Skip to content
Snippets Groups Projects

Add managing protected branches as custom permission

Merged Jarka Košanová requested to merge 448823-protected-branches-cr into master
Files
9
@@ -9,6 +9,7 @@ import {
GlSprintf,
} from '@gitlab/ui';
import { debounce, intersectionWith, groupBy, differenceBy, intersectionBy } from 'lodash';
import glAbilitiesMixin from '~/vue_shared/mixins/gl_abilities_mixin';
import { createAlert } from '~/alert';
import { __, s__, n__ } from '~/locale';
import { getUsers, getGroups, getDeployKeys } from '../api/access_dropdown_api';
@@ -35,6 +36,7 @@ export default {
GlAvatar,
GlSprintf,
},
mixins: [glAbilitiesMixin()],
props: {
accessLevelsData: {
type: Array,
@@ -187,6 +189,9 @@ export default {
...this.getDataForSave(LEVEL_TYPES.DEPLOY_KEY, 'deploy_key_id'),
];
},
canAdminContainer() {
return this.glAbilities.adminProject || this.glAbilities.adminGroup;
},
},
watch: {
query: debounce(function debouncedSearch() {
@@ -226,19 +231,18 @@ export default {
focusInput() {
this.$refs.search?.focusInput();
},
getGroups() {
return this.groups.length
? Promise.resolve({ data: this.groups })
: getGroups({ withProjectAccess: this.groupsWithProjectAccess });
},
getData({ initial = false } = {}) {
this.initialLoading = initial;
this.loading = true;
if (this.hasLicense) {
if (gon.abilities.adminProject || gon.abilities.adminGroup) {
Promise.all([
getDeployKeys(this.query),
getUsers(this.query),
this.groups.length
? Promise.resolve({ data: this.groups })
: getGroups({ withProjectAccess: this.groupsWithProjectAccess }),
])
if (this.canAdminContainer) {
Promise.all([getDeployKeys(this.query), getUsers(this.query), this.getGroups()])
.then(([deployKeysResponse, usersResponse, groupsResponse]) => {
this.consolidateData(
deployKeysResponse.data,
@@ -254,13 +258,8 @@ export default {
this.initialLoading = false;
this.loading = false;
});
} else if (gon.abilities.adminProtectedBranch) {
Promise.all([
getUsers(this.query),
this.groups.length
? Promise.resolve({ data: this.groups })
: getGroups({ withProjectAccess: this.groupsWithProjectAccess }),
])
} else if (this.glAbilities.adminProtectedBranch) {
Promise.all([getUsers(this.query), this.getGroups()])
.then(([usersResponse, groupsResponse]) => {
this.consolidateData(null, usersResponse.data, groupsResponse.data);
this.setSelected({ initial });
@@ -306,7 +305,7 @@ export default {
}
}
if (gon.abilities.adminProject || gon.abilities.adminGroup) {
if (this.canAdminContainer) {
this.deployKeys = deployKeysResponse.map((response) => {
const {
id,
Loading