diff options
Diffstat (limited to 'app/assets/javascripts/repository')
8 files changed, 73 insertions, 20 deletions
diff --git a/app/assets/javascripts/repository/components/table/index.vue b/app/assets/javascripts/repository/components/table/index.vue index c8549180a25..5e0ad7acdfd 100644 --- a/app/assets/javascripts/repository/components/table/index.vue +++ b/app/assets/javascripts/repository/components/table/index.vue @@ -80,7 +80,7 @@ export default { <table-header v-once /> <tbody> <parent-row - v-show="showParentRow" + v-if="showParentRow" :commit-ref="escapedRef" :path="path" :loading-path="loadingPath" @@ -97,6 +97,7 @@ export default { :path="entry.flatPath" :type="entry.type" :url="entry.webUrl" + :mode="entry.mode" :submodule-tree-url="entry.treeUrl" :lfs-oid="entry.lfsOid" :loading-path="loadingPath" diff --git a/app/assets/javascripts/repository/components/table/row.vue b/app/assets/javascripts/repository/components/table/row.vue index d5363016335..615e329f415 100644 --- a/app/assets/javascripts/repository/components/table/row.vue +++ b/app/assets/javascripts/repository/components/table/row.vue @@ -66,6 +66,11 @@ export default { type: String, required: true, }, + mode: { + type: String, + required: false, + default: '', + }, type: { type: String, required: true, @@ -140,6 +145,7 @@ export default { > <file-icon :file-name="fullPath" + :file-mode="mode" :folder="isFolder" :submodule="isSubmodule" :loading="path === loadingPath" diff --git a/app/assets/javascripts/repository/components/tree_content.vue b/app/assets/javascripts/repository/components/tree_content.vue index 7b34e9ef60d..59ba1caa8c9 100644 --- a/app/assets/javascripts/repository/components/tree_content.vue +++ b/app/assets/javascripts/repository/components/tree_content.vue @@ -5,7 +5,6 @@ import FileTable from './table/index.vue'; import getRefMixin from '../mixins/get_ref'; import getFiles from '../queries/getFiles.query.graphql'; import getProjectPath from '../queries/getProjectPath.query.graphql'; -import getVueFileListLfsBadge from '../queries/getVueFileListLfsBadge.query.graphql'; import FilePreview from './preview/index.vue'; import { readmeFile } from '../utils/readme'; @@ -21,9 +20,6 @@ export default { projectPath: { query: getProjectPath, }, - vueFileListLfsBadge: { - query: getVueFileListLfsBadge, - }, }, props: { path: { @@ -47,7 +43,6 @@ export default { blobs: [], }, isLoadingFiles: false, - vueFileListLfsBadge: false, }; }, computed: { @@ -82,7 +77,6 @@ export default { path: this.path || '/', nextPageCursor: this.nextPageCursor, pageSize: PAGE_SIZE, - vueLfsEnabled: this.vueFileListLfsBadge, }, }) .then(({ data }) => { diff --git a/app/assets/javascripts/repository/components/web_ide_link.vue b/app/assets/javascripts/repository/components/web_ide_link.vue new file mode 100644 index 00000000000..6549d5a3878 --- /dev/null +++ b/app/assets/javascripts/repository/components/web_ide_link.vue @@ -0,0 +1,47 @@ +<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/graphql.js b/app/assets/javascripts/repository/graphql.js index 6640b636597..450a1571165 100644 --- a/app/assets/javascripts/repository/graphql.js +++ b/app/assets/javascripts/repository/graphql.js @@ -30,7 +30,7 @@ const defaultClient = createDefaultClient( }, readme(_, { url }) { return axios - .get(url, { params: { viewer: 'rich', format: 'json' } }) + .get(url, { params: { format: 'json', viewer: 'rich' } }) .then(({ data }) => ({ ...data, __typename: 'ReadmeFile' })); }, }, diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 6528e283372..4f80ab4ff5d 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -4,18 +4,26 @@ 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 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 { webIDEUrl } from '../lib/utils/url_utility'; import { __ } from '../locale'; export default function setupVueRepositoryList() { const el = document.getElementById('js-tree-list'); const { dataset } = el; - const { projectPath, projectShortPath, ref, escapedRef, fullName } = dataset; + const { + canPushCode, + projectPath, + projectShortPath, + forkPath, + ref, + escapedRef, + fullName, + } = dataset; const router = createRouter(projectPath, escapedRef); apolloProvider.clients.defaultClient.cache.writeData({ @@ -24,7 +32,6 @@ export default function setupVueRepositoryList() { projectShortPath, ref, escapedRef, - vueFileListLfsBadge: gon.features?.vueFileListLfsBadge || false, commits: [], }, }); @@ -118,11 +125,12 @@ export default function setupVueRepositoryList() { el: webIdeLinkEl, router, render(h) { - return h(TreeActionLink, { + return h(WebIdeLink, { props: { - path: webIDEUrl(`/${projectPath}/edit/${ref}/-/${this.$route.params.path || ''}`), - text: __('Web IDE'), - cssClass: 'qa-web-ide-button', + projectPath, + refSha: ref, + forkPath, + canPushCode: parseBoolean(canPushCode), }, }); }, diff --git a/app/assets/javascripts/repository/queries/getFiles.query.graphql b/app/assets/javascripts/repository/queries/getFiles.query.graphql index 01ad72ef752..feb89df0492 100644 --- a/app/assets/javascripts/repository/queries/getFiles.query.graphql +++ b/app/assets/javascripts/repository/queries/getFiles.query.graphql @@ -14,7 +14,6 @@ query getFiles( $ref: String! $pageSize: Int! $nextPageCursor: String - $vueLfsEnabled: Boolean = false ) { project(fullPath: $projectPath) { repository { @@ -46,8 +45,9 @@ query getFiles( edges { node { ...TreeEntry + mode webUrl - lfsOid @include(if: $vueLfsEnabled) + lfsOid } } pageInfo { diff --git a/app/assets/javascripts/repository/queries/getVueFileListLfsBadge.query.graphql b/app/assets/javascripts/repository/queries/getVueFileListLfsBadge.query.graphql deleted file mode 100644 index eb21c1e73d8..00000000000 --- a/app/assets/javascripts/repository/queries/getVueFileListLfsBadge.query.graphql +++ /dev/null @@ -1,3 +0,0 @@ -query getVueFileListLfsBadge { - vueFileListLfsBadge @client -} |