summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci_variable_list/components/ci_group_variables.vue
blob: 4466a6a8081bb6493a4bc7a5f2cbe23e16725fb9 (plain)
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
<script>
import { convertToGraphQLId } from '~/graphql_shared/utils';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import {
  ADD_MUTATION_ACTION,
  DELETE_MUTATION_ACTION,
  GRAPHQL_GROUP_TYPE,
  UPDATE_MUTATION_ACTION,
} from '../constants';
import getGroupVariables from '../graphql/queries/group_variables.query.graphql';
import addGroupVariable from '../graphql/mutations/group_add_variable.mutation.graphql';
import deleteGroupVariable from '../graphql/mutations/group_delete_variable.mutation.graphql';
import updateGroupVariable from '../graphql/mutations/group_update_variable.mutation.graphql';
import CiVariableShared from './ci_variable_shared.vue';

export default {
  components: {
    CiVariableShared,
  },
  mixins: [glFeatureFlagsMixin()],
  inject: ['groupPath', 'groupId'],
  computed: {
    areScopedVariablesAvailable() {
      return this.glFeatures.groupScopedCiVariables;
    },
    graphqlId() {
      return convertToGraphQLId(GRAPHQL_GROUP_TYPE, this.groupId);
    },
  },
  mutationData: {
    [ADD_MUTATION_ACTION]: addGroupVariable,
    [UPDATE_MUTATION_ACTION]: updateGroupVariable,
    [DELETE_MUTATION_ACTION]: deleteGroupVariable,
  },
  queryData: {
    ciVariables: {
      lookup: (data) => data?.group?.ciVariables,
      query: getGroupVariables,
    },
  },
};
</script>

<template>
  <ci-variable-shared
    :id="graphqlId"
    :are-scoped-variables-available="areScopedVariablesAvailable"
    component-name="GroupVariables"
    entity="group"
    :full-path="groupPath"
    :mutation-data="$options.mutationData"
    :query-data="$options.queryData"
  />
</template>