diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 21:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 21:09:47 +0300 |
commit | bf1600d157465f9408aace91073954fd5790c054 (patch) | |
tree | f317bb99330769c4eb37621c860af014810e554b /app/assets/javascripts/repository | |
parent | 6de7d2c195a8a7fa5702cafa4365f7a9fcac37cd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/repository')
-rw-r--r-- | app/assets/javascripts/repository/components/web_ide_link.vue | 47 | ||||
-rw-r--r-- | app/assets/javascripts/repository/index.js | 28 |
2 files changed, 12 insertions, 63 deletions
diff --git a/app/assets/javascripts/repository/components/web_ide_link.vue b/app/assets/javascripts/repository/components/web_ide_link.vue deleted file mode 100644 index 6549d5a3878..00000000000 --- a/app/assets/javascripts/repository/components/web_ide_link.vue +++ /dev/null @@ -1,47 +0,0 @@ -<script> -import TreeActionLink from './tree_action_link.vue'; -import { __ } from '~/locale'; -import { webIDEUrl } from '~/lib/utils/url_utility'; - -export default { - components: { - TreeActionLink, - }, - props: { - projectPath: { - type: String, - required: true, - }, - refSha: { - type: String, - required: true, - }, - canPushCode: { - type: Boolean, - required: false, - default: true, - }, - forkPath: { - type: String, - required: false, - default: '', - }, - }, - computed: { - showLinkToFork() { - return !this.canPushCode && this.forkPath; - }, - text() { - return this.showLinkToFork ? __('Edit fork in Web IDE') : __('Web IDE'); - }, - path() { - const path = this.showLinkToFork ? this.forkPath : this.projectPath; - return webIDEUrl(`/${path}/edit/${this.refSha}/-/${this.$route.params.path || ''}`); - }, - }, -}; -</script> - -<template> - <tree-action-link :path="path" :text="text" data-qa-selector="web_ide_button" /> -</template> diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 187bbfed125..7f72524b6fe 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -1,30 +1,22 @@ import Vue from 'vue'; -import { escapeFileUrl } from '../lib/utils/url_utility'; +import { escapeFileUrl, joinPaths, webIDEUrl } from '../lib/utils/url_utility'; import createRouter from './router'; import App from './components/app.vue'; import Breadcrumbs from './components/breadcrumbs.vue'; import LastCommit from './components/last_commit.vue'; import TreeActionLink from './components/tree_action_link.vue'; -import WebIdeLink from './components/web_ide_link.vue'; +import WebIdeLink from '~/vue_shared/components/web_ide_link.vue'; import DirectoryDownloadLinks from './components/directory_download_links.vue'; import apolloProvider from './graphql'; import { setTitle } from './utils/title'; import { updateFormAction } from './utils/dom'; -import { parseBoolean } from '../lib/utils/common_utils'; +import { convertObjectPropsToCamelCase, parseBoolean } from '../lib/utils/common_utils'; import { __ } from '../locale'; export default function setupVueRepositoryList() { const el = document.getElementById('js-tree-list'); const { dataset } = el; - const { - canPushCode, - projectPath, - projectShortPath, - forkPath, - ref, - escapedRef, - fullName, - } = dataset; + const { projectPath, projectShortPath, ref, escapedRef, fullName } = dataset; const router = createRouter(projectPath, escapedRef); apolloProvider.clients.defaultClient.cache.writeData({ @@ -121,6 +113,10 @@ export default function setupVueRepositoryList() { const webIdeLinkEl = document.getElementById('js-tree-web-ide-link'); if (webIdeLinkEl) { + const { ideBasePath, ...options } = convertObjectPropsToCamelCase( + JSON.parse(webIdeLinkEl.dataset.options), + ); + // eslint-disable-next-line no-new new Vue({ el: webIdeLinkEl, @@ -128,10 +124,10 @@ export default function setupVueRepositoryList() { render(h) { return h(WebIdeLink, { props: { - projectPath, - refSha: ref, - forkPath, - canPushCode: parseBoolean(canPushCode), + webIdeUrl: webIDEUrl( + joinPaths('/', ideBasePath, 'edit', ref, '-', this.$route.params.path || '', '/'), + ), + ...options, }, }); }, |