debian-mirror-gitlab/app/assets/javascripts/notes/components/sidebar_subscription.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
Vue
Raw Normal View History

2021-04-17 20:07:23 +05:30
<script>
import { mapActions } from 'vuex';
2023-04-23 21:23:45 +05:30
import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants';
2021-04-17 20:07:23 +05:30
import { fetchPolicies } from '~/lib/graphql';
import { confidentialityQueries } from '~/sidebar/constants';
2022-10-11 01:57:18 +05:30
import { defaultClient as gqlClient } from '~/graphql_shared/issuable_client';
2021-04-17 20:07:23 +05:30
export default {
props: {
noteableData: {
type: Object,
required: true,
},
iid: {
type: Number,
required: true,
},
},
computed: {
fullPath() {
if (this.noteableData.web_url) {
return this.noteableData.web_url.split('/-/')[0].substring(1).replace('groups/', '');
}
return null;
},
issuableType() {
return this.noteableData.noteableType.toLowerCase();
},
},
created() {
2023-04-23 21:23:45 +05:30
if (this.issuableType !== TYPE_ISSUE && this.issuableType !== TYPE_EPIC) {
2021-04-17 20:07:23 +05:30
return;
}
gqlClient
.watchQuery({
query: confidentialityQueries[this.issuableType].query,
variables: {
iid: String(this.iid),
fullPath: this.fullPath,
},
fetchPolicy: fetchPolicies.CACHE_ONLY,
})
.subscribe((res) => {
const issuable = res.data?.workspace?.issuable;
if (issuable) {
this.setConfidentiality(issuable.confidential);
}
});
},
methods: {
...mapActions(['setConfidentiality']),
},
render() {
return null;
},
};
</script>