Commit a3c0ad65 authored by Paul Slaughter's avatar Paul Slaughter Committed by Sean McGivern

Fix "Edit fork in Web IDE" behavior

- This was accidentally removed when things were
[refactored for Gitpod][1]

[1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37985
parent d1d63b17
...@@ -113,9 +113,10 @@ export default function setupVueRepositoryList() { ...@@ -113,9 +113,10 @@ export default function setupVueRepositoryList() {
const webIdeLinkEl = document.getElementById('js-tree-web-ide-link'); const webIdeLinkEl = document.getElementById('js-tree-web-ide-link');
if (webIdeLinkEl) { if (webIdeLinkEl) {
const { ideBasePath, ...options } = convertObjectPropsToCamelCase( const {
JSON.parse(webIdeLinkEl.dataset.options), webIdeUrlData: { path: ideBasePath, isFork: webIdeIsFork },
); ...options
} = convertObjectPropsToCamelCase(JSON.parse(webIdeLinkEl.dataset.options), { deep: true });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
...@@ -127,6 +128,7 @@ export default function setupVueRepositoryList() { ...@@ -127,6 +128,7 @@ export default function setupVueRepositoryList() {
webIdeUrl: webIDEUrl( webIdeUrl: webIDEUrl(
joinPaths('/', ideBasePath, 'edit', ref, '-', this.$route.params.path || '', '/'), joinPaths('/', ideBasePath, 'edit', ref, '-', this.$route.params.path || '', '/'),
), ),
webIdeIsFork,
...options, ...options,
}, },
}); });
......
...@@ -15,7 +15,13 @@ export default { ...@@ -15,7 +15,13 @@ export default {
props: { props: {
webIdeUrl: { webIdeUrl: {
type: String, type: String,
required: true, required: false,
default: '',
},
webIdeIsFork: {
type: Boolean,
required: false,
default: false,
}, },
needsToFork: { needsToFork: {
type: Boolean, type: Boolean,
...@@ -61,9 +67,11 @@ export default { ...@@ -61,9 +67,11 @@ export default {
? { href: '#modal-confirm-fork', handle: () => this.showModal('#modal-confirm-fork') } ? { href: '#modal-confirm-fork', handle: () => this.showModal('#modal-confirm-fork') }
: { href: this.webIdeUrl }; : { href: this.webIdeUrl };
const text = this.webIdeIsFork ? __('Edit fork in Web IDE') : __('Web IDE');
return { return {
key: KEY_WEB_IDE, key: KEY_WEB_IDE,
text: __('Web IDE'), text,
secondaryText: __('Quickly and easily edit multiple files in your project.'), secondaryText: __('Quickly and easily edit multiple files in your project.'),
tooltip: '', tooltip: '',
attrs: { attrs: {
......
...@@ -199,14 +199,14 @@ module TreeHelper ...@@ -199,14 +199,14 @@ module TreeHelper
} }
end end
def ide_base_path(project) def web_ide_url_data(project)
can_push_code = current_user&.can?(:push_code, project) can_push_code = current_user&.can?(:push_code, project)
fork_path = current_user&.fork_of(project)&.full_path fork_path = current_user&.fork_of(project)&.full_path
if can_push_code if fork_path && !can_push_code
project.full_path { path: fork_path, is_fork: true }
else else
fork_path || project.full_path { path: project.full_path, is_fork: false }
end end
end end
...@@ -216,7 +216,7 @@ module TreeHelper ...@@ -216,7 +216,7 @@ module TreeHelper
show_web_ide_button = (can_collaborate || current_user&.already_forked?(project) || can_create_mr_from_fork) show_web_ide_button = (can_collaborate || current_user&.already_forked?(project) || can_create_mr_from_fork)
{ {
ide_base_path: ide_base_path(project), web_ide_url_data: web_ide_url_data(project),
needs_to_fork: !can_collaborate && !current_user&.already_forked?(project), needs_to_fork: !can_collaborate && !current_user&.already_forked?(project),
show_web_ide_button: show_web_ide_button, show_web_ide_button: show_web_ide_button,
show_gitpod_button: show_web_ide_button && Gitlab::Gitpod.feature_and_settings_enabled?(project), show_gitpod_button: show_web_ide_button && Gitlab::Gitpod.feature_and_settings_enabled?(project),
......
...@@ -9233,6 +9233,9 @@ msgstr "" ...@@ -9233,6 +9233,9 @@ msgstr ""
msgid "Edit files in the editor and commit changes here" msgid "Edit files in the editor and commit changes here"
msgstr "" msgstr ""
msgid "Edit fork in Web IDE"
msgstr ""
msgid "Edit group: %{group_name}" msgid "Edit group: %{group_name}"
msgstr "" msgstr ""
......
...@@ -60,6 +60,7 @@ describe('Web IDE link component', () => { ...@@ -60,6 +60,7 @@ describe('Web IDE link component', () => {
it.each` it.each`
props | expectedActions props | expectedActions
${{}} | ${[ACTION_WEB_IDE]} ${{}} | ${[ACTION_WEB_IDE]}
${{ webIdeIsFork: true }} | ${[{ ...ACTION_WEB_IDE, text: 'Edit fork in Web IDE' }]}
${{ needsToFork: true }} | ${[ACTION_WEB_IDE_FORK]} ${{ needsToFork: true }} | ${[ACTION_WEB_IDE_FORK]}
${{ showWebIdeButton: false, showGitpodButton: true, gitpodEnabled: true }} | ${[ACTION_GITPOD]} ${{ showWebIdeButton: false, showGitpodButton: true, gitpodEnabled: true }} | ${[ACTION_GITPOD]}
${{ showWebIdeButton: false, showGitpodButton: true, gitpodEnabled: false }} | ${[ACTION_GITPOD_ENABLE]} ${{ showWebIdeButton: false, showGitpodButton: true, gitpodEnabled: false }} | ${[ACTION_GITPOD_ENABLE]}
......
...@@ -178,7 +178,7 @@ RSpec.describe TreeHelper do ...@@ -178,7 +178,7 @@ RSpec.describe TreeHelper do
it 'returns a list of attributes related to the project' do it 'returns a list of attributes related to the project' do
expect(subject).to include( expect(subject).to include(
ide_base_path: project.full_path, web_ide_url_data: { path: project.full_path, is_fork: false },
needs_to_fork: false, needs_to_fork: false,
show_web_ide_button: true, show_web_ide_button: true,
show_gitpod_button: false, show_gitpod_button: false,
...@@ -200,9 +200,9 @@ RSpec.describe TreeHelper do ...@@ -200,9 +200,9 @@ RSpec.describe TreeHelper do
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
end end
it 'includes ide_base_path: forked_project.full_path' do it 'includes web_ide_url_data: forked_project.full_path' do
expect(subject).to include( expect(subject).to include(
ide_base_path: forked_project.full_path web_ide_url_data: { path: forked_project.full_path, is_fork: true }
) )
end end
end end
...@@ -216,9 +216,9 @@ RSpec.describe TreeHelper do ...@@ -216,9 +216,9 @@ RSpec.describe TreeHelper do
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
end end
it 'includes ide_base_path: project.full_path' do it 'includes web_ide_url_data: project.full_path' do
expect(subject).to include( expect(subject).to include(
ide_base_path: project.full_path web_ide_url_data: { path: project.full_path, is_fork: false }
) )
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment