From c89804112a1d40a14ffe0c674cf38b36f24d3c2c Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Fri, 23 May 2025 16:04:11 +0900 Subject: [PATCH 1/9] Implement org cluster agent query --- ...zation_workspaces_cluster_agents_query.vue | 94 +++++++++ .../workspaces/admin_settings/constants.js | 12 +- .../organization_mapped_agents.query.graphql | 10 + ...on_workspaces_cluster_agents.query.graphql | 44 +++++ .../admin_settings/init_admin_settings_app.js | 11 ++ .../workspaces/admin_settings/pages/app.vue | 178 +++++++++++------- locale/gitlab.pot | 3 + 7 files changed, 271 insertions(+), 81 deletions(-) create mode 100644 ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue create mode 100644 ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_mapped_agents.query.graphql create mode 100644 ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_workspaces_cluster_agents.query.graphql diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue b/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue new file mode 100644 index 00000000000000..66585c94f39ef6 --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue @@ -0,0 +1,94 @@ + diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/constants.js b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js index f9e3abc56e9c5e..1d30a9c9940ec3 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/constants.js +++ b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js @@ -1,21 +1,11 @@ import { s__ } from '~/locale'; -const AVAILABILITY_OPTIONS = { +export const AVAILABILITY_OPTIONS = { AVAILABLE: 'available', BLOCKED: 'blocked', }; -export const CONNECTION_STATUS = { - CONNECTED: 'connected', - NOT_CONNECTED: 'not_connected', -}; - export const AVAILABILITY_TEXT = { [AVAILABILITY_OPTIONS.AVAILABLE]: s__('Workspaces|Available'), [AVAILABILITY_OPTIONS.BLOCKED]: s__('Workspaces|Blocked'), }; - -export const CONNECTION_STATUS_TEXT = { - [CONNECTION_STATUS.CONNECTED]: s__('Workspaces|Connected'), - [CONNECTION_STATUS.NOT_CONNECTED]: s__('Workspaces|Not connected'), -}; diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_mapped_agents.query.graphql b/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_mapped_agents.query.graphql new file mode 100644 index 00000000000000..38b29ba1853468 --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_mapped_agents.query.graphql @@ -0,0 +1,10 @@ +query mappedOrganizationClusterAgentsQuery($organizationId: OrganizationsOrganizationID!) { + organization(id: $organizationId) { + id + mappedAgents: workspacesClusterAgents(filter: DIRECTLY_MAPPED) { + nodes { + id + } + } + } +} diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_workspaces_cluster_agents.query.graphql b/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_workspaces_cluster_agents.query.graphql new file mode 100644 index 00000000000000..651376e218e47b --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/admin_settings/graphql/queries/organization_workspaces_cluster_agents.query.graphql @@ -0,0 +1,44 @@ +query organizationWorkspacesClusterAgentsQuery( + $organizationId: OrganizationsOrganizationID! + $before: String + $after: String +) { + organization(id: $organizationId) { + id + clusterAgents: workspacesClusterAgents( + filter: UNMAPPED + first: 5 + before: $before + after: $after + ) { + nodes { + id + name + webPath + project { + id + name + group { + id + name + } + } + workspacesAgentConfig { + id + enabled + } + connections { + nodes { + connectedAt + } + } + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + } + } +} diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js b/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js index b340f8711455d3..af90a561b626dc 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js +++ b/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js @@ -1,10 +1,20 @@ import Vue from 'vue'; +import VueApollo from 'vue-apollo'; import { convertToGraphQLId } from '~/graphql_shared/utils'; import { TYPE_ORGANIZATION } from '~/graphql_shared/constants'; import { parseBoolean } from '~/lib/utils/common_utils'; +import createDefaultClient from '~/lib/graphql'; import WorkspacesAgentAvailabilityApp from './pages/app.vue'; +Vue.use(VueApollo); + +const createApolloProvider = () => { + const defaultClient = createDefaultClient(); + + return new VueApollo({ defaultClient }); +}; + const initWorkspacesAgentAvailabilityApp = () => { const el = document.getElementById('js-workspaces-agent-availability-settings'); @@ -14,6 +24,7 @@ const initWorkspacesAgentAvailabilityApp = () => { return new Vue({ el, + apolloProvider: createApolloProvider(), components: { WorkspacesAgentAvailabilityApp, }, diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue index 0e083f8d9ce32c..fe8967d93a2708 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue @@ -1,19 +1,27 @@ diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7f862f91ff8e85..7a5b25569c515a 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -70676,6 +70676,9 @@ msgstr "" msgid "Workspaces|Workspaces Settings" msgstr "" +msgid "Workspaces|Workspaces enabled in config" +msgstr "" + msgid "Workspaces|Workspaces have built-in support for devfiles. The default location is .devfile.yaml, but you can also use a custom location. The devfile is used to automatically configure the development environment with the defined specifications." msgstr "" -- GitLab From a0a74e9d545f1ee409502b5487760eaae6c4b725 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Fri, 23 May 2025 20:18:20 +0900 Subject: [PATCH 2/9] Add specs for query component --- ...zation_workspaces_cluster_agents_query.vue | 40 ++- .../organization_mapped_agents.query.graphql | 2 +- ...on_workspaces_cluster_agents.query.graphql | 4 +- ...on_workspaces_cluster_agents_query_spec.js | 248 ++++++++++++++++++ .../frontend/workspaces/mock_data/index.js | 247 +++++++++++++++++ 5 files changed, 525 insertions(+), 16 deletions(-) create mode 100644 ee/spec/frontend/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query_spec.js diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue b/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue index 66585c94f39ef6..c1e47cc3d911c6 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/components/get_organization_workspaces_cluster_agents_query.vue @@ -1,5 +1,6 @@