Commit 92722c0d authored by Lee Tickett's avatar Lee Tickett Committed by Martin Wortschack

Replace harcoded values in settings panel

parent 690a1f3b
...@@ -46,7 +46,11 @@ export default { ...@@ -46,7 +46,11 @@ export default {
allowedVisibilityOptions: { allowedVisibilityOptions: {
type: Array, type: Array,
required: false, required: false,
default: () => [0, 10, 20], default: () => [
visibilityOptions.PRIVATE,
visibilityOptions.INTERNAL,
visibilityOptions.PUBLIC,
],
}, },
lfsAvailable: { lfsAvailable: {
type: Boolean, type: Boolean,
...@@ -118,16 +122,14 @@ export default { ...@@ -118,16 +122,14 @@ export default {
const defaults = { const defaults = {
visibilityOptions, visibilityOptions,
visibilityLevel: visibilityOptions.PUBLIC, visibilityLevel: visibilityOptions.PUBLIC,
// TODO: Change all of these to use the visibilityOptions constants issuesAccessLevel: featureAccessLevel.EVERYONE,
// https://gitlab.com/gitlab-org/gitlab/-/issues/214667 repositoryAccessLevel: featureAccessLevel.EVERYONE,
issuesAccessLevel: 20, forkingAccessLevel: featureAccessLevel.EVERYONE,
repositoryAccessLevel: 20, mergeRequestsAccessLevel: featureAccessLevel.EVERYONE,
forkingAccessLevel: 20, buildsAccessLevel: featureAccessLevel.EVERYONE,
mergeRequestsAccessLevel: 20, wikiAccessLevel: featureAccessLevel.EVERYONE,
buildsAccessLevel: 20, snippetsAccessLevel: featureAccessLevel.EVERYONE,
wikiAccessLevel: 20, pagesAccessLevel: featureAccessLevel.EVERYONE,
snippetsAccessLevel: 20,
pagesAccessLevel: 20,
metricsDashboardAccessLevel: featureAccessLevel.PROJECT_MEMBERS, metricsDashboardAccessLevel: featureAccessLevel.PROJECT_MEMBERS,
containerRegistryEnabled: true, containerRegistryEnabled: true,
lfsEnabled: true, lfsEnabled: true,
...@@ -180,7 +182,7 @@ export default { ...@@ -180,7 +182,7 @@ export default {
}, },
repositoryEnabled() { repositoryEnabled() {
return this.repositoryAccessLevel > 0; return this.repositoryAccessLevel > featureAccessLevel.NOT_ENABLED;
}, },
visibilityLevelDescription() { visibilityLevelDescription() {
...@@ -206,40 +208,70 @@ export default { ...@@ -206,40 +208,70 @@ export default {
visibilityLevel(value, oldValue) { visibilityLevel(value, oldValue) {
if (value === visibilityOptions.PRIVATE) { if (value === visibilityOptions.PRIVATE) {
// when private, features are restricted to "only team members" // when private, features are restricted to "only team members"
this.issuesAccessLevel = Math.min(10, this.issuesAccessLevel); this.issuesAccessLevel = Math.min(
this.repositoryAccessLevel = Math.min(10, this.repositoryAccessLevel); featureAccessLevel.PROJECT_MEMBERS,
this.mergeRequestsAccessLevel = Math.min(10, this.mergeRequestsAccessLevel); this.issuesAccessLevel,
this.buildsAccessLevel = Math.min(10, this.buildsAccessLevel); );
this.wikiAccessLevel = Math.min(10, this.wikiAccessLevel); this.repositoryAccessLevel = Math.min(
this.snippetsAccessLevel = Math.min(10, this.snippetsAccessLevel); featureAccessLevel.PROJECT_MEMBERS,
this.metricsDashboardAccessLevel = Math.min(10, this.metricsDashboardAccessLevel); this.repositoryAccessLevel,
if (this.pagesAccessLevel === 20) { );
this.mergeRequestsAccessLevel = Math.min(
featureAccessLevel.PROJECT_MEMBERS,
this.mergeRequestsAccessLevel,
);
this.buildsAccessLevel = Math.min(
featureAccessLevel.PROJECT_MEMBERS,
this.buildsAccessLevel,
);
this.wikiAccessLevel = Math.min(featureAccessLevel.PROJECT_MEMBERS, this.wikiAccessLevel);
this.snippetsAccessLevel = Math.min(
featureAccessLevel.PROJECT_MEMBERS,
this.snippetsAccessLevel,
);
this.metricsDashboardAccessLevel = Math.min(
featureAccessLevel.PROJECT_MEMBERS,
this.metricsDashboardAccessLevel,
);
if (this.pagesAccessLevel === featureAccessLevel.EVERYONE) {
// When from Internal->Private narrow access for only members // When from Internal->Private narrow access for only members
this.pagesAccessLevel = 10; this.pagesAccessLevel = featureAccessLevel.PROJECT_MEMBERS;
} }
this.highlightChanges(); this.highlightChanges();
} else if (oldValue === visibilityOptions.PRIVATE) { } else if (oldValue === visibilityOptions.PRIVATE) {
// if changing away from private, make enabled features more permissive // if changing away from private, make enabled features more permissive
if (this.issuesAccessLevel > 0) this.issuesAccessLevel = 20; if (this.issuesAccessLevel > featureAccessLevel.NOT_ENABLED)
if (this.repositoryAccessLevel > 0) this.repositoryAccessLevel = 20; this.issuesAccessLevel = featureAccessLevel.EVERYONE;
if (this.mergeRequestsAccessLevel > 0) this.mergeRequestsAccessLevel = 20; if (this.repositoryAccessLevel > featureAccessLevel.NOT_ENABLED)
if (this.buildsAccessLevel > 0) this.buildsAccessLevel = 20; this.repositoryAccessLevel = featureAccessLevel.EVERYONE;
if (this.wikiAccessLevel > 0) this.wikiAccessLevel = 20; if (this.mergeRequestsAccessLevel > featureAccessLevel.NOT_ENABLED)
if (this.snippetsAccessLevel > 0) this.snippetsAccessLevel = 20; this.mergeRequestsAccessLevel = featureAccessLevel.EVERYONE;
if (this.pagesAccessLevel === 10) this.pagesAccessLevel = 20; if (this.buildsAccessLevel > featureAccessLevel.NOT_ENABLED)
if (this.metricsDashboardAccessLevel === 10) this.metricsDashboardAccessLevel = 20; this.buildsAccessLevel = featureAccessLevel.EVERYONE;
if (this.wikiAccessLevel > featureAccessLevel.NOT_ENABLED)
this.wikiAccessLevel = featureAccessLevel.EVERYONE;
if (this.snippetsAccessLevel > featureAccessLevel.NOT_ENABLED)
this.snippetsAccessLevel = featureAccessLevel.EVERYONE;
if (this.pagesAccessLevel === featureAccessLevel.PROJECT_MEMBERS)
this.pagesAccessLevel = featureAccessLevel.EVERYONE;
if (this.metricsDashboardAccessLevel === featureAccessLevel.PROJECT_MEMBERS)
this.metricsDashboardAccessLevel = featureAccessLevel.EVERYONE;
this.highlightChanges(); this.highlightChanges();
} }
}, },
issuesAccessLevel(value, oldValue) { issuesAccessLevel(value, oldValue) {
if (value === 0) toggleHiddenClassBySelector('.issues-feature', true); if (value === featureAccessLevel.NOT_ENABLED)
else if (oldValue === 0) toggleHiddenClassBySelector('.issues-feature', false); toggleHiddenClassBySelector('.issues-feature', true);
else if (oldValue === featureAccessLevel.NOT_ENABLED)
toggleHiddenClassBySelector('.issues-feature', false);
}, },
mergeRequestsAccessLevel(value, oldValue) { mergeRequestsAccessLevel(value, oldValue) {
if (value === 0) toggleHiddenClassBySelector('.merge-requests-feature', true); if (value === featureAccessLevel.NOT_ENABLED)
else if (oldValue === 0) toggleHiddenClassBySelector('.merge-requests-feature', false); toggleHiddenClassBySelector('.merge-requests-feature', true);
else if (oldValue === featureAccessLevel.NOT_ENABLED)
toggleHiddenClassBySelector('.merge-requests-feature', false);
}, },
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment