diff --git a/app/assets/javascripts/token_access/components/inbound_token_access.vue b/app/assets/javascripts/token_access/components/inbound_token_access.vue
index a6c2b08735f1860b2cf94ef51385d563da8c51be..29dbc49f835aed0b6000f51ffa5d961e28fa9df6 100644
--- a/app/assets/javascripts/token_access/components/inbound_token_access.vue
+++ b/app/assets/javascripts/token_access/components/inbound_token_access.vue
@@ -9,9 +9,10 @@ import {
GlLoadingIcon,
GlSprintf,
GlToggle,
+ GlTooltipDirective,
} from '@gitlab/ui';
import { createAlert } from '~/alert';
-import { __, s__ } from '~/locale';
+import { __, s__, n__, sprintf } from '~/locale';
import { helpPagePath } from '~/helpers/help_page_helper';
import { TYPENAME_GROUP } from '~/graphql_shared/constants';
import inboundAddGroupOrProjectCIJobTokenScope from '../graphql/mutations/inbound_add_group_or_project_ci_job_token_scope.mutation.graphql';
@@ -41,17 +42,6 @@ export default {
projectsFetchError: __('There was a problem fetching the projects'),
scopeFetchError: __('There was a problem fetching the job token scope value'),
},
- fields: [
- {
- key: 'fullPath',
- label: '',
- },
- {
- key: 'actions',
- label: '',
- tdClass: 'gl-text-right',
- },
- ],
components: {
GlAlert,
GlButton,
@@ -64,6 +54,9 @@ export default {
GlToggle,
TokenAccessTable,
},
+ directives: {
+ GlTooltip: GlTooltipDirective,
+ },
inject: {
fullPath: {
default: '',
@@ -92,8 +85,13 @@ export default {
};
},
update({ project }) {
- this.projects = project?.ciJobTokenScope?.inboundAllowlist?.nodes ?? [];
- this.groups = project?.ciJobTokenScope?.groupsAllowlist?.nodes ?? [];
+ const projects = project?.ciJobTokenScope?.inboundAllowlist?.nodes ?? [];
+ const groups = project?.ciJobTokenScope?.groupsAllowlist?.nodes ?? [];
+
+ this.projectCount = projects.length;
+ this.groupCount = groups.length;
+
+ return [...groups, ...projects];
},
error() {
createAlert({ message: this.$options.i18n.projectsFetchError });
@@ -103,19 +101,36 @@ export default {
data() {
return {
inboundJobTokenScopeEnabled: null,
- targetPath: '',
- projects: [],
- groups: [],
+ groupsAndProjectsWithAccess: [],
+ groupOrProjectPath: '',
+ projectCount: 0,
+ groupCount: 0,
isAddFormVisible: false,
};
},
computed: {
- isTargetPathEmpty() {
- return this.targetPath === '';
+ isGroupOrProjectPathEmpty() {
+ return this.groupOrProjectPath === '';
},
ciJobTokenHelpPage() {
return helpPagePath('ci/jobs/ci_job_token#control-job-token-access-to-your-project');
},
+ groupCountTooltip() {
+ return sprintf(
+ n__('%{count} group has access', '%{count} groups have access', this.groupCount),
+ {
+ count: this.groupCount,
+ },
+ );
+ },
+ projectCountTooltip() {
+ return sprintf(
+ n__('%{count} project has access', '%{count} projects have access', this.projectCount),
+ {
+ count: this.projectCount,
+ },
+ );
+ },
},
methods: {
async updateCIJobTokenScope() {
@@ -152,7 +167,7 @@ export default {
mutation: inboundAddGroupOrProjectCIJobTokenScope,
variables: {
projectPath: this.fullPath,
- targetPath: this.targetPath,
+ targetPath: this.groupOrProjectPath,
},
});
@@ -162,7 +177,7 @@ export default {
} catch (error) {
createAlert({ message: error.message });
} finally {
- this.clearTargetPath();
+ this.clearGroupOrProjectPath();
this.getGroupsAndProjects();
}
},
@@ -204,8 +219,8 @@ export default {
this.getGroupsAndProjects();
}
},
- clearTargetPath() {
- this.targetPath = '';
+ clearGroupOrProjectPath() {
+ this.groupOrProjectPath = '';
this.isAddFormVisible = false;
},
getGroupsAndProjects() {
@@ -262,16 +277,28 @@ export default {
body-class="gl-new-card-body gl-px-0"
>
- {{ $options.i18n.cardHeaderTitle }}
-
- {{ $options.i18n.cardHeaderTitle }}
+
+ {{ $options.i18n.addGroupOrProject }}