Commit 8a3e6935 authored by David O'Regan's avatar David O'Regan

Merge branch '218529-change-image-upload-path' into 'master'

Update image upload path

See merge request gitlab-org/gitlab!46967
parents 4c839b62 b64abada
...@@ -6,7 +6,6 @@ import EditDrawer from './edit_drawer.vue'; ...@@ -6,7 +6,6 @@ import EditDrawer from './edit_drawer.vue';
import UnsavedChangesConfirmDialog from './unsaved_changes_confirm_dialog.vue'; import UnsavedChangesConfirmDialog from './unsaved_changes_confirm_dialog.vue';
import parseSourceFile from '~/static_site_editor/services/parse_source_file'; import parseSourceFile from '~/static_site_editor/services/parse_source_file';
import { EDITOR_TYPES } from '~/vue_shared/components/rich_content_editor/constants'; import { EDITOR_TYPES } from '~/vue_shared/components/rich_content_editor/constants';
import { DEFAULT_IMAGE_UPLOAD_PATH } from '../constants';
import imageRepository from '../image_repository'; import imageRepository from '../image_repository';
import formatter from '../services/formatter'; import formatter from '../services/formatter';
import templater from '../services/templater'; import templater from '../services/templater';
...@@ -48,9 +47,7 @@ export default { ...@@ -48,9 +47,7 @@ export default {
}, },
imageRoot: { imageRoot: {
type: String, type: String,
required: false, required: true,
default: DEFAULT_IMAGE_UPLOAD_PATH,
validator: prop => prop.endsWith('/'),
}, },
}, },
data() { data() {
......
...@@ -20,6 +20,4 @@ export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit'; ...@@ -20,6 +20,4 @@ export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit';
export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request'; export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request';
export const TRACKING_ACTION_INITIALIZE_EDITOR = 'initialize_editor'; export const TRACKING_ACTION_INITIALIZE_EDITOR = 'initialize_editor';
export const DEFAULT_IMAGE_UPLOAD_PATH = 'source/images/uploads/';
export const MR_META_LOCAL_STORAGE_KEY = 'sse-merge-request-meta-storage-key'; export const MR_META_LOCAL_STORAGE_KEY = 'sse-merge-request-meta-storage-key';
...@@ -10,5 +10,6 @@ query appData { ...@@ -10,5 +10,6 @@ query appData {
source source
target target
} }
imageUploadPath
} }
} }
...@@ -27,6 +27,7 @@ type AppData { ...@@ -27,6 +27,7 @@ type AppData {
sourcePath: String! sourcePath: String!
username: String! username: String!
mounts: [Mount]! mounts: [Mount]!
imageUploadPath: String!
} }
input HasSubmittedChangesInput { input HasSubmittedChangesInput {
......
...@@ -16,7 +16,6 @@ const initStaticSiteEditor = el => { ...@@ -16,7 +16,6 @@ const initStaticSiteEditor = el => {
// so we are adding them here as a convenience for future use. // so we are adding them here as a convenience for future use.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
staticSiteGenerator, staticSiteGenerator,
// eslint-disable-next-line no-unused-vars
imageUploadPath, imageUploadPath,
mounts, mounts,
} = el.dataset; } = el.dataset;
...@@ -31,6 +30,7 @@ const initStaticSiteEditor = el => { ...@@ -31,6 +30,7 @@ const initStaticSiteEditor = el => {
returnUrl, returnUrl,
sourcePath, sourcePath,
username, username,
imageUploadPath,
}); });
return new Vue({ return new Vue({
......
...@@ -140,6 +140,7 @@ export default { ...@@ -140,6 +140,7 @@ export default {
:return-url="appData.returnUrl" :return-url="appData.returnUrl"
:mounts="appData.mounts" :mounts="appData.mounts"
:project="appData.project" :project="appData.project"
:image-root="appData.imageUploadPath"
@submit="onPrepareSubmit" @submit="onPrepareSubmit"
/> />
<edit-meta-modal <edit-meta-modal
......
<script> <script>
import { GlModal, GlFormGroup, GlFormInput, GlTabs, GlTab } from '@gitlab/ui'; import { GlModal, GlFormGroup, GlFormInput, GlTabs, GlTab } from '@gitlab/ui';
import { isSafeURL } from '~/lib/utils/url_utility'; import { isSafeURL, joinPaths } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { IMAGE_TABS } from '../../constants'; import { IMAGE_TABS } from '../../constants';
...@@ -74,7 +74,7 @@ export default { ...@@ -74,7 +74,7 @@ export default {
return; return;
} }
const imageUrl = `${this.imageRoot}${file.name}`; const imageUrl = joinPaths(this.imageRoot, file.name);
this.$emit('addImage', { imageUrl, file, altText: altText || file.name }); this.$emit('addImage', { imageUrl, file, altText: altText || file.name });
}, },
......
...@@ -53,7 +53,6 @@ export default { ...@@ -53,7 +53,6 @@ export default {
imageRoot: { imageRoot: {
type: String, type: String,
required: true, required: true,
validator: prop => prop.endsWith('/'),
}, },
}, },
data() { data() {
......
---
title: Update image upload path (SSE)
merge_request: 46967
author:
type: changed
...@@ -17,6 +17,7 @@ import { ...@@ -17,6 +17,7 @@ import {
returnUrl, returnUrl,
mounts, mounts,
project, project,
imageRoot,
} from '../mock_data'; } from '../mock_data';
jest.mock('~/static_site_editor/services/formatter', () => jest.fn(str => `${str} format-pass`)); jest.mock('~/static_site_editor/services/formatter', () => jest.fn(str => `${str} format-pass`));
...@@ -35,6 +36,7 @@ describe('~/static_site_editor/components/edit_area.vue', () => { ...@@ -35,6 +36,7 @@ describe('~/static_site_editor/components/edit_area.vue', () => {
returnUrl, returnUrl,
mounts, mounts,
project, project,
imageRoot,
savingChanges, savingChanges,
...propsData, ...propsData,
}, },
......
...@@ -79,3 +79,5 @@ export const mounts = [ ...@@ -79,3 +79,5 @@ export const mounts = [
target: '', target: '',
}, },
]; ];
export const imageRoot = 'source/images/';
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
trackingCategory, trackingCategory,
images, images,
mounts, mounts,
imageRoot,
} from '../mock_data'; } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -43,6 +44,7 @@ describe('static_site_editor/pages/home', () => { ...@@ -43,6 +44,7 @@ describe('static_site_editor/pages/home', () => {
username, username,
sourcePath, sourcePath,
mounts, mounts,
imageUploadPath: imageRoot,
}; };
const hasSubmittedChangesMutationPayload = { const hasSubmittedChangesMutationPayload = {
data: { data: {
......
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