From 049cb6d4b2eacb1f8aeae6d136a0d9b86fb08866 Mon Sep 17 00:00:00 2001 From: Chad Woolley Date: Fri, 9 Feb 2024 14:52:21 -0800 Subject: [PATCH 01/13] Allow devfile path and ref selection - Also adds link to devfile in workspace list --- doc/api/graphql/reference/index.md | 1 + doc/user/workspace/configuration.md | 2 +- .../agent_admin_ui/agent_workspaces_list.vue | 6 +- .../common/get_project_details_query.vue | 11 +- .../components/common/workspaces_list.vue | 2 +- .../components/list/workspaces_table.vue | 17 +- .../workspace_create.mutation.graphql | 1 + .../agent_workspaces_list.query.graphql | 1 + .../queries/get_project_details.query.graphql | 8 +- ...hql => get_projects_details.query.graphql} | 2 +- .../user_workspaces_list.query.graphql | 1 + .../remote_development/pages/create.vue | 228 ++++++++++++++---- .../remote_development/pages/list.vue | 6 +- .../remote_development/services/utils.js | 8 +- .../vue_shared/components/web_ide_link.vue | 4 +- .../page_bundles/remote_development.scss | 2 +- .../remote_development/workspace_type.rb | 3 + ee/app/models/remote_development/workspace.rb | 4 + .../workspaces/create/devfile_fetcher.rb | 13 +- .../project_cloner_component_injector.rb | 8 +- .../remote_development/workspaces_spec.rb | 4 +- .../agent_workspaces_list_spec.js | 26 +- .../common/get_project_details_query_spec.js | 77 ------ .../components/list/workspaces_table_spec.js | 27 ++- .../remote_development/mock_data/index.js | 43 ++-- .../remote_development/pages/create_spec.js | 62 +++-- .../remote_development/pages/list_spec.js | 24 +- .../remote_development/router/index_spec.js | 8 +- .../remote_development/services/utils_spec.js | 8 +- .../components/web_ide_link_spec.js | 9 +- .../remote_development/workspace_type_spec.rb | 3 +- .../workspaces/create/devfile_fetcher_spec.rb | 20 +- .../create/main_integration_spec.rb | 19 +- .../project_cloner_component_injector_spec.rb | 3 +- .../remote_development/workspace_spec.rb | 9 + locale/gitlab.pot | 38 ++- 36 files changed, 430 insertions(+), 278 deletions(-) rename ee/app/assets/javascripts/remote_development/graphql/queries/{user_workspaces_projects_names.query.graphql => get_projects_details.query.graphql} (62%) diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 18783d30c58699..ec995f96032dab 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -30457,6 +30457,7 @@ Represents a remote development workspace. | `devfile` | [`String!`](#string) | Source YAML of the devfile used to configure the workspace. | | `devfilePath` | [`String!`](#string) | Project repo git path containing the devfile used to configure the workspace. | | `devfileRef` | [`String!`](#string) | Project repo git ref containing the devfile used to configure the workspace. | +| `devfileWebUrl` | [`String!`](#string) | Web URL of the devfile used to configure the workspace. | | `editor` | [`String!`](#string) | Editor used to configure the workspace. Must match a configured template. | | `id` | [`RemoteDevelopmentWorkspaceID!`](#remotedevelopmentworkspaceid) | Global ID of the workspace. | | `maxHoursBeforeTermination` | [`Int!`](#int) | Maximum hours the workspace can exist before it is automatically terminated. | diff --git a/doc/user/workspace/configuration.md b/doc/user/workspace/configuration.md index 8ac22a1177390c..88f0c4196bd166 100644 --- a/doc/user/workspace/configuration.md +++ b/doc/user/workspace/configuration.md @@ -54,7 +54,7 @@ To create a workspace: 1. Select **New workspace**. 1. From the **Select project** dropdown list, [select a project with a `.devfile.yaml` file](#prerequisites). 1. From the **Select cluster agent** dropdown list, select a cluster agent owned by the group the project belongs to. -1. In **Time before automatic termination**, enter the number of hours until the workspace automatically terminates. +1. In **Workspace automatically terminates after**, enter the number of hours until the workspace automatically terminates. This timeout is a safety measure to prevent a workspace from consuming excessive resources or running indefinitely. 1. Select **Create workspace**. diff --git a/ee/app/assets/javascripts/remote_development/components/agent_admin_ui/agent_workspaces_list.vue b/ee/app/assets/javascripts/remote_development/components/agent_admin_ui/agent_workspaces_list.vue index 4d272408b7bc36..5f616f9c25a023 100644 --- a/ee/app/assets/javascripts/remote_development/components/agent_admin_ui/agent_workspaces_list.vue +++ b/ee/app/assets/javascripts/remote_development/components/agent_admin_ui/agent_workspaces_list.vue @@ -7,7 +7,7 @@ import { WORKSPACES_LIST_POLL_INTERVAL, } from '../../constants'; import agentWorkspacesListQuery from '../../graphql/queries/agent_workspaces_list.query.graphql'; -import { fetchProjectNames, populateWorkspacesWithProjectNames } from '../../services/utils'; +import { fetchProjects, populateWorkspacesWithProjectDetails } from '../../services/utils'; import WorkspacesList from '../common/workspaces_list.vue'; export const i18n = { @@ -51,7 +51,7 @@ export default { return; } const workspaces = data?.project?.clusterAgent?.workspaces?.nodes; - const result = await fetchProjectNames(this.$apollo, workspaces); + const result = await fetchProjects(this.$apollo, workspaces); if (result.error) { this.error = i18n.loadingWorkspacesFailed; @@ -60,7 +60,7 @@ export default { return; } - this.workspaces = populateWorkspacesWithProjectNames(workspaces, result.projects); + this.workspaces = populateWorkspacesWithProjectDetails(workspaces, result.projects); this.pageInfo = data?.project?.clusterAgent?.workspaces?.pageInfo; }, }, diff --git a/ee/app/assets/javascripts/remote_development/components/common/get_project_details_query.vue b/ee/app/assets/javascripts/remote_development/components/common/get_project_details_query.vue index 86177d7f1c85ee..50510fe36d0561 100644 --- a/ee/app/assets/javascripts/remote_development/components/common/get_project_details_query.vue +++ b/ee/app/assets/javascripts/remote_development/components/common/get_project_details_query.vue @@ -3,7 +3,6 @@ import { uniqBy } from 'lodash'; import { logError } from '~/lib/logger'; import getProjectDetailsQuery from '../../graphql/queries/get_project_details.query.graphql'; import getGroupClusterAgentsQuery from '../../graphql/queries/get_group_cluster_agents.query.graphql'; -import { DEFAULT_DEVFILE_PATH } from '../../constants'; export default { props: { @@ -19,7 +18,6 @@ export default { variables() { return { projectFullPath: this.projectFullPath, - devFilePath: DEFAULT_DEVFILE_PATH, }; }, skip() { @@ -39,9 +37,6 @@ export default { const { nameWithNamespace, repository, group, id } = result.data.project; - const hasDevFile = repository - ? repository.blobs.nodes.some(({ path }) => path === DEFAULT_DEVFILE_PATH) - : false; const rootRef = repository ? repository.rootRef : null; if (!group) { @@ -51,7 +46,6 @@ export default { fullPath: this.projectFullPath, nameWithNamespace, clusterAgents: [], - hasDevFile, rootRef, }); return; @@ -81,7 +75,6 @@ export default { fullPath: this.projectFullPath, nameWithNamespace, clusterAgents: uniqClusterAgents, - hasDevFile, rootRef, }); }, @@ -97,6 +90,10 @@ export default { }); if (error) { + // NOTE: It seems to be impossible to have test coverage for this line + // with the current version of mock-apollo-client. Any type of + // mock error is always thrown and caught below instead of + // being returned. return { error }; } diff --git a/ee/app/assets/javascripts/remote_development/components/common/workspaces_list.vue b/ee/app/assets/javascripts/remote_development/components/common/workspaces_list.vue index 7ededb9ea5013f..9351cc47fd99ab 100644 --- a/ee/app/assets/javascripts/remote_development/components/common/workspaces_list.vue +++ b/ee/app/assets/javascripts/remote_development/components/common/workspaces_list.vue @@ -78,7 +78,7 @@ export default { > {{ $options.i18n.learnMoreHelpLink }} diff --git a/ee/app/assets/javascripts/remote_development/components/list/workspaces_table.vue b/ee/app/assets/javascripts/remote_development/components/list/workspaces_table.vue index 30adacfd7f6a1e..79aa626f01a4a3 100644 --- a/ee/app/assets/javascripts/remote_development/components/list/workspaces_table.vue +++ b/ee/app/assets/javascripts/remote_development/components/list/workspaces_table.vue @@ -27,6 +27,7 @@ const sortWorkspacesByTerminatedState = (workspaceA, workspaceB) => { export const i18n = { tableColumnHeaders: { name: __('Name'), + devfile: __('Devfile'), preview: __('Preview'), created: __('Created'), }, @@ -75,6 +76,11 @@ export default { label: i18n.tableColumnHeaders.created, thClass: 'gl-w-20p', }, + { + key: 'devfile', + label: i18n.tableColumnHeaders.devfile, + thClass: 'gl-w-30p', + }, { key: 'preview', label: i18n.tableColumnHeaders.preview, @@ -117,11 +123,20 @@ export default { :time="item.createdAt" /> +