Commit d655d138 authored by Clement Ho's avatar Clement Ho

Pass updateEndpoint from backend

parent 02884c87
......@@ -16,6 +16,10 @@ export default {
required: true,
type: String,
},
updateEndpoint: {
required: true,
type: String,
},
canUpdate: {
required: true,
type: Boolean,
......@@ -133,9 +137,6 @@ export default {
hasUpdated() {
return !!this.state.updatedAt;
},
updateUrl() {
return `${this.endpoint}.json`;
},
},
components: {
descriptionComponent,
......@@ -260,7 +261,7 @@ export default {
:updated-at="state.updatedAt"
:task-status="state.taskStatus"
:issuable-type="issuableType"
:update-url="updateUrl"
:update-url="updateEndpoint"
/>
<edited-component
v-if="hasUpdated"
......
......@@ -213,6 +213,7 @@ module IssuablesHelper
def issuable_initial_data(issuable)
data = {
endpoint: issuable_path(issuable),
updateEndpoint: "#{issuable_path(issuable)}.json",
canUpdate: can?(current_user, :"update_#{issuable.to_ability_name}", issuable),
canDestroy: can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable),
canAdmin: can?(current_user, :"admin_#{issuable.to_ability_name}", issuable),
......
......@@ -12,6 +12,10 @@
type: String,
required: true,
},
updateEndpoint: {
type: String,
required: true,
},
canUpdate: {
required: true,
type: Boolean,
......@@ -111,6 +115,7 @@
:can-update="canUpdate"
:can-destroy="canDestroy"
:endpoint="endpoint"
:update-endpoint="updateEndpoint"
:issuable-ref="issuableRef"
issuable-type="epic"
:initial-title-html="initialTitleHtml"
......
......@@ -34,6 +34,7 @@ describe('EpicShowApp', () => {
canUpdate,
canDestroy,
endpoint,
updateEndpoint,
initialTitleHtml,
initialTitleText,
startDate,
......@@ -59,6 +60,7 @@ describe('EpicShowApp', () => {
canUpdate,
canDestroy,
endpoint,
updateEndpoint,
issuableRef: '',
initialTitleHtml,
initialTitleText,
......
export const contentProps = {
endpoint: '',
updateEndpoint: gl.TEST_HOST,
canAdmin: true,
canUpdate: true,
canDestroy: true,
......
......@@ -35,6 +35,7 @@ describe('Issuable output', () => {
canUpdate: true,
canDestroy: true,
endpoint: '/gitlab-org/gitlab-shell/issues/9/realtime_changes',
updateEndpoint: gl.TEST_HOST,
issuableRef: '#1',
initialTitleHtml: '',
initialTitleText: '',
......@@ -366,15 +367,4 @@ describe('Issuable output', () => {
expect(vm.$el.querySelector('.title-container .note-action-button')).toBeDefined();
});
});
describe('update url', () => {
it('sets update url in description textarea', (done) => {
vm.showForm = true;
vm.canUpdate = false;
Vue.nextTick(() => {
expect(vm.$el.querySelector('.js-task-list-field').dataset.updateUrl).toEqual(`${vm.endpoint}.json`);
done();
});
});
});
});
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