summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2019-01-10 15:22:28 -0600
committerFatih Acet <acetfatih@gmail.com>2019-01-30 23:18:13 +0100
commit83306d249e0762d21b9ca128b9ebb57a0bef6f8b (patch)
treeb2cd7dc17355ce61ac8eff4ae4f7abe0797ac7d7
parentf1acd5051513ee815578f7311ca88ee54e79e323 (diff)
downloadgitlab-ce-83306d249e0762d21b9ca128b9ebb57a0bef6f8b.tar.gz
Pass tasklist lock version
receive data on when there is a conflict
-rw-r--r--app/assets/javascripts/issue_show/components/app.vue1
-rw-r--r--app/assets/javascripts/issue_show/components/description.vue10
-rw-r--r--app/assets/javascripts/task_list.js4
-rw-r--r--app/controllers/concerns/issuable_actions.rb5
4 files changed, 18 insertions, 2 deletions
diff --git a/app/assets/javascripts/issue_show/components/app.vue b/app/assets/javascripts/issue_show/components/app.vue
index d65b44ca6f3..3e71c40e896 100644
--- a/app/assets/javascripts/issue_show/components/app.vue
+++ b/app/assets/javascripts/issue_show/components/app.vue
@@ -326,6 +326,7 @@ export default {
:task-status="state.taskStatus"
:issuable-type="issuableType"
:update-url="updateEndpoint"
+ :lock-version="state.lock_version"
/>
<edited-component
v-if="hasUpdated"
diff --git a/app/assets/javascripts/issue_show/components/description.vue b/app/assets/javascripts/issue_show/components/description.vue
index 5ca88d75063..4443d6c6760 100644
--- a/app/assets/javascripts/issue_show/components/description.vue
+++ b/app/assets/javascripts/issue_show/components/description.vue
@@ -35,6 +35,10 @@ export default {
required: false,
default: null,
},
+ lockVersion: {
+ type: Number,
+ required: false,
+ },
},
data() {
return {
@@ -67,8 +71,10 @@ export default {
new TaskList({
dataType: this.issuableType,
fieldName: 'description',
+ lockVersion: this.lockVersion,
selector: '.detail-page-description',
onSuccess: this.taskListUpdateSuccess.bind(this),
+ onError: this.taskListUpdateError.bind(this),
});
}
},
@@ -82,6 +88,10 @@ export default {
}
},
+ taskListUpdateError(data) {
+ // stub for error handling
+ },
+
updateTaskStatusText() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/);
const $issuableHeader = $('.issuable-meta');
diff --git a/app/assets/javascripts/task_list.js b/app/assets/javascripts/task_list.js
index edefb3735d7..f063250c36f 100644
--- a/app/assets/javascripts/task_list.js
+++ b/app/assets/javascripts/task_list.js
@@ -8,8 +8,9 @@ export default class TaskList {
this.selector = options.selector;
this.dataType = options.dataType;
this.fieldName = options.fieldName;
+ this.lockVersion = options.lockVersion;
this.onSuccess = options.onSuccess || (() => {});
- this.onError = function showFlash(e) {
+ this.onError = options.onError || function showFlash(e) {
let errorMessages = '';
if (e.response.data && typeof e.response.data === 'object') {
@@ -43,6 +44,7 @@ export default class TaskList {
const patchData = {};
patchData[this.dataType] = {
[this.fieldName]: $target.val(),
+ ['lock_version']: this.lockVersion,
};
return axios
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index 8ef3b6502df..f0b4198b2d9 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -162,10 +162,13 @@ module IssuableActions
end
format.json do
+ # We want to pass back the latest valid data, so reload the model
+ @issuable.reload
render json: {
errors: [
"Someone edited this #{issuable.human_class_name} at the same time you did. Please refresh your browser and make sure your changes will not unintentionally remove theirs."
- ]
+ ],
+ data: serializer.represent(@issuable)
}, status: :conflict
end
end