Commit d655d138 authored by Clement Ho's avatar Clement Ho

Pass updateEndpoint from backend

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