diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-01 18:09:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-01 18:09:29 +0000 |
commit | 3011f8b297a5b71cd505a672b59cc8d3e0aa9f65 (patch) | |
tree | 99bf3a2d875f92f7d77a8302911b1ff3ce2a19be /app | |
parent | 06f736847bb6a7f577a8f121f94e4cc7ddb51856 (diff) | |
download | gitlab-ce-3011f8b297a5b71cd505a672b59cc8d3e0aa9f65.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
24 files changed, 64 insertions, 60 deletions
diff --git a/app/assets/javascripts/artifacts_settings/graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql b/app/assets/javascripts/artifacts_settings/graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql index d50fd665c16..b1664a4ed42 100644 --- a/app/assets/javascripts/artifacts_settings/graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql +++ b/app/assets/javascripts/artifacts_settings/graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql @@ -1,5 +1,7 @@ mutation updateKeepLatestArtifactProjectSetting($fullPath: ID!, $keepLatestArtifact: Boolean!) { - ciCdSettingsUpdate(input: { fullPath: $fullPath, keepLatestArtifact: $keepLatestArtifact }) { + projectCiCdSettingsUpdate( + input: { fullPath: $fullPath, keepLatestArtifact: $keepLatestArtifact } + ) { errors } } diff --git a/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue b/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue index d797469dd53..8e7ccb80784 100644 --- a/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue +++ b/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue @@ -75,7 +75,7 @@ export default { }, }); - if (data.ciCdSettingsUpdate.errors.length) { + if (data.projectCiCdSettingsUpdate.errors.length) { this.reportError(this.$options.errors.updateError); } } catch (error) { diff --git a/app/assets/javascripts/clusters/agents/components/create_token_modal.vue b/app/assets/javascripts/clusters/agents/components/create_token_modal.vue index 451e1ee1d67..d2e5e484502 100644 --- a/app/assets/javascripts/clusters/agents/components/create_token_modal.vue +++ b/app/assets/javascripts/clusters/agents/components/create_token_modal.vue @@ -9,7 +9,6 @@ import { EVENT_ACTIONS_OPEN, EVENT_ACTIONS_CLICK, TOKEN_NAME_LIMIT, - TOKEN_STATUS_ACTIVE, } from '../constants'; import createNewAgentToken from '../graphql/mutations/create_new_agent_token.mutation.graphql'; import getClusterAgentQuery from '../graphql/queries/get_cluster_agent.query.graphql'; @@ -66,7 +65,6 @@ export default { variables: { agentName: this.agentName, projectPath: this.projectPath, - tokenStatus: TOKEN_STATUS_ACTIVE, ...this.cursor, }, }; diff --git a/app/assets/javascripts/clusters/agents/components/revoke_token_button.vue b/app/assets/javascripts/clusters/agents/components/revoke_token_button.vue index 697162b50ae..c2c7beffae7 100644 --- a/app/assets/javascripts/clusters/agents/components/revoke_token_button.vue +++ b/app/assets/javascripts/clusters/agents/components/revoke_token_button.vue @@ -9,7 +9,7 @@ import { GlSprintf, } from '@gitlab/ui'; import { s__, __, sprintf } from '~/locale'; -import { REVOKE_TOKEN_MODAL_ID, TOKEN_STATUS_ACTIVE } from '../constants'; +import { REVOKE_TOKEN_MODAL_ID } from '../constants'; import revokeAgentToken from '../graphql/mutations/revoke_token.mutation.graphql'; import getClusterAgentQuery from '../graphql/queries/get_cluster_agent.query.graphql'; import { removeTokenFromStore } from '../graphql/cache_update'; @@ -61,7 +61,6 @@ export default { variables: { agentName: this.agentName, projectPath: this.projectPath, - tokenStatus: TOKEN_STATUS_ACTIVE, ...this.cursor, }, }; diff --git a/app/assets/javascripts/clusters/agents/components/show.vue b/app/assets/javascripts/clusters/agents/components/show.vue index f1bd36b4a63..d740d1c8865 100644 --- a/app/assets/javascripts/clusters/agents/components/show.vue +++ b/app/assets/javascripts/clusters/agents/components/show.vue @@ -10,7 +10,7 @@ import { } from '@gitlab/ui'; import { s__, __ } from '~/locale'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; -import { MAX_LIST_COUNT, TOKEN_STATUS_ACTIVE } from '../constants'; +import { MAX_LIST_COUNT } from '../constants'; import getClusterAgentQuery from '../graphql/queries/get_cluster_agent.query.graphql'; import TokenTable from './token_table.vue'; import ActivityEvents from './activity_events_list.vue'; @@ -31,7 +31,6 @@ export default { return { agentName: this.agentName, projectPath: this.projectPath, - tokenStatus: TOKEN_STATUS_ACTIVE, ...this.cursor, }; }, diff --git a/app/assets/javascripts/clusters/agents/constants.js b/app/assets/javascripts/clusters/agents/constants.js index e97d6500260..8eff9a152b2 100644 --- a/app/assets/javascripts/clusters/agents/constants.js +++ b/app/assets/javascripts/clusters/agents/constants.js @@ -37,7 +37,6 @@ export const EVENT_DETAILS = { }; export const DEFAULT_ICON = 'token'; -export const TOKEN_STATUS_ACTIVE = 'ACTIVE'; export const CREATE_TOKEN_MODAL = 'create-token'; export const EVENT_LABEL_MODAL = 'agent_token_creation_modal'; diff --git a/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql b/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql index d7a8e447071..7be524f92c4 100644 --- a/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql +++ b/app/assets/javascripts/clusters/agents/graphql/queries/get_cluster_agent.query.graphql @@ -4,7 +4,6 @@ query getClusterAgent( $projectPath: ID! $agentName: String! - $tokenStatus: AgentTokenStatus! $first: Int $last: Int $afterToken: String @@ -21,13 +20,7 @@ query getClusterAgent( name } - tokens( - status: $tokenStatus - first: $first - last: $last - before: $beforeToken - after: $afterToken - ) { + tokens(first: $first, last: $last, before: $beforeToken, after: $afterToken) { count nodes { diff --git a/app/assets/javascripts/environments/components/kubernetes_agent_info.vue b/app/assets/javascripts/environments/components/kubernetes_agent_info.vue index c4f6d225444..7660912f93a 100644 --- a/app/assets/javascripts/environments/components/kubernetes_agent_info.vue +++ b/app/assets/javascripts/environments/components/kubernetes_agent_info.vue @@ -2,7 +2,6 @@ import { GlIcon, GlLink, GlSprintf, GlLoadingIcon, GlAlert } from '@gitlab/ui'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import { getAgentLastContact, getAgentStatus } from '~/clusters_list/clusters_util'; -import { TOKEN_STATUS_ACTIVE } from '~/clusters/agents/constants'; import { AGENT_STATUSES } from '~/clusters_list/constants'; import { s__ } from '~/locale'; import getK8sClusterAgentQuery from '../graphql/queries/k8s_cluster_agent.query.graphql'; @@ -37,7 +36,6 @@ export default { return { agentName: this.agentName, projectPath: this.agentProjectPath, - tokenStatus: TOKEN_STATUS_ACTIVE, }; }, update: (data) => data?.project?.clusterAgent, diff --git a/app/assets/javascripts/environments/graphql/queries/k8s_cluster_agent.query.graphql b/app/assets/javascripts/environments/graphql/queries/k8s_cluster_agent.query.graphql index 999ae74239f..bd45d2dba2f 100644 --- a/app/assets/javascripts/environments/graphql/queries/k8s_cluster_agent.query.graphql +++ b/app/assets/javascripts/environments/graphql/queries/k8s_cluster_agent.query.graphql @@ -1,14 +1,10 @@ -query getK8sClusterAgentQuery( - $projectPath: ID! - $agentName: String! - $tokenStatus: AgentTokenStatus! -) { +query getK8sClusterAgentQuery($projectPath: ID!, $agentName: String!) { project(fullPath: $projectPath) { id clusterAgent(name: $agentName) { id webPath - tokens(status: $tokenStatus) { + tokens { nodes { id lastUsedAt diff --git a/app/assets/javascripts/super_sidebar/components/context_switcher.vue b/app/assets/javascripts/super_sidebar/components/context_switcher.vue index a93d0acbff8..ad2111140a1 100644 --- a/app/assets/javascripts/super_sidebar/components/context_switcher.vue +++ b/app/assets/javascripts/super_sidebar/components/context_switcher.vue @@ -14,7 +14,7 @@ import ContextSwitcherToggle from './context_switcher_toggle.vue'; export default { i18n: { contextNavigation: s__('Navigation|Context navigation'), - switchTo: s__('Navigation|Switch to...'), + switchTo: s__('Navigation|Switch context'), searchPlaceholder: s__('Navigation|Search your projects or groups'), searchingLabel: s__('Navigation|Retrieving search results'), searchError: s__('Navigation|There was an error fetching search results.'), @@ -160,7 +160,10 @@ export default { <template #toggle> <context-switcher-toggle :context="contextHeader" :expanded="isOpen" /> </template> - <div class="gl-p-1 gl-border-b gl-border-gray-50 gl-bg-white"> + <div aria-hidden="true" class="gl-font-sm gl-font-weight-bold gl-px-4 gl-pt-3 gl-pb-4"> + {{ $options.i18n.switchTo }} + </div> + <div class="gl-p-1 gl-border-t gl-border-b gl-border-gray-50 gl-bg-white"> <gl-search-box-by-type ref="search-box" v-model="searchString" @@ -182,10 +185,10 @@ export default { <nav v-else :aria-label="$options.i18n.contextNavigation" data-qa-selector="context_navigation"> <ul class="gl-p-0 gl-m-0 gl-list-style-none"> <li v-if="!isSearch"> - <div aria-hidden="true" class="gl-font-weight-bold gl-px-3 gl-py-3"> - {{ $options.i18n.switchTo }} - </div> - <ul :aria-label="$options.i18n.switchTo" class="gl-p-0"> + <ul + :aria-label="$options.i18n.switchTo" + class="gl-border-b gl-border-gray-50 gl-px-0 gl-py-2" + > <nav-item v-for="item in persistentLinks" :key="item.link" @@ -201,6 +204,7 @@ export default { :search-results="projects" /> <groups-list + class="gl-border-t gl-border-gray-50" :username="username" :view-all-link="groupsPath" :is-search="isSearch" diff --git a/app/assets/javascripts/super_sidebar/components/frequent_items_list.vue b/app/assets/javascripts/super_sidebar/components/frequent_items_list.vue index 50f3069899a..11bf2ddbd30 100644 --- a/app/assets/javascripts/super_sidebar/components/frequent_items_list.vue +++ b/app/assets/javascripts/super_sidebar/components/frequent_items_list.vue @@ -72,15 +72,19 @@ export default { </script> <template> - <li class="gl-border-t gl-border-gray-50 gl-mx-3 gl-py-3"> + <li class="gl-py-3"> <div data-testid="list-title" aria-hidden="true" - class="gl-display-flex gl-align-items-center gl-text-transform-uppercase gl-text-secondary gl-font-weight-bold gl-font-xs gl-line-height-12 gl-letter-spacing-06em gl-my-3" + class="gl-display-flex gl-align-items-center gl-text-transform-uppercase gl-text-secondary gl-font-weight-semibold gl-font-xs gl-line-height-12 gl-letter-spacing-06em gl-my-3" > - <span class="gl-flex-grow-1">{{ title }}</span> + <span class="gl-flex-grow-1 gl-px-3">{{ title }}</span> </div> - <div v-if="isEmpty" data-testid="empty-text" class="gl-text-gray-500 gl-font-sm gl-my-3"> + <div + v-if="isEmpty" + data-testid="empty-text" + class="gl-text-gray-500 gl-font-sm gl-my-3 gl-mx-3" + > {{ pristineText }} </div> <items-list :aria-label="title" :items="cachedFrequentItems" @remove-item="handleItemRemove"> diff --git a/app/assets/javascripts/super_sidebar/components/search_results.vue b/app/assets/javascripts/super_sidebar/components/search_results.vue index b1af3070801..ff933f341af 100644 --- a/app/assets/javascripts/super_sidebar/components/search_results.vue +++ b/app/assets/javascripts/super_sidebar/components/search_results.vue @@ -52,7 +52,7 @@ export default { 'gl-text-left', 'gl-text-transform-uppercase', 'gl-text-secondary', - 'gl-font-weight-bold', + 'gl-font-weight-semibold', 'gl-font-xs', 'gl-line-height-12', 'gl-letter-spacing-06em', @@ -62,7 +62,6 @@ export default { // Spacing 'gl-my-3', 'gl-pt-2', - 'gl-w-full', // Layout 'gl-display-flex', 'gl-justify-content-space-between', @@ -72,17 +71,22 @@ export default { </script> <template> - <li class="gl-border-t gl-border-gray-50 gl-mx-3"> + <li class="gl-border-t gl-border-gray-50"> <button v-collapse-toggle="collapseId" :class="$options.buttonClasses" + class="gl-mx-3" data-testid="search-results-toggle" > {{ title }} <gl-icon :name="collapseIcon" :size="16" /> </button> <gl-collapse :id="collapseId" v-model="expanded"> - <div v-if="isEmpty" data-testid="empty-text" class="gl-text-gray-500 gl-font-sm gl-mb-3"> + <div + v-if="isEmpty" + data-testid="empty-text" + class="gl-text-gray-500 gl-font-sm gl-mb-3 gl-mx-4" + > {{ noResultsText }} </div> <items-list :aria-label="title" :items="searchResults"> diff --git a/app/assets/javascripts/super_sidebar/components/super_sidebar_toggle.vue b/app/assets/javascripts/super_sidebar/components/super_sidebar_toggle.vue index 3064b91ca7d..4fff5cf832e 100644 --- a/app/assets/javascripts/super_sidebar/components/super_sidebar_toggle.vue +++ b/app/assets/javascripts/super_sidebar/components/super_sidebar_toggle.vue @@ -24,8 +24,8 @@ export default { }, }, i18n: { - collapseSidebar: __('Collapse sidebar'), - expandSidebar: __('Expand sidebar'), + collapseSidebar: __('Hide sidebar'), + expandSidebar: __('Show sidebar'), navigationSidebar: __('Navigation sidebar'), }, data() { 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 1904846fcbc..eb1222d5130 100644 --- a/app/assets/javascripts/token_access/components/inbound_token_access.vue +++ b/app/assets/javascripts/token_access/components/inbound_token_access.vue @@ -124,7 +124,7 @@ export default { try { const { data: { - ciCdSettingsUpdate: { errors }, + projectCiCdSettingsUpdate: { errors }, }, } = await this.$apollo.mutate({ mutation: inboundUpdateCIJobTokenScopeMutation, diff --git a/app/assets/javascripts/token_access/components/opt_in_jwt.vue b/app/assets/javascripts/token_access/components/opt_in_jwt.vue index 9485e0c3667..18636a26f46 100644 --- a/app/assets/javascripts/token_access/components/opt_in_jwt.vue +++ b/app/assets/javascripts/token_access/components/opt_in_jwt.vue @@ -63,7 +63,7 @@ export default { try { const { data: { - ciCdSettingsUpdate: { errors }, + projectCiCdSettingsUpdate: { errors }, }, } = await this.$apollo.mutate({ mutation: updateOptInJwtMutation, 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 d9c23c6c7f3..7a1b1ed6586 100644 --- a/app/assets/javascripts/token_access/components/outbound_token_access.vue +++ b/app/assets/javascripts/token_access/components/outbound_token_access.vue @@ -122,7 +122,7 @@ export default { try { const { data: { - ciCdSettingsUpdate: { errors }, + projectCiCdSettingsUpdate: { errors }, }, } = await this.$apollo.mutate({ mutation: updateCIJobTokenScopeMutation, diff --git a/app/assets/javascripts/token_access/graphql/mutations/inbound_update_ci_job_token_scope.mutation.graphql b/app/assets/javascripts/token_access/graphql/mutations/inbound_update_ci_job_token_scope.mutation.graphql index aac9feab237..6c85839df07 100644 --- a/app/assets/javascripts/token_access/graphql/mutations/inbound_update_ci_job_token_scope.mutation.graphql +++ b/app/assets/javascripts/token_access/graphql/mutations/inbound_update_ci_job_token_scope.mutation.graphql @@ -1,5 +1,5 @@ -mutation inboundUpdateCIJobTokenScope($input: CiCdSettingsUpdateInput!) { - ciCdSettingsUpdate(input: $input) { +mutation inboundUpdateCIJobTokenScope($input: ProjectCiCdSettingsUpdateInput!) { + projectCiCdSettingsUpdate(input: $input) { ciCdSettings { inboundJobTokenScopeEnabled } diff --git a/app/assets/javascripts/token_access/graphql/mutations/update_ci_job_token_scope.mutation.graphql b/app/assets/javascripts/token_access/graphql/mutations/update_ci_job_token_scope.mutation.graphql index d99f2e3597d..30a6bb6106a 100644 --- a/app/assets/javascripts/token_access/graphql/mutations/update_ci_job_token_scope.mutation.graphql +++ b/app/assets/javascripts/token_access/graphql/mutations/update_ci_job_token_scope.mutation.graphql @@ -1,5 +1,5 @@ -mutation updateCIJobTokenScope($input: CiCdSettingsUpdateInput!) { - ciCdSettingsUpdate(input: $input) { +mutation updateCIJobTokenScope($input: ProjectCiCdSettingsUpdateInput!) { + projectCiCdSettingsUpdate(input: $input) { ciCdSettings { jobTokenScopeEnabled } diff --git a/app/assets/javascripts/token_access/graphql/mutations/update_opt_in_jwt.mutation.graphql b/app/assets/javascripts/token_access/graphql/mutations/update_opt_in_jwt.mutation.graphql index c12b5646423..7f0a6bc7d6d 100644 --- a/app/assets/javascripts/token_access/graphql/mutations/update_opt_in_jwt.mutation.graphql +++ b/app/assets/javascripts/token_access/graphql/mutations/update_opt_in_jwt.mutation.graphql @@ -1,5 +1,5 @@ -mutation updateOptInJwt($input: CiCdSettingsUpdateInput!) { - ciCdSettingsUpdate(input: $input) { +mutation updateOptInJwt($input: ProjectCiCdSettingsUpdateInput!) { + projectCiCdSettingsUpdate(input: $input) { ciCdSettings { optInJwt } diff --git a/app/finders/clusters/agent_tokens_finder.rb b/app/finders/clusters/agent_tokens_finder.rb index 0e777564db5..9ec00245250 100644 --- a/app/finders/clusters/agent_tokens_finder.rb +++ b/app/finders/clusters/agent_tokens_finder.rb @@ -13,15 +13,25 @@ module Clusters def execute return ::Clusters::AgentToken.none unless can_read_cluster_agent? - agent.agent_tokens.then { |agent_tokens| by_status(agent_tokens) } + agent_tokens_by_status end private attr_reader :agent, :current_user, :params - def by_status(agent_tokens) - params[:status].present? ? agent_tokens.with_status(params[:status]) : agent_tokens + def agent_tokens_by_status + # If the `status` parameter is set to `active`, we use the `active_agent_tokens` scope + # in case this called from GraphQL's AgentTokensResolver. This prevents a repeat query + # to the database, because `active_agent_tokens` is already preloaded in the AgentsResolver + return agent.active_agent_tokens if active_tokens_only? + + # Else, we use the `agent_tokens` scope combined with `with_status` if necessary + params[:status].present? ? agent.agent_tokens.with_status(params[:status]) : agent.agent_tokens + end + + def active_tokens_only? + params[:status].present? && params[:status].to_sym == :active end def can_read_cluster_agent? diff --git a/app/graphql/resolvers/clusters/agent_tokens_resolver.rb b/app/graphql/resolvers/clusters/agent_tokens_resolver.rb index b7355a1752e..0b9422db2a9 100644 --- a/app/graphql/resolvers/clusters/agent_tokens_resolver.rb +++ b/app/graphql/resolvers/clusters/agent_tokens_resolver.rb @@ -9,12 +9,8 @@ module Resolvers delegate :project, to: :agent - argument :status, Types::Clusters::AgentTokenStatusEnum, - required: false, - description: 'Status of the token.' - - def resolve(**args) - ::Clusters::AgentTokensFinder.new(agent, current_user, args).execute + def resolve(**_args) + ::Clusters::AgentTokensFinder.new(agent, current_user, status: :active).execute end end end diff --git a/app/graphql/resolvers/clusters/agents_resolver.rb b/app/graphql/resolvers/clusters/agents_resolver.rb index 0b9eb361dbd..f138ad2b510 100644 --- a/app/graphql/resolvers/clusters/agents_resolver.rb +++ b/app/graphql/resolvers/clusters/agents_resolver.rb @@ -28,7 +28,7 @@ module Resolvers def preloads { activity_events: { activity_events: [:user, agent_token: :agent] }, - tokens: :agent_tokens + tokens: :active_agent_tokens } end end diff --git a/app/models/clusters/agent.rb b/app/models/clusters/agent.rb index a758548ad7d..b5d634927e5 100644 --- a/app/models/clusters/agent.rb +++ b/app/models/clusters/agent.rb @@ -13,6 +13,7 @@ module Clusters belongs_to :project, class_name: '::Project' # Otherwise, it will load ::Clusters::Project has_many :agent_tokens, -> { order_last_used_at_desc }, class_name: 'Clusters::AgentToken', inverse_of: :agent + has_many :active_agent_tokens, -> { active.order_last_used_at_desc }, class_name: 'Clusters::AgentToken', inverse_of: :agent has_many :ci_access_group_authorizations, class_name: 'Clusters::Agents::Authorizations::CiAccess::GroupAuthorization' has_many :ci_access_authorized_groups, class_name: '::Group', through: :ci_access_group_authorizations, source: :group diff --git a/app/models/clusters/agent_token.rb b/app/models/clusters/agent_token.rb index e2dcff13a69..b2b13f6cef7 100644 --- a/app/models/clusters/agent_token.rb +++ b/app/models/clusters/agent_token.rb @@ -20,6 +20,7 @@ module Clusters scope :order_last_used_at_desc, -> { order(arel_table[:last_used_at].desc.nulls_last) } scope :with_status, -> (status) { where(status: status) } + scope :active, -> { where(status: :active) } enum status: { active: 0, |