Skip to content
Snippets Groups Projects
Unverified Commit aae5b910 authored by Alper Akgun's avatar Alper Akgun
Browse files

Merge branch 'vtak/private-workspaces' into 'master'

Allow creating workspaces for private projects

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124273



Merged-by: default avatarAlper Akgun <aakgun@gitlab.com>
Approved-by: default avatarEnrique Alcántara <ealcantara@gitlab.com>
Approved-by: default avatarAlper Akgun <aakgun@gitlab.com>
Reviewed-by: default avatarAlper Akgun <aakgun@gitlab.com>
Reviewed-by: default avatarChad Woolley <cwoolley@gitlab.com>
Reviewed-by: default avatarVishal Tak <vtak@gitlab.com>
Co-authored-by: default avatarVishal Tak <vtak@gitlab.com>
parents 6a40efd7 d3a5de56
No related branches found
No related tags found
No related merge requests found
Showing
with 10 additions and 57 deletions
Loading
Loading
@@ -18,7 +18,7 @@ export const i18n = {
workspacesGroupLabel: s__('Workspaces|Your workspaces'),
newWorkspaceButton: s__('Workspaces|New workspace'),
noWorkspacesMessage: s__(
'Workspaces|A workspace is a virtual sandbox environment for your code in GitLab. You can create a workspace for a public project.',
'Workspaces|A workspace is a virtual sandbox environment for your code in GitLab.',
),
loadingWorkspacesFailedMessage: s__('Workspaces|Could not load workspaces'),
noWorkspacesSupportMessage: __('To set up this feature, contact your administrator.'),
Loading
Loading
Loading
Loading
@@ -31,9 +31,7 @@ import {
 
export const i18n = {
title: s__('Workspaces|New workspace'),
subtitle: s__(
'Workspaces|A workspace is a virtual sandbox environment for your code in GitLab. You can create a workspace for a public project.',
),
subtitle: s__('Workspaces|A workspace is a virtual sandbox environment for your code in GitLab.'),
betaBadge: __('Beta'),
form: {
devfileProject: s__('Workspaces|Select project'),
Loading
Loading
@@ -41,9 +39,6 @@ export const i18n = {
editor: s__('Workspaces|Select default editor'),
maxHoursBeforeTermination: s__('Workspaces|Time before automatic termination'),
maxHoursSuffix: __('hours'),
help: {
devfileProjectHelp: s__('Workspaces|You can create a workspace for public projects only.'),
},
},
invalidProjectAlert: {
title: s__("Workspaces|You can't create a workspace for this project"),
Loading
Loading
@@ -219,12 +214,10 @@ export default {
<gl-form class="gl-mt-6 gl-flex-basis-two-thirds" @submit.prevent="createWorkspace">
<gl-form-group
:label="$options.i18n.form.devfileProject"
:label-description="$options.i18n.form.help.devfileProjectHelp"
label-for="workspace-devfile-project-id"
>
<search-projects-listbox
:value="selectedProject"
:visibility="$options.PROJECT_VISIBILITY.public"
data-qa-selector="workspace_devfile_project_id_field"
@input="onSelectProjectFromListbox"
/>
Loading
Loading
Loading
Loading
@@ -27,9 +27,6 @@ class Workspace < ApplicationRecord
# to be used to create a new workspace
validate :validate_agent_config_presence
 
# We do not yet support workspaces for private projects, so validate that the associated project is currently public
validate :validate_project_is_public
# See https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/blob/main/doc/architecture.md?plain=0#workspace-states
# for state validation rules
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/409773
Loading
Loading
@@ -75,12 +72,6 @@ def validate_agent_config_presence
errors.add(:agent, _('for Workspace must have an associated RemoteDevelopmentAgentConfig'))
end
 
def validate_project_is_public
return true if project.public?
errors.add(:project, _('for Workspace is required to be public'))
end
def touch_desired_state_updated_at
self.desired_state_updated_at = Time.current.utc
end
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
FactoryBot.define do
factory :workspace, class: 'RemoteDevelopment::Workspace' do
project factory: [:project, :public, :in_group]
project factory: [:project, :in_group]
user
agent factory: [:ee_cluster_agent, :with_remote_development_agent_config]
personal_access_token
Loading
Loading
Loading
Loading
@@ -13,7 +13,6 @@ import {
DEFAULT_DESIRED_STATE,
DEFAULT_DEVFILE_PATH,
ROUTES,
PROJECT_VISIBILITY,
WORKSPACES_LIST_PAGE_SIZE,
} from 'ee/remote_development/constants';
import waitForPromises from 'helpers/wait_for_promises';
Loading
Loading
@@ -151,10 +150,6 @@ describe('remote_development/pages/create.vue', () => {
createWrapper();
});
 
it('limits projects search to public projects', () => {
expect(findSearchProjectsListbox().props().visibility).toBe(PROJECT_VISIBILITY.public);
});
it('displays a cancel button that allows navigating to the workspaces list', () => {
expect(wrapper.findByTestId('cancel-workspace').attributes().to).toBe(ROUTES.index);
});
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@
include_context 'with remote development shared fixtures'
 
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, :public, :in_group, :repository) }
let_it_be(:project, reload: true) { create(:project, :in_group, :repository) }
let_it_be(:agent) { create(:ee_cluster_agent, :with_remote_development_agent_config) }
let(:random_string) { 'abcdef' }
let(:devfile_path) { '.devfile.yaml' }
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@
end
 
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public, :in_group, :repository) }
let_it_be(:project) { create(:project, :in_group, :repository) }
let_it_be(:agent) { create(:ee_cluster_agent, :with_remote_development_agent_config) }
let(:random_string) { 'abcdef' }
let(:devfile_path) { '.devfile.yaml' }
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@
 
let(:project) do
files = { devfile_path => devfile_yaml }
create(:project, :public, :in_group, :custom_repo, path: 'test-project', files: files, namespace: group)
create(:project, :in_group, :custom_repo, path: 'test-project', files: files, namespace: group)
end
 
let(:agent) do
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@
 
let_it_be(:group) { create(:group, name: "test-group") }
let_it_be(:project) do
create(:project, :public, :in_group, :repository, path: "test-project", namespace: group)
create(:project, :in_group, :repository, path: "test-project", namespace: group)
end
 
let(:flattened_devfile_name) { 'example.flattened-devfile.yaml' }
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@
include_context 'with remote development shared fixtures'
 
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, :public, :in_group, :repository) }
let_it_be(:project, reload: true) { create(:project, :in_group, :repository) }
let_it_be(:agent) { create(:ee_cluster_agent, :with_remote_development_agent_config) }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
let(:random_string) { 'abcdef' }
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@
RSpec.describe RemoteDevelopment::Workspace, feature_category: :remote_development do
let_it_be(:user) { create(:user) }
let_it_be(:agent) { create(:ee_cluster_agent, :with_remote_development_agent_config) }
let_it_be(:project) { create(:project, :public, :in_group) }
let_it_be(:project) { create(:project, :in_group) }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
 
subject do
Loading
Loading
@@ -120,25 +120,5 @@
expect(subject.errors[:agent]).to include('for Workspace must have an associated RemoteDevelopmentAgentConfig')
end
end
context 'on project' do
context 'when the project is not public' do
let_it_be(:private_project) do
create(:project, visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
subject do
build(:workspace, user: user, project: private_project)
end
it 'validates project is public' do
# sanity check of fixture
expect(private_project).to be_private
expect(subject).not_to be_valid
expect(subject.errors[:project]).to include('for Workspace is required to be public')
end
end
end
end
end
Loading
Loading
@@ -53834,7 +53834,7 @@ msgstr ""
msgid "Workspaces"
msgstr ""
 
msgid "Workspaces|A workspace is a virtual sandbox environment for your code in GitLab. You can create a workspace for a public project."
msgid "Workspaces|A workspace is a virtual sandbox environment for your code in GitLab."
msgstr ""
 
msgid "Workspaces|Cancel"
Loading
Loading
@@ -53933,9 +53933,6 @@ msgstr ""
msgid "Workspaces|Workspaces"
msgstr ""
 
msgid "Workspaces|You can create a workspace for public projects only."
msgstr ""
msgid "Workspaces|You can't create a workspace for this project"
msgstr ""
 
Loading
Loading
@@ -56009,9 +56006,6 @@ msgstr[1] ""
msgid "finding is not found or is already attached to a vulnerability"
msgstr ""
 
msgid "for Workspace is required to be public"
msgstr ""
msgid "for Workspace must have an associated RemoteDevelopmentAgentConfig"
msgstr ""
 
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment