Skip to content
代码片段 群组 项目
提交 78f00682 编辑于 作者: Jacques's avatar Jacques
浏览文件

Prevent editing squash option for All protected branches

Prevents editing squash options when the target is All protected branches
上级 f847444d
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
...@@ -230,8 +230,11 @@ export default { ...@@ -230,8 +230,11 @@ export default {
isAllBranchesRule() { isAllBranchesRule() {
return this.branch === this.$options.i18n.allBranches; return this.branch === this.$options.i18n.allBranches;
}, },
isAllProtectedBranchesRule() {
return this.branch === this.$options.i18n.allProtectedBranches;
},
isPredefinedRule() { isPredefinedRule() {
return this.isAllBranchesRule || this.branch === this.$options.i18n.allProtectedBranches; return this.isAllBranchesRule || this.isAllProtectedBranchesRule;
}, },
hasPushAccessLevelSet() { hasPushAccessLevelSet() {
return this.pushAccessLevels?.total > 0; return this.pushAccessLevels?.total > 0;
...@@ -251,7 +254,11 @@ export default { ...@@ -251,7 +254,11 @@ export default {
return this.showApprovers || this.showSquashSetting; return this.showApprovers || this.showSquashSetting;
}, },
showSquashSetting() { showSquashSetting() {
return this.glFeatures.branchRuleSquashSettings && !this.branch?.includes('*'); // Squash settings are not available for wildcards return (
this.glFeatures.branchRuleSquashSettings &&
!this.branch?.includes('*') &&
!this.isAllProtectedBranchesRule
); // Squash settings are not available for wildcards or All protected branches
}, },
showEditSquashSetting() { showEditSquashSetting() {
return ( return (
......
...@@ -319,6 +319,22 @@ describe('View branch rules', () => { ...@@ -319,6 +319,22 @@ describe('View branch rules', () => {
expect(findSquashSettingSection().exists()).toBe(false); expect(findSquashSettingSection().exists()).toBe(false);
}); });
it.each`
branch | expectedExists | description
${'main'} | ${true} | ${'shows squash section for regular branch'}
${'All branches'} | ${true} | ${'shows squash section for all branches'}
${'All protected branches'} | ${false} | ${'hides squash section for protected branches'}
${'feature-*'} | ${false} | ${'hides squash section for wildcard branches'}
`('$description', async ({ branch, expectedExists }) => {
jest.spyOn(util, 'getParameterByName').mockReturnValueOnce(branch);
await createComponent({
glFeatures: { branchRuleSquashSettings: true },
});
expect(findSquashSettingSection().exists()).toBe(expectedExists);
});
}); });
it('renders page title', () => { it('renders page title', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册