1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<script>
import { mapActions } from 'vuex';
import { IssuableType } from '~/issue_show/constants';
import { fetchPolicies } from '~/lib/graphql';
import { confidentialityQueries } from '~/sidebar/constants';
import { defaultClient as gqlClient } from '~/sidebar/graphql';
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() {
if (this.issuableType !== IssuableType.Issue && this.issuableType !== IssuableType.Epic) {
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>
|