debian-mirror-gitlab/app/assets/javascripts/projects/settings/utils.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import { joinPaths } from '~/lib/utils/url_utility';
export const generateRefDestinationPath = (selectedRef) => {
const namespace = '-/settings/ci_cd';
const { pathname } = window.location;
if (!selectedRef || !pathname.includes(namespace)) {
return window.location.href;
}
const [projectRootPath] = pathname.split(namespace);
const destinationPath = joinPaths(projectRootPath, namespace);
const newURL = new URL(window.location);
newURL.pathname = destinationPath;
newURL.searchParams.set('ref', selectedRef);
return newURL.href;
};
2023-03-04 22:38:38 +05:30
export const getAccessLevels = (accessLevels = {}) => {
const total = accessLevels.edges?.length;
const accessLevelTypes = { total, users: [], groups: [], roles: [] };
accessLevels.edges?.forEach(({ node }) => {
if (node.user) {
const src = node.user.avatarUrl;
accessLevelTypes.users.push({ src, ...node.user });
} else if (node.group) {
accessLevelTypes.groups.push(node);
} else {
2023-04-23 21:23:45 +05:30
accessLevelTypes.roles.push({ accessLevelDescription: node.accessLevelDescription });
2023-03-04 22:38:38 +05:30
}
});
return accessLevelTypes;
};