diff options
Diffstat (limited to 'app/assets/javascripts/packages_and_registries')
3 files changed, 134 insertions, 0 deletions
diff --git a/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue new file mode 100644 index 00000000000..32f05d0e298 --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue @@ -0,0 +1,111 @@ +<script> +import { GlCard, GlTable, GlLoadingIcon } from '@gitlab/ui'; +import packagesProtectionRuleQuery from '~/packages_and_registries/settings/project/graphql/queries/get_packages_protection_rules.query.graphql'; +import SettingsBlock from '~/packages_and_registries/shared/components/settings_block.vue'; +import { s__ } from '~/locale'; + +const PAGINATION_DEFAULT_PER_PAGE = 10; + +export default { + components: { + SettingsBlock, + GlCard, + GlTable, + GlLoadingIcon, + }, + inject: ['projectPath'], + i18n: { + settingBlockTitle: s__('PackageRegistry|Protected packages'), + settingBlockDescription: s__( + 'PackageRegistry|When a package is protected then only certain user roles are able to update and delete the protected package. This helps to avoid tampering with the package.', + ), + }, + data() { + return { + fetchSettingsError: false, + packageProtectionRules: [], + }; + }, + computed: { + tableItems() { + return this.packageProtectionRules.map((packagesProtectionRule) => { + return { + col_1_package_name_pattern: packagesProtectionRule.packageNamePattern, + col_2_package_type: packagesProtectionRule.packageType, + col_3_push_protected_up_to_access_level: + packagesProtectionRule.pushProtectedUpToAccessLevel, + }; + }); + }, + totalItems() { + return this.packageProtectionRules.length; + }, + }, + apollo: { + packageProtectionRules: { + query: packagesProtectionRuleQuery, + variables() { + return { + projectPath: this.projectPath, + first: PAGINATION_DEFAULT_PER_PAGE, + }; + }, + update: (data) => { + return data.project?.packagesProtectionRules?.nodes || []; + }, + error(e) { + this.fetchSettingsError = e; + }, + }, + }, + fields: [ + { + key: 'col_1_package_name_pattern', + label: s__('PackageRegistry|Package name pattern'), + }, + { key: 'col_2_package_type', label: s__('PackageRegistry|Package type') }, + { + key: 'col_3_push_protected_up_to_access_level', + label: s__('PackageRegistry|Push protected up to access level'), + }, + ], +}; +</script> + +<template> + <settings-block> + <template #title>{{ $options.i18n.settingBlockTitle }}</template> + + <template #description> + {{ $options.i18n.settingBlockDescription }} + </template> + + <template #default> + <gl-card + class="gl-new-card" + header-class="gl-new-card-header" + body-class="gl-new-card-body gl-px-0" + > + <template #header> + <div class="gl-new-card-title-wrapper gl-justify-content-space-between"> + <h3 class="gl-new-card-title">{{ $options.i18n.settingBlockTitle }}</h3> + </div> + </template> + + <template #default> + <gl-table + :items="tableItems" + :fields="$options.fields" + show-empty + stacked="md" + class="mb-3" + > + <template #table-busy> + <gl-loading-icon size="sm" class="gl-my-5" /> + </template> + </gl-table> + </template> + </gl-card> + </template> + </settings-block> +</template> diff --git a/app/assets/javascripts/packages_and_registries/settings/project/components/registry_settings_app.vue b/app/assets/javascripts/packages_and_registries/settings/project/components/registry_settings_app.vue index 06af69ff250..8e4c50b199b 100644 --- a/app/assets/javascripts/packages_and_registries/settings/project/components/registry_settings_app.vue +++ b/app/assets/javascripts/packages_and_registries/settings/project/components/registry_settings_app.vue @@ -8,6 +8,7 @@ import { } from '~/packages_and_registries/settings/project/constants'; import ContainerExpirationPolicy from '~/packages_and_registries/settings/project/components/container_expiration_policy.vue'; import PackagesCleanupPolicy from '~/packages_and_registries/settings/project/components/packages_cleanup_policy.vue'; +import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; export default { components: { @@ -18,7 +19,10 @@ export default { ), GlAlert, PackagesCleanupPolicy, + PackagesProtectionRules: () => + import('~/packages_and_registries/settings/project/components/packages_protection_rules.vue'), }, + mixins: [glFeatureFlagsMixin()], inject: [ 'showContainerRegistrySettings', 'showPackageRegistrySettings', @@ -32,6 +36,11 @@ export default { showAlert: false, }; }, + computed: { + showProtectedPackagesSettings() { + return this.showPackageRegistrySettings && this.glFeatures.packagesProtectedPackages; + }, + }, mounted() { this.checkAlert(); }, @@ -60,6 +69,7 @@ export default { > {{ $options.i18n.UPDATE_SETTINGS_SUCCESS_MESSAGE }} </gl-alert> + <packages-protection-rules v-if="showProtectedPackagesSettings" /> <packages-cleanup-policy v-if="showPackageRegistrySettings" /> <container-expiration-policy v-if="showContainerRegistrySettings" /> <dependency-proxy-packages-settings v-if="showDependencyProxySettings" /> diff --git a/app/assets/javascripts/packages_and_registries/settings/project/graphql/queries/get_packages_protection_rules.query.graphql b/app/assets/javascripts/packages_and_registries/settings/project/graphql/queries/get_packages_protection_rules.query.graphql new file mode 100644 index 00000000000..e0a072b93e4 --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/project/graphql/queries/get_packages_protection_rules.query.graphql @@ -0,0 +1,13 @@ +query getProjectPackageProtectionRules($projectPath: ID!, $first: Int) { + project(fullPath: $projectPath) { + id + packagesProtectionRules(first: $first) { + nodes { + id + packageNamePattern + packageType + pushProtectedUpToAccessLevel + } + } + } +} |