diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 18:08:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 18:08:26 +0300 |
commit | 4279dbc29c63f614e6439e104204165ff0517a59 (patch) | |
tree | a2a2dc637398f9c66eeda39ee9e3e209370a84c4 /app/assets/javascripts/projects | |
parent | 7912017a137da35c48071a048c99d27737c29f0f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/projects')
3 files changed, 45 insertions, 11 deletions
diff --git a/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue b/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue index ea4b657fe80..a9eb2a53fbf 100644 --- a/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue +++ b/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue @@ -54,7 +54,10 @@ export default { v-for="rule in branchRules" :key="rule.name" :name="rule.name" + :is-default="rule.isDefault" :branch-protection="rule.branchProtection" + :status-checks-total="rule.externalStatusChecks.nodes.length" + :approval-rules-total="rule.approvalRules.nodes.length" /> <span v-if="!branchRules.length" data-testid="empty">{{ $options.i18n.emptyState }}</span> diff --git a/app/assets/javascripts/projects/settings/repository/branch_rules/components/branch_rule.vue b/app/assets/javascripts/projects/settings/repository/branch_rules/components/branch_rule.vue index cdf8c36d52c..78c824c66d1 100644 --- a/app/assets/javascripts/projects/settings/repository/branch_rules/components/branch_rule.vue +++ b/app/assets/javascripts/projects/settings/repository/branch_rules/components/branch_rule.vue @@ -1,13 +1,14 @@ <script> import { GlBadge, GlButton } from '@gitlab/ui'; -import { s__ } from '~/locale'; +import { s__, sprintf, n__ } from '~/locale'; export const i18n = { defaultLabel: s__('BranchRules|default'), - protectedLabel: s__('BranchRules|protected'), detailsButtonLabel: s__('BranchRules|Details'), allowForcePush: s__('BranchRules|Allowed to force push'), codeOwnerApprovalRequired: s__('BranchRules|Requires CODEOWNERS approval'), + statusChecks: s__('BranchRules|%{total} status %{subject}'), + approvalRules: s__('BranchRules|%{total} approval %{subject}'), }; export default { @@ -32,16 +33,21 @@ export default { required: false, default: false, }, - isProtected: { - type: Boolean, - required: false, - default: false, - }, branchProtection: { type: Object, required: false, default: () => {}, }, + statusChecksTotal: { + type: Number, + required: false, + default: 0, + }, + approvalRulesTotal: { + type: Number, + required: false, + default: 0, + }, }, computed: { hasApprovalDetails() { @@ -50,6 +56,18 @@ export default { detailsPath() { return `${this.branchRulesPath}?branch=${this.name}`; }, + statusChecksText() { + return sprintf(this.$options.i18n.statusChecks, { + total: this.statusChecksTotal, + subject: n__('check', 'checks', this.statusChecksTotal), + }); + }, + approvalRulesText() { + return sprintf(this.$options.i18n.approvalRules, { + total: this.approvalRulesTotal, + subject: n__('rule', 'rules', this.approvalRulesTotal), + }); + }, approvalDetails() { const approvalDetails = []; if (this.branchProtection.allowForcePush) { @@ -58,6 +76,12 @@ export default { if (this.branchProtection.codeOwnerApprovalRequired) { approvalDetails.push(this.$options.i18n.codeOwnerApprovalRequired); } + if (this.statusChecksTotal) { + approvalDetails.push(this.statusChecksText); + } + if (this.approvalRulesTotal) { + approvalDetails.push(this.approvalRulesText); + } return approvalDetails; }, }, @@ -73,10 +97,6 @@ export default { $options.i18n.defaultLabel }}</gl-badge> - <gl-badge v-if="isProtected" variant="success" size="sm" class="gl-ml-2">{{ - $options.i18n.protectedLabel - }}</gl-badge> - <ul v-if="hasApprovalDetails" class="gl-pl-6 gl-mt-2 gl-mb-0 gl-text-gray-500"> <li v-for="(detail, index) in approvalDetails" :key="index">{{ detail }}</li> </ul> diff --git a/app/assets/javascripts/projects/settings/repository/branch_rules/graphql/queries/branch_rules.query.graphql b/app/assets/javascripts/projects/settings/repository/branch_rules/graphql/queries/branch_rules.query.graphql index 20b99702f68..49e089e7805 100644 --- a/app/assets/javascripts/projects/settings/repository/branch_rules/graphql/queries/branch_rules.query.graphql +++ b/app/assets/javascripts/projects/settings/repository/branch_rules/graphql/queries/branch_rules.query.graphql @@ -4,10 +4,21 @@ query getBranchRules($projectPath: ID!) { branchRules { nodes { name + isDefault branchProtection { allowForcePush codeOwnerApprovalRequired } + externalStatusChecks { + nodes { + id + } + } + approvalRules { + nodes { + id + } + } } } } |