Commit 81c69c28 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'issue-edit-inline-confidential' into 'issue-edit-inline'

Issue edit inline confidential

See merge request !11389
parents 4693aa9c 6963442d
...@@ -41,6 +41,10 @@ export default { ...@@ -41,6 +41,10 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
isConfidential: {
type: Boolean,
required: true,
},
markdownPreviewUrl: { markdownPreviewUrl: {
type: String, type: String,
required: true, required: true,
...@@ -78,6 +82,7 @@ export default { ...@@ -78,6 +82,7 @@ export default {
this.showForm = true; this.showForm = true;
this.store.formState = { this.store.formState = {
title: this.state.titleText, title: this.state.titleText,
confidential: this.isConfidential,
description: this.state.descriptionText, description: this.state.descriptionText,
}; };
}, },
...@@ -86,7 +91,13 @@ export default { ...@@ -86,7 +91,13 @@ export default {
}, },
updateIssuable() { updateIssuable() {
this.service.updateIssuable(this.store.formState) this.service.updateIssuable(this.store.formState)
.then(() => { .then((res) => {
const data = res.json();
if (data.confidential !== this.isConfidential) {
location.reload();
}
eventHub.$emit('close.form'); eventHub.$emit('close.form');
}) })
.catch(() => { .catch(() => {
......
<script>
export default {
props: {
formState: {
type: Object,
required: true,
},
},
};
</script>
<template>
<fieldset class="checkbox">
<label for="issue-confidential">
<input
type="checkbox"
value="1"
id="issue-confidential"
v-model="formState.confidential" />
This issue is confidential and should only be visible to team members with at least Reporter access.
</label>
</fieldset>
</template>
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import titleField from './fields/title.vue'; import titleField from './fields/title.vue';
import descriptionField from './fields/description.vue'; import descriptionField from './fields/description.vue';
import editActions from './edit_actions.vue'; import editActions from './edit_actions.vue';
import confidentialCheckbox from './fields/confidential_checkbox.vue';
export default { export default {
props: { props: {
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
titleField, titleField,
descriptionField, descriptionField,
editActions, editActions,
confidentialCheckbox,
}, },
}; };
</script> </script>
...@@ -34,6 +36,8 @@ ...@@ -34,6 +36,8 @@
<form> <form>
<title-field <title-field
:form-state="formState" /> :form-state="formState" />
<confidential-checkbox
:form-state="formState" />
<description-field <description-field
:form-state="formState" :form-state="formState"
:markdown-preview-url="markdownPreviewUrl" :markdown-preview-url="markdownPreviewUrl"
......
...@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
canDestroy, canDestroy,
endpoint, endpoint,
issuableRef, issuableRef,
isConfidential,
markdownPreviewUrl, markdownPreviewUrl,
markdownDocs, markdownDocs,
} = issuableElement.dataset; } = issuableElement.dataset;
...@@ -37,6 +38,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -37,6 +38,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle: issuableTitleElement.innerHTML, initialTitle: issuableTitleElement.innerHTML,
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '', initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '', initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
isConfidential: gl.utils.convertPermissionToBoolean(isConfidential),
markdownPreviewUrl, markdownPreviewUrl,
markdownDocs, markdownDocs,
}; };
...@@ -51,6 +53,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -51,6 +53,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle: this.initialTitle, initialTitle: this.initialTitle,
initialDescriptionHtml: this.initialDescriptionHtml, initialDescriptionHtml: this.initialDescriptionHtml,
initialDescriptionText: this.initialDescriptionText, initialDescriptionText: this.initialDescriptionText,
isConfidential: this.isConfidential,
markdownPreviewUrl: this.markdownPreviewUrl, markdownPreviewUrl: this.markdownPreviewUrl,
markdownDocs: this.markdownDocs, markdownDocs: this.markdownDocs,
}, },
......
...@@ -14,6 +14,7 @@ export default class Store { ...@@ -14,6 +14,7 @@ export default class Store {
}; };
this.formState = { this.formState = {
title: '', title: '',
confidential: false,
description: '', description: '',
}; };
} }
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"can-update" => can?(current_user, :update_issue, @issue).to_s, "can-update" => can?(current_user, :update_issue, @issue).to_s,
"can-destroy" => can?(current_user, :destroy_issue, @issue).to_s, "can-destroy" => can?(current_user, :destroy_issue, @issue).to_s,
"issuable-ref" => @issue.to_reference, "issuable-ref" => @issue.to_reference,
"is-confidential" => @issue.confidential.to_s,
"markdown-preview-url" => preview_markdown_path(@project), "markdown-preview-url" => preview_markdown_path(@project),
"markdown-docs" => help_page_path('user/markdown'), "markdown-docs" => help_page_path('user/markdown'),
} } } }
......
...@@ -35,6 +35,7 @@ describe('Issuable output', () => { ...@@ -35,6 +35,7 @@ describe('Issuable output', () => {
initialDescriptionHtml: '', initialDescriptionHtml: '',
initialDescriptionText: '', initialDescriptionText: '',
showForm: false, showForm: false,
isConfidential: false,
}, },
}).$mount(); }).$mount();
}); });
...@@ -108,6 +109,29 @@ describe('Issuable output', () => { ...@@ -108,6 +109,29 @@ describe('Issuable output', () => {
}); });
}); });
it('reloads the page if the confidential status has changed', (done) => {
spyOn(window.location, 'reload');
spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => {
resolve({
json() {
return {
confidential: true,
};
},
});
}));
vm.updateIssuable();
setTimeout(() => {
expect(
window.location.reload,
).toHaveBeenCalled();
done();
});
});
it('closes form on error', (done) => { it('closes form on error', (done) => {
spyOn(window, 'Flash').and.callThrough(); spyOn(window, 'Flash').and.callThrough();
spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve, reject) => { spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve, reject) => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment