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" > diff --git a/app/assets/javascripts/token_access/components/outbound_token_access.vue b/app/assets/javascripts/token_access/components/outbound_token_access.vue index aad46e730d83890b53214c8b82f8f43208c53f75..c3d08b884fee164648620763b8b1c012520f7881 100644 --- a/app/assets/javascripts/token_access/components/outbound_token_access.vue +++ b/app/assets/javascripts/token_access/components/outbound_token_access.vue @@ -8,9 +8,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 glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import addProjectCIJobTokenScopeMutation from '../graphql/mutations/add_project_ci_job_token_scope.mutation.graphql'; @@ -46,17 +47,6 @@ export default { deprecationDocumentationLink: helpPagePath('ci/jobs/ci_job_token', { anchor: 'limit-your-projects-job-token-access', }), - fields: [ - { - key: 'fullPath', - label: __('Project that can be accessed'), - }, - { - key: 'actions', - label: '', - tdClass: 'gl-text-right', - }, - ], components: { GlAlert, GlButton, @@ -68,6 +58,9 @@ export default { GlToggle, TokenAccessTable, }, + directives: { + GlTooltip: GlTooltipDirective, + }, mixins: [glFeatureFlagMixin()], inject: { fullPath: { @@ -121,6 +114,14 @@ export default { disableTokenToggle() { return !this.jobTokenScopeEnabled; }, + projectCountTooltip() { + return sprintf( + n__('%{count} project has access', '%{count} projects have access', this.projects.length), + { + count: this.projects.length, + }, + ); + }, }, methods: { async updateCIJobTokenScope() { @@ -265,13 +266,13 @@ export default {
- +
diff --git a/app/assets/javascripts/token_access/components/token_access_table.vue b/app/assets/javascripts/token_access/components/token_access_table.vue index 700c6b9ef3958131e70b36bd74b17fea167d04c5..9f619d32debf6404b8f35fbe3e032627bd7a41a7 100644 --- a/app/assets/javascripts/token_access/components/token_access_table.vue +++ b/app/assets/javascripts/token_access/components/token_access_table.vue @@ -1,11 +1,27 @@