From e55b70e10a0f3a7d4c0db6610021220dab248cc7 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 5 Jun 2023 15:41:58 +0200 Subject: [PATCH 1/6] feat: Protected packages: Create protection rules in project setting ui MR includes: - Add form for creating new package protection rule - Refetch list of protection rules after submission Changelog: added --- .../packages_protection_rule_form.vue | 191 ++++++++++ .../components/packages_protection_rules.vue | 33 ++ ..._packages_protection_rule.mutation.graphql | 11 + locale/gitlab.pot | 12 + .../packages_protection_rule_form_spec.js | 327 ++++++++++++++++++ .../packages_protection_rules_spec.js | 81 +++++ .../settings/project/settings/mock_data.js | 22 ++ 7 files changed, 677 insertions(+) create mode 100644 app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rule_form.vue create mode 100644 app/assets/javascripts/packages_and_registries/settings/project/graphql/mutations/create_packages_protection_rule.mutation.graphql create mode 100644 spec/frontend/packages_and_registries/settings/project/settings/components/packages_protection_rule_form_spec.js diff --git a/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rule_form.vue b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rule_form.vue new file mode 100644 index 00000000000000..3b4a4ed26f1c94 --- /dev/null +++ b/app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rule_form.vue @@ -0,0 +1,191 @@ + + + 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 index d917777880332d..c2e6a376367a4d 100644 --- 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 @@ -2,6 +2,7 @@ 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 PackagesProtectionRuleForm from '~/packages_and_registries/settings/project/components/packages_protection_rule_form.vue'; import { s__ } from '~/locale'; const PAGINATION_DEFAULT_PER_PAGE = 10; @@ -12,6 +13,7 @@ export default { GlCard, GlTable, GlLoadingIcon, + PackagesProtectionRuleForm, }, inject: ['projectPath'], i18n: { @@ -24,6 +26,7 @@ export default { return { fetchSettingsError: false, packageProtectionRules: [], + protectionRuleFormVisibility: false, }; }, computed: { @@ -43,6 +46,9 @@ export default { isLoadingPackageProtectionRules() { return this.$apollo.queries.packageProtectionRules.loading; }, + isAddProtectionRuleButtonDisabled() { + return this.protectionRuleFormVisibility; + }, }, apollo: { packageProtectionRules: { @@ -72,6 +78,18 @@ export default { label: s__('PackageRegistry|Push protected up to access level'), }, ], + methods: { + showProtectionRuleForm() { + this.protectionRuleFormVisibility = true; + }, + hideProtectionRuleForm() { + this.protectionRuleFormVisibility = false; + }, + refetchProtectionRules() { + this.$apollo.queries.packageProtectionRules.refetch(); + this.hideProtectionRuleForm(); + }, + }, }; @@ -92,10 +110,25 @@ export default {