From 8b7f309076499683d89042b2bd184631b9e60194 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Tue, 13 May 2025 15:37:58 +0900 Subject: [PATCH 1/7] Add workspaces agent availability to admin settings --- .../application_settings/general.html.haml | 1 + .../_workspaces_agent_availability.html.haml | 9 +++++ .../workspaces_agents_availability_admin.yml | 10 +++++ ...paces_agent_availability.html.haml_spec.rb | 39 +++++++++++++++++++ .../general.html.haml_spec.rb | 8 ++++ locale/gitlab.pot | 6 +++ 6 files changed, 73 insertions(+) create mode 100644 ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml create mode 100644 ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml create mode 100644 ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb diff --git a/app/views/admin/application_settings/general.html.haml b/app/views/admin/application_settings/general.html.haml index b8c7df18e89cee..91e875f5ffad75 100644 --- a/app/views/admin/application_settings/general.html.haml +++ b/app/views/admin/application_settings/general.html.haml @@ -105,6 +105,7 @@ = render 'admin/application_settings/floc' = render_if_exists 'admin/application_settings/add_license' = render 'admin/application_settings/cluster_agents' += render_if_exists 'admin/application_settings/workspaces_agent_availability' = render 'admin/application_settings/jira_connect' = render 'admin/application_settings/slack' = render 'admin/application_settings/security_txt', expanded: expanded_by_default? diff --git a/ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml b/ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml new file mode 100644 index 00000000000000..4410ad16d3bf1e --- /dev/null +++ b/ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml @@ -0,0 +1,9 @@ +- return unless ::License.feature_available?(:remote_development) && ::Feature.enabled?(:workspaces_agents_availability_admin, current_user) + += render ::Layouts::SettingsBlockComponent.new(s_('Workspaces|Workspaces Agent Availability'), + id: 'js-workspaces-agent-availability-settings', + expanded: expanded_by_default?) do |c| + - c.with_description do + = s_('Workspaces|Configure which Kubernetes agents are available for new workspaces. These settings do not affect existing workspaces.') + - c.with_body do + #js-workspaces-agent-availability-settings-body diff --git a/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml new file mode 100644 index 00000000000000..eea5b8263b389e --- /dev/null +++ b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml @@ -0,0 +1,10 @@ +--- +name: workspaces_agents_availability_admin +description: +feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/513370 +introduced_by_url: +rollout_issue_url: +milestone: '18.1' +group: group::remote development +type: wip +default_enabled: false diff --git a/ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb b/ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb new file mode 100644 index 00000000000000..33544646904806 --- /dev/null +++ b/ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'admin/application_settings/_workspaces_agent_availability', feature_category: :workspaces do + let_it_be(:user) { build_stubbed(:admin) } + let_it_be(:app_settings) { build(:application_setting) } + + # We use `view.render`, because just `render` throws a "no implicit conversion of nil into String" exception + # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53093#note_499060593 + subject(:rendered) { view.render('admin/application_settings/workspaces_agent_availability') } + + before do + assign(:application_setting, app_settings) + allow(view).to receive(:current_user).and_return(user) + end + + context 'when license allows and flag is enabled' do + before do + stub_licensed_features(remote_development: true) + stub_feature_flags(workspaces_agents_availability_admin: true) + end + + it 'renders settings' do + expect(rendered).to have_selector('#js-workspaces-agent-availability-settings') + end + end + + context 'when feature not available' do + before do + stub_licensed_features(remote_development: false) + stub_feature_flags(workspaces_agents_availability_admin: false) + end + + it 'renders nothing' do + expect(rendered).to be_nil + end + end +end diff --git a/ee/spec/views/admin/application_settings/general.html.haml_spec.rb b/ee/spec/views/admin/application_settings/general.html.haml_spec.rb index a102f52f04d009..88194726ba0d76 100644 --- a/ee/spec/views/admin/application_settings/general.html.haml_spec.rb +++ b/ee/spec/views/admin/application_settings/general.html.haml_spec.rb @@ -153,4 +153,12 @@ end end end + + describe 'Workspaces agent availability settings', feature_category: :remote_development do + it 'renders correct ee partial' do + render + + expect(rendered).to render_template('admin/application_settings/_workspaces_agent_availability') + end + end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index c269cb2ffadcc1..5cf0573b36af1a 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -70152,6 +70152,9 @@ msgstr "" msgid "Workspaces|Cluster agent" msgstr "" +msgid "Workspaces|Configure which Kubernetes agents are available for new workspaces. These settings do not affect existing workspaces." +msgstr "" + msgid "Workspaces|Could not load available agents. Refresh the page to try again." msgstr "" @@ -70329,6 +70332,9 @@ msgstr "" msgid "Workspaces|Workspaces" msgstr "" +msgid "Workspaces|Workspaces Agent Availability" +msgstr "" + msgid "Workspaces|Workspaces Settings" msgstr "" -- GitLab From fa3244524b2174b303d12580aba72393d04095e6 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Wed, 14 May 2025 11:03:56 +0900 Subject: [PATCH 2/7] Workspaces agent availability table skeleton --- .../workspaces_agent_availability_table.vue | 112 ++++++++++++++++++ .../general/workspaces_agent_availability.js | 16 +++ .../application_settings/general/index.js | 2 + locale/gitlab.pot | 27 +++++ 4 files changed, 157 insertions(+) create mode 100644 ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue create mode 100644 ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js diff --git a/ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue b/ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue new file mode 100644 index 00000000000000..e6c3b54eb7f5f9 --- /dev/null +++ b/ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue @@ -0,0 +1,112 @@ + + diff --git a/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js b/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js new file mode 100644 index 00000000000000..83215325aaf0d7 --- /dev/null +++ b/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js @@ -0,0 +1,16 @@ +import Vue from 'vue'; +import WorkspacesAgentAvailabilityTable from './components/workspaces_agent_availability_table.vue'; + +export default function initWorkspacesAgentAvailabilityApp() { + const el = document.getElementById('js-workspaces-agent-availability-settings-body'); + + return new Vue({ + el, + components: { + WorkspacesAgentAvailabilityTable, + }, + render(createElement) { + return createElement(WorkspacesAgentAvailabilityTable); + }, + }); +} diff --git a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js index 46da4fb69a582c..6d64e726053f95 100644 --- a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js +++ b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js @@ -1,6 +1,7 @@ import '~/pages/admin/application_settings/general/index'; import { initPrivateProfileRestrictions } from 'ee/admin/application_settings/user_restrictions'; import initAddLicenseApp from 'ee/admin/application_settings/general/add_license'; +import initWorkspacesAgentAvailabilityApp from 'ee/admin/application_settings/general/workspaces_agent_availability'; import { initScimTokenApp } from 'ee/saml_sso'; import { initMaintenanceModeSettings } from 'ee/maintenance_mode_settings'; import { initServicePingSettingsClickTracking } from 'ee/registration_features_discovery_message'; @@ -14,3 +15,4 @@ initScimTokenApp(); initPrivateProfileRestrictions(); initInputCopyToggleVisibility(); initAllowedIntegrations(); +initWorkspacesAgentAvailabilityApp(); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 5cf0573b36af1a..bd6299c8538a05 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -70137,12 +70137,21 @@ msgstr "" msgid "Workspaces|Allowed agents" msgstr "" +msgid "Workspaces|Availability" +msgstr "" + +msgid "Workspaces|Available" +msgstr "" + msgid "Workspaces|Block agent" msgstr "" msgid "Workspaces|Block this agent for all group members?" msgstr "" +msgid "Workspaces|Blocked" +msgstr "" + msgid "Workspaces|Blocking an agent doesn't delete it. Agents can only be deleted in the project where they were created." msgstr "" @@ -70155,6 +70164,9 @@ msgstr "" msgid "Workspaces|Configure which Kubernetes agents are available for new workspaces. These settings do not affect existing workspaces." msgstr "" +msgid "Workspaces|Connected" +msgstr "" + msgid "Workspaces|Could not load available agents. Refresh the page to try again." msgstr "" @@ -70212,6 +70224,9 @@ msgstr "" msgid "Workspaces|GitLab devfile" msgstr "" +msgid "Workspaces|Group" +msgstr "" + msgid "Workspaces|Group agents" msgstr "" @@ -70230,18 +70245,27 @@ msgstr "" msgid "Workspaces|Learn more." msgstr "" +msgid "Workspaces|Name" +msgstr "" + msgid "Workspaces|New workspace" msgstr "" msgid "Workspaces|No active workspaces" msgstr "" +msgid "Workspaces|No agents available" +msgstr "" + msgid "Workspaces|No agents available to create workspaces. Please consult %{linkStart}Workspaces documentation%{linkEnd} for troubleshooting." msgstr "" msgid "Workspaces|No terminated workspaces" msgstr "" +msgid "Workspaces|Not connected" +msgstr "" + msgid "Workspaces|Open workspace" msgstr "" @@ -70272,6 +70296,9 @@ msgstr "" msgid "Workspaces|Starting workspace" msgstr "" +msgid "Workspaces|Status" +msgstr "" + msgid "Workspaces|Stop" msgstr "" -- GitLab From 3b98a57b7225fd6c2a9c01f9c8962b2fc8e019f0 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Wed, 14 May 2025 11:19:08 +0900 Subject: [PATCH 3/7] Update feature flag introduced_by_url --- .../feature_flags/wip/workspaces_agents_availability_admin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml index eea5b8263b389e..f849fe36b36f9d 100644 --- a/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml +++ b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml @@ -2,7 +2,7 @@ name: workspaces_agents_availability_admin description: feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/513370 -introduced_by_url: +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/191120 rollout_issue_url: milestone: '18.1' group: group::remote development -- GitLab From d0550b269d390d777da59534a422a1890558fd0f Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Fri, 16 May 2025 14:24:54 +0900 Subject: [PATCH 4/7] Address MR feedback --- .../admin/application_settings/general.html.haml | 2 +- .../general/workspaces_agent_availability.js | 16 ---------------- .../admin/application_settings/general/index.js | 2 +- .../workspaces/admin_settings/index.js | 16 ++++++++++++++++ .../admin_settings/pages/app.vue} | 3 ++- .../_agent_availability.html.haml} | 6 +++--- .../general.html.haml_spec.rb | 2 +- .../_agent_availability.html.haml_spec.rb} | 2 +- 8 files changed, 25 insertions(+), 24 deletions(-) delete mode 100644 ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js create mode 100644 ee/app/assets/javascripts/workspaces/admin_settings/index.js rename ee/app/assets/javascripts/{admin/application_settings/general/components/workspaces_agent_availability_table.vue => workspaces/admin_settings/pages/app.vue} (96%) rename ee/app/views/admin/application_settings/{_workspaces_agent_availability.html.haml => workspaces/_agent_availability.html.haml} (82%) rename ee/spec/views/admin/application_settings/{_workspaces_agent_availability.html.haml_spec.rb => workspaces/_agent_availability.html.haml_spec.rb} (97%) diff --git a/app/views/admin/application_settings/general.html.haml b/app/views/admin/application_settings/general.html.haml index 91e875f5ffad75..e480b9879b046e 100644 --- a/app/views/admin/application_settings/general.html.haml +++ b/app/views/admin/application_settings/general.html.haml @@ -105,7 +105,7 @@ = render 'admin/application_settings/floc' = render_if_exists 'admin/application_settings/add_license' = render 'admin/application_settings/cluster_agents' -= render_if_exists 'admin/application_settings/workspaces_agent_availability' += render_if_exists 'admin/application_settings/workspaces/agent_availability' = render 'admin/application_settings/jira_connect' = render 'admin/application_settings/slack' = render 'admin/application_settings/security_txt', expanded: expanded_by_default? diff --git a/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js b/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js deleted file mode 100644 index 83215325aaf0d7..00000000000000 --- a/ee/app/assets/javascripts/admin/application_settings/general/workspaces_agent_availability.js +++ /dev/null @@ -1,16 +0,0 @@ -import Vue from 'vue'; -import WorkspacesAgentAvailabilityTable from './components/workspaces_agent_availability_table.vue'; - -export default function initWorkspacesAgentAvailabilityApp() { - const el = document.getElementById('js-workspaces-agent-availability-settings-body'); - - return new Vue({ - el, - components: { - WorkspacesAgentAvailabilityTable, - }, - render(createElement) { - return createElement(WorkspacesAgentAvailabilityTable); - }, - }); -} diff --git a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js index 6d64e726053f95..997de3123a41f1 100644 --- a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js +++ b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js @@ -1,7 +1,7 @@ import '~/pages/admin/application_settings/general/index'; +import { initWorkspacesAgentAvailabilityApp } from 'ee/workspaces/admin_settings'; import { initPrivateProfileRestrictions } from 'ee/admin/application_settings/user_restrictions'; import initAddLicenseApp from 'ee/admin/application_settings/general/add_license'; -import initWorkspacesAgentAvailabilityApp from 'ee/admin/application_settings/general/workspaces_agent_availability'; import { initScimTokenApp } from 'ee/saml_sso'; import { initMaintenanceModeSettings } from 'ee/maintenance_mode_settings'; import { initServicePingSettingsClickTracking } from 'ee/registration_features_discovery_message'; diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/index.js b/ee/app/assets/javascripts/workspaces/admin_settings/index.js new file mode 100644 index 00000000000000..4b9d75bab9fc58 --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/admin_settings/index.js @@ -0,0 +1,16 @@ +import Vue from 'vue'; +import WorkspacesAgentAvailabilityApp from './pages/app.vue'; + +export const initWorkspacesAgentAvailabilityApp = () => { + const el = document.getElementById('js-workspaces-agent-availability-settings-body'); + + return new Vue({ + el, + components: { + WorkspacesAgentAvailabilityApp, + }, + render(createElement) { + return createElement(WorkspacesAgentAvailabilityApp); + }, + }); +}; diff --git a/ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue similarity index 96% rename from ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue rename to ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue index e6c3b54eb7f5f9..d314fd4f931463 100644 --- a/ee/app/assets/javascripts/admin/application_settings/general/components/workspaces_agent_availability_table.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue @@ -3,7 +3,7 @@ import { GlBadge, GlTableLite, GlToggle } from '@gitlab/ui'; import { s__ } from '~/locale'; export default { - name: 'WorkspacesAgentAvailabilityTable', + name: 'WorkspacesAgentAvailabilityApp', components: { GlTableLite, GlBadge, @@ -40,6 +40,7 @@ export default { }, }, // TODO: replace with GQL query + // Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/513370 mockData: [ { name: 'remotedev', diff --git a/ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml b/ee/app/views/admin/application_settings/workspaces/_agent_availability.html.haml similarity index 82% rename from ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml rename to ee/app/views/admin/application_settings/workspaces/_agent_availability.html.haml index 4410ad16d3bf1e..3a41cf7eda62b1 100644 --- a/ee/app/views/admin/application_settings/_workspaces_agent_availability.html.haml +++ b/ee/app/views/admin/application_settings/workspaces/_agent_availability.html.haml @@ -2,8 +2,8 @@ = render ::Layouts::SettingsBlockComponent.new(s_('Workspaces|Workspaces Agent Availability'), id: 'js-workspaces-agent-availability-settings', - expanded: expanded_by_default?) do |c| - - c.with_description do + expanded: expanded_by_default?) do |setting| + - setting.with_description do = s_('Workspaces|Configure which Kubernetes agents are available for new workspaces. These settings do not affect existing workspaces.') - - c.with_body do + - setting.with_body do #js-workspaces-agent-availability-settings-body diff --git a/ee/spec/views/admin/application_settings/general.html.haml_spec.rb b/ee/spec/views/admin/application_settings/general.html.haml_spec.rb index 88194726ba0d76..5e7385805c18c4 100644 --- a/ee/spec/views/admin/application_settings/general.html.haml_spec.rb +++ b/ee/spec/views/admin/application_settings/general.html.haml_spec.rb @@ -158,7 +158,7 @@ it 'renders correct ee partial' do render - expect(rendered).to render_template('admin/application_settings/_workspaces_agent_availability') + expect(rendered).to render_template('admin/application_settings/workspaces/_agent_availability') end end end diff --git a/ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb similarity index 97% rename from ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb rename to ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb index 33544646904806..28f833f5e3f6d6 100644 --- a/ee/spec/views/admin/application_settings/_workspaces_agent_availability.html.haml_spec.rb +++ b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb @@ -8,7 +8,7 @@ # We use `view.render`, because just `render` throws a "no implicit conversion of nil into String" exception # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53093#note_499060593 - subject(:rendered) { view.render('admin/application_settings/workspaces_agent_availability') } + subject(:rendered) { view.render('admin/application_settings/workspaces/agent_availability') } before do assign(:application_setting, app_settings) -- GitLab From 0d19aaba1edef817795d5b58b08de05f6975ad10 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Thu, 22 May 2025 12:57:09 +0900 Subject: [PATCH 5/7] Address MR feedback --- .../application_settings/general/index.js | 2 +- .../workspaces/admin_settings/constants.js | 21 +++++++++++ .../{index.js => init_admin_settings_app.js} | 4 +- .../workspaces/admin_settings/pages/app.vue | 23 +++--------- .../_agent_availability.html.haml_spec.rb | 37 +++++++++---------- 5 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 ee/app/assets/javascripts/workspaces/admin_settings/constants.js rename ee/app/assets/javascripts/workspaces/admin_settings/{index.js => init_admin_settings_app.js} (78%) diff --git a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js index 997de3123a41f1..242513b6f009c5 100644 --- a/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js +++ b/ee/app/assets/javascripts/pages/admin/application_settings/general/index.js @@ -1,5 +1,5 @@ import '~/pages/admin/application_settings/general/index'; -import { initWorkspacesAgentAvailabilityApp } from 'ee/workspaces/admin_settings'; +import { initWorkspacesAgentAvailabilityApp } from 'ee/workspaces/admin_settings/init_admin_settings_app'; import { initPrivateProfileRestrictions } from 'ee/admin/application_settings/user_restrictions'; import initAddLicenseApp from 'ee/admin/application_settings/general/add_license'; import { initScimTokenApp } from 'ee/saml_sso'; diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/constants.js b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js new file mode 100644 index 00000000000000..f3e86daadb5c85 --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js @@ -0,0 +1,21 @@ +import { s__ } from '~/locale'; + +const AVAILABILITY_OPTIONS = { + AVAILABLE: 'available', + BLOCKED: 'blocked', +}; + +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/index.js b/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js similarity index 78% rename from ee/app/assets/javascripts/workspaces/admin_settings/index.js rename to ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js index 4b9d75bab9fc58..cbbcf2040387d0 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/index.js +++ b/ee/app/assets/javascripts/workspaces/admin_settings/init_admin_settings_app.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import WorkspacesAgentAvailabilityApp from './pages/app.vue'; -export const initWorkspacesAgentAvailabilityApp = () => { +const initWorkspacesAgentAvailabilityApp = () => { const el = document.getElementById('js-workspaces-agent-availability-settings-body'); return new Vue({ @@ -14,3 +14,5 @@ export const initWorkspacesAgentAvailabilityApp = () => { }, }); }; + +export { initWorkspacesAgentAvailabilityApp }; 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 d314fd4f931463..0339f08f15b478 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue @@ -2,6 +2,8 @@ import { GlBadge, GlTableLite, GlToggle } from '@gitlab/ui'; import { s__ } from '~/locale'; +import { AVAILABILITY_TEXT, CONNECTION_STATUS_TEXT } from '../constants'; + export default { name: 'WorkspacesAgentAvailabilityApp', components: { @@ -19,28 +21,13 @@ export default { } }, getStatusText(status) { - switch (status) { - case 'not_connected': - return s__('Workspaces|Not connected'); - case 'connected': - return s__('Workspaces|Connected'); - default: - return null; - } + return AVAILABILITY_TEXT[status] ?? null; }, getAvailabilityText(availability) { - switch (availability) { - case 'available': - return s__('Workspaces|Available'); - case 'blocked': - return s__('Workspaces|Blocked'); - default: - return null; - } + return CONNECTION_STATUS_TEXT[availability] ?? null; }, }, - // TODO: replace with GQL query - // Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/513370 + // TODO: replace with GQL query - https://gitlab.com/gitlab-org/gitlab/-/issues/513370 mockData: [ { name: 'remotedev', diff --git a/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb index 28f833f5e3f6d6..87a78ac6d74f70 100644 --- a/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb +++ b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb @@ -15,25 +15,24 @@ allow(view).to receive(:current_user).and_return(user) end - context 'when license allows and flag is enabled' do - before do - stub_licensed_features(remote_development: true) - stub_feature_flags(workspaces_agents_availability_admin: true) - end - - it 'renders settings' do - expect(rendered).to have_selector('#js-workspaces-agent-availability-settings') - end - end - - context 'when feature not available' do - before do - stub_licensed_features(remote_development: false) - stub_feature_flags(workspaces_agents_availability_admin: false) - end - - it 'renders nothing' do - expect(rendered).to be_nil + [true, false].each do |license_enabled| + [true, false].each do |flag_enabled| + context "when license is #{license_enabled ? 'enabled' : 'disabled'} " \ + "and flag is #{flag_enabled ? 'on' : 'off'}" do + before do + stub_licensed_features(remote_development: license_enabled) + stub_feature_flags(workspaces_agents_availability_admin: flag_enabled) + end + + it "#{license_enabled && flag_enabled ? 'renders' : 'does not render'} settings" do + if license_enabled && flag_enabled + expect(rendered).to have_selector('#js-workspaces-agent-availability-settings') + # Anything else you find relevant for testing Cindy! + else + expect(rendered).to be_nil + end + end + end end end end -- GitLab From 1534964a75b538d863b1b554e6bb2e16e6803710 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Fri, 23 May 2025 10:42:54 +0900 Subject: [PATCH 6/7] Apply MR feedback --- .../javascripts/workspaces/admin_settings/constants.js | 2 +- .../workspaces/admin_settings/pages/app.vue | 10 +++++----- .../workspaces/_agent_availability.html.haml_spec.rb | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ee/app/assets/javascripts/workspaces/admin_settings/constants.js b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js index f3e86daadb5c85..f9e3abc56e9c5e 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/constants.js +++ b/ee/app/assets/javascripts/workspaces/admin_settings/constants.js @@ -5,7 +5,7 @@ const AVAILABILITY_OPTIONS = { BLOCKED: 'blocked', }; -const CONNECTION_STATUS = { +export const CONNECTION_STATUS = { CONNECTED: 'connected', NOT_CONNECTED: 'not_connected', }; 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 0339f08f15b478..f7e8a3d913d925 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue @@ -2,7 +2,7 @@ import { GlBadge, GlTableLite, GlToggle } from '@gitlab/ui'; import { s__ } from '~/locale'; -import { AVAILABILITY_TEXT, CONNECTION_STATUS_TEXT } from '../constants'; +import { AVAILABILITY_TEXT, CONNECTION_STATUS_TEXT, CONNECTION_STATUS } from '../constants'; export default { name: 'WorkspacesAgentAvailabilityApp', @@ -14,17 +14,17 @@ export default { methods: { getBadgeVariant(status) { switch (status) { - case 'connected': + case CONNECTION_STATUS.CONNECTED: return 'success'; default: return 'neutral'; } }, getStatusText(status) { - return AVAILABILITY_TEXT[status] ?? null; + return CONNECTION_STATUS_TEXT[status] ?? null; }, getAvailabilityText(availability) { - return CONNECTION_STATUS_TEXT[availability] ?? null; + return AVAILABILITY_TEXT[availability] ?? null; }, }, // TODO: replace with GQL query - https://gitlab.com/gitlab-org/gitlab/-/issues/513370 @@ -77,7 +77,7 @@ export default { :fields="$options.fields" > diff --git a/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb index 87a78ac6d74f70..2cf14d3ae22c9e 100644 --- a/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb +++ b/ee/spec/views/admin/application_settings/workspaces/_agent_availability.html.haml_spec.rb @@ -27,7 +27,6 @@ it "#{license_enabled && flag_enabled ? 'renders' : 'does not render'} settings" do if license_enabled && flag_enabled expect(rendered).to have_selector('#js-workspaces-agent-availability-settings') - # Anything else you find relevant for testing Cindy! else expect(rendered).to be_nil end -- GitLab From 081049cbee2a3586bdee74a70271e52e8bbdd273 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Mon, 26 May 2025 11:58:10 +0900 Subject: [PATCH 7/7] Apply MR feedback --- .../workspaces/admin_settings/init_admin_settings_app.js | 2 ++ .../assets/javascripts/workspaces/admin_settings/pages/app.vue | 1 - .../feature_flags/wip/workspaces_agents_availability_admin.yml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) 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 cbbcf2040387d0..54e81abaa3c02e 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 @@ -4,6 +4,8 @@ import WorkspacesAgentAvailabilityApp from './pages/app.vue'; const initWorkspacesAgentAvailabilityApp = () => { const el = document.getElementById('js-workspaces-agent-availability-settings-body'); + if (!el) return null; + return new Vue({ el, components: { 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 f7e8a3d913d925..f50a6239cf206f 100644 --- a/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue +++ b/ee/app/assets/javascripts/workspaces/admin_settings/pages/app.vue @@ -87,7 +87,6 @@ export default { :value="item.availability === 'available'" :label="getAvailabilityText(item.availability)" label-position="hidden" - class="flex-row" />

{{ getAvailabilityText(item.availability) }}

diff --git a/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml index f849fe36b36f9d..1ebf754f84cc4b 100644 --- a/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml +++ b/ee/config/feature_flags/wip/workspaces_agents_availability_admin.yml @@ -1,6 +1,6 @@ --- name: workspaces_agents_availability_admin -description: +description: Enables the development of the Workspace agents availability admin page feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/513370 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/191120 rollout_issue_url: -- GitLab