summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue')
-rw-r--r--app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue60
1 files changed, 26 insertions, 34 deletions
diff --git a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
index 0987603cafd..c6f7d5e44ad 100644
--- a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
+++ b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue
@@ -1,12 +1,10 @@
<script>
-import { mapState, mapActions } from 'vuex';
-import { __ } from '~/locale';
-import Flash from '~/flash';
+import { mapState } from 'vuex';
+import { __, sprintf } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue';
import eventHub from '~/sidebar/event_hub';
import EditForm from './edit_form.vue';
-import recaptchaModalImplementor from '~/vue_shared/mixins/recaptcha_modal_implementor';
export default {
components: {
@@ -16,7 +14,6 @@ export default {
directives: {
tooltip,
},
- mixins: [recaptchaModalImplementor],
props: {
fullPath: {
required: true,
@@ -26,9 +23,10 @@ export default {
required: true,
type: Boolean,
},
- service: {
- required: true,
- type: Object,
+ issuableType: {
+ required: false,
+ type: String,
+ default: 'issue',
},
},
data() {
@@ -37,45 +35,36 @@ export default {
};
},
computed: {
- ...mapState({ confidential: ({ noteableData }) => noteableData.confidential }),
+ ...mapState({
+ confidential: ({ noteableData, confidential }) => {
+ if (noteableData) {
+ return noteableData.confidential;
+ }
+ return Boolean(confidential);
+ },
+ }),
confidentialityIcon() {
return this.confidential ? 'eye-slash' : 'eye';
},
tooltipLabel() {
return this.confidential ? __('Confidential') : __('Not confidential');
},
+ confidentialText() {
+ return sprintf(__('This %{issuableType} is confidential'), {
+ issuableType: this.issuableType,
+ });
+ },
},
created() {
- eventHub.$on('updateConfidentialAttribute', this.updateConfidentialAttribute);
eventHub.$on('closeConfidentialityForm', this.toggleForm);
},
beforeDestroy() {
- eventHub.$off('updateConfidentialAttribute', this.updateConfidentialAttribute);
eventHub.$off('closeConfidentialityForm', this.toggleForm);
},
methods: {
- ...mapActions(['setConfidentiality']),
toggleForm() {
this.edit = !this.edit;
},
- closeForm() {
- this.edit = false;
- },
- updateConfidentialAttribute() {
- // TODO: rm when FF is defaulted to on.
- const confidential = !this.confidential;
- this.service
- .update('issue', { confidential })
- .then(({ data }) => this.checkForSpam(data))
- .then(() => window.location.reload())
- .catch(error => {
- if (error.name === 'SpamError') {
- this.openRecaptcha();
- } else {
- Flash(__('Something went wrong trying to change the confidentiality of this issue'));
- }
- });
- },
},
};
</script>
@@ -109,7 +98,12 @@ export default {
>
</div>
<div class="value sidebar-item-value hide-collapsed">
- <edit-form v-if="edit" :is-confidential="confidential" :full-path="fullPath" />
+ <edit-form
+ v-if="edit"
+ :confidential="confidential"
+ :full-path="fullPath"
+ :issuable-type="issuableType"
+ />
<div v-if="!confidential" class="no-value sidebar-item-value" data-testid="not-confidential">
<icon :size="16" name="eye" aria-hidden="true" class="sidebar-item-icon inline" />
{{ __('Not confidential') }}
@@ -121,10 +115,8 @@ export default {
aria-hidden="true"
class="sidebar-item-icon inline is-active"
/>
- {{ __('This issue is confidential') }}
+ {{ confidentialText }}
</div>
</div>
-
- <recaptcha-modal v-if="showRecaptcha" :html="recaptchaHTML" @close="closeRecaptcha" />
</div>
</template>