All files / app/assets/javascripts/packages_and_registries/settings/group/components group_settings_app.vue

100% Statements 13/13
100% Branches 0/0
100% Functions 9/9
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95              1x                             21x             21x             42x     42x     42x     42x         9x     6x 6x 6x     12x 12x                                                                      
<script>
import { GlAlert } from '@gitlab/ui';
import { __ } from '~/locale';
import PackagesSettings from '~/packages_and_registries/settings/group/components/packages_settings.vue';
import PackagesForwardingSettings from '~/packages_and_registries/settings/group/components/packages_forwarding_settings.vue';
import DependencyProxySettings from '~/packages_and_registries/settings/group/components/dependency_proxy_settings.vue';
 
import getGroupPackagesSettingsQuery from '~/packages_and_registries/settings/group/graphql/queries/get_group_packages_settings.query.graphql';
 
export default {
  name: 'GroupSettingsApp',
  components: {
    GlAlert,
    PackagesSettings,
    PackagesForwardingSettings,
    DependencyProxySettings,
  },
  inject: ['groupPath'],
  apollo: {
    group: {
      query: getGroupPackagesSettingsQuery,
      variables() {
        return {
          fullPath: this.groupPath,
        };
      },
    },
  },
  data() {
    return {
      group: {},
      alertMessage: null,
    };
  },
  computed: {
    packageSettings() {
      return this.group?.packageSettings || {};
    },
    dependencyProxySettings() {
      return this.group?.dependencyProxySetting || {};
    },
    dependencyProxyImageTtlPolicy() {
      return this.group?.dependencyProxyImageTtlPolicy || {};
    },
    isLoading() {
      return this.$apollo.queries.group.loading;
    },
  },
  methods: {
    dismissAlert() {
      this.alertMessage = null;
    },
    handleSuccess() {
      const successMessage = __('Settings saved successfully.');
      this.$toast.show(successMessage);
      this.dismissAlert();
    },
    handleError() {
      const errorMessage = __('An error occurred while saving the settings.');
      this.alertMessage = errorMessage;
    },
  },
};
</script>
 
<template>
  <div data-testid="packages-and-registries-group-settings">
    <gl-alert v-if="alertMessage" variant="warning" class="gl-mt-4" @dismiss="dismissAlert">
      {{ alertMessage }}
    </gl-alert>
 
    <packages-settings
      class="settings-section-no-bottom"
      :package-settings="packageSettings"
      :is-loading="isLoading"
      @success="handleSuccess"
      @error="handleError"
    />
 
    <packages-forwarding-settings
      :forward-settings="packageSettings"
      @success="handleSuccess"
      @error="handleError"
    />
 
    <dependency-proxy-settings
      :dependency-proxy-settings="dependencyProxySettings"
      :dependency-proxy-image-ttl-policy="dependencyProxyImageTtlPolicy"
      :is-loading="isLoading"
      @success="handleSuccess"
      @error="handleError"
    />
  </div>
</template>