Commit 39bf8b82 authored by Samantha Ming's avatar Samantha Ming

Switch to use more GraphQL blob info

parent d164e450
......@@ -5,7 +5,6 @@ import PipelineTourSuccessModal from '~/blob/pipeline_tour_success_modal.vue';
import BlobViewer from '~/blob/viewer/index';
import GpgBadges from '~/gpg_badges';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import initBlob from '~/pages/projects/init_blob';
import initWebIdeLink from '~/pages/projects/shared/web_ide_link';
import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
......@@ -21,14 +20,7 @@ const apolloProvider = new VueApollo({
const viewBlobEl = document.querySelector('#js-view-blob-app');
if (viewBlobEl) {
const {
blobPath,
projectPath,
targetBranch,
originalBranch,
canPushCode,
replacePath,
} = viewBlobEl.dataset;
const { blobPath, projectPath, targetBranch, originalBranch } = viewBlobEl.dataset;
// eslint-disable-next-line no-new
new Vue({
......@@ -37,8 +29,6 @@ if (viewBlobEl) {
provide: {
targetBranch,
originalBranch,
canPushCode: parseBoolean(canPushCode),
replacePath,
},
render(createElement) {
return createElement(BlobContentViewer, {
......
......@@ -135,7 +135,13 @@ export default {
:edit-path="blobInfo.editBlobPath"
:web-ide-path="blobInfo.ideEditPath"
/>
<blob-replace v-if="isLoggedIn" :name="blobInfo.name" :path="path" />
<blob-replace
v-if="isLoggedIn"
:path="path"
:name="blobInfo.name"
:replace-path="blobInfo.replacePath"
:can-push-code="blobInfo.canModifyBlob"
/>
</template>
</blob-header>
<blob-content
......
......@@ -2,6 +2,7 @@
import { GlButton, GlModalDirective } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import { sprintf, __ } from '~/locale';
import getRefMixin from '../mixins/get_ref';
import UploadBlobModal from './upload_blob_modal.vue';
export default {
......@@ -16,6 +17,7 @@ export default {
directives: {
GlModal: GlModalDirective,
},
mixins: [getRefMixin],
inject: {
targetBranch: {
default: '',
......@@ -23,12 +25,6 @@ export default {
originalBranch: {
default: '',
},
canPushCode: {
default: false,
},
replacePath: {
default: null,
},
},
props: {
name: {
......@@ -39,6 +35,14 @@ export default {
type: String,
required: true,
},
replacePath: {
type: String,
required: true,
},
canPushCode: {
type: Boolean,
required: true,
},
},
computed: {
replaceModalId() {
......@@ -60,8 +64,8 @@ export default {
:modal-id="replaceModalId"
:modal-title="title"
:commit-message="title"
:target-branch="targetBranch"
:original-branch="originalBranch"
:target-branch="targetBranch || ref"
:original-branch="originalBranch || ref"
:can-push-code="canPushCode"
:path="path"
:replace-path="replacePath"
......
......@@ -6,7 +6,7 @@ export default {
query: refQuery,
manual: true,
result({ data, loading }) {
if (!loading) {
if (data && !loading) {
this.ref = data.ref;
this.escapedRef = data.escapedRef;
}
......
......@@ -15,6 +15,7 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) {
storedExternally
rawPath
replacePath
canModifyBlob
simpleViewer {
fileType
tooLarge
......
......@@ -19,9 +19,7 @@
#js-view-blob-app{ data: { blob_path: blob.path,
project_path: @project.full_path,
target_branch: project.empty_repo? ? ref : @ref,
original_branch: @ref,
can_push_code: can?(current_user, :push_code, @project).to_s,
replace_path: project_update_blob_path(@project, @id) } }
original_branch: @ref } }
.gl-spinner-container
= loading_icon(size: 'md')
- else
......
......@@ -5,13 +5,13 @@ import UploadBlobModal from '~/repository/components/upload_blob_modal.vue';
const DEFAULT_PROPS = {
name: 'some name',
path: 'some/path',
canPushCode: true,
replacePath: 'some/replace/path',
};
const DEFAULT_INJECT = {
targetBranch: 'master',
originalBranch: 'master',
canPushCode: true,
replacePath: 'some/replace/path',
};
describe('BlobReplace component', () => {
......@@ -49,8 +49,8 @@ describe('BlobReplace component', () => {
it('renders UploadBlobModal', () => {
createComponent();
const { targetBranch, originalBranch, canPushCode, replacePath } = DEFAULT_INJECT;
const { name, path } = DEFAULT_PROPS;
const { targetBranch, originalBranch } = DEFAULT_INJECT;
const { name, path, canPushCode, replacePath } = DEFAULT_PROPS;
const title = `Replace ${name}`;
expect(findUploadBlobModal().props()).toMatchObject({
......
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