Commit c2295fbd authored by Fatih Acet's avatar Fatih Acet

Render right sidebar and handle request error.

parent 261d47bc
...@@ -8,6 +8,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -8,6 +8,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
return { return {
isLoading : true, isLoading : true,
hasError : false,
isParallel : diffViewType === 'parallel', isParallel : diffViewType === 'parallel',
diffViewType : diffViewType, diffViewType : diffViewType,
conflictsData : {}, conflictsData : {},
...@@ -18,12 +19,19 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -18,12 +19,19 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
decorateData(vueInstance, data) { decorateData(vueInstance, data) {
this.vueInstance = vueInstance; this.vueInstance = vueInstance;
data.shortCommitSha = data.commit_sha.slice(0, 7);
data.commitMesage = data.commit_message;
this.setParallelLines(data); if (data.type === 'error') {
this.setInlineLines(data); vueInstance.hasError = true;
this.updateResolutionsData(data); data.errorMessage = data.message;
}
else {
data.shortCommitSha = data.commit_sha.slice(0, 7);
data.commitMesage = data.commit_message;
this.setParallelLines(data);
this.setInlineLines(data);
this.updateResolutionsData(data);
}
vueInstance.conflictsData = data; vueInstance.conflictsData = data;
} }
...@@ -166,7 +174,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -166,7 +174,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
vi.diffView = newType; vi.diffView = newType;
vi.isParallel = newType === 'parallel'; vi.isParallel = newType === 'parallel';
$.cookie('diff_view', newType); // TODO: Make sure that cookie path added. $.cookie('diff_view', newType); // TODO: Make sure that cookie path added.
$('.container-fluid').toggleClass('container-limited'); $('.content-wrapper .container-fluid').toggleClass('container-limited');
} }
...@@ -270,4 +278,10 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -270,4 +278,10 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
} }
} }
handleFailedRequest(vueInstance, data) {
vueInstance.hasError = true;
vueInstance.conflictsData.errorMessage = 'Something went wrong!';
}
} }
...@@ -29,10 +29,18 @@ window.MergeConflictResolver = class MergeConflictResolver { ...@@ -29,10 +29,18 @@ window.MergeConflictResolver = class MergeConflictResolver {
fetchData() { fetchData() {
$.get('./conflicts.json').done( (data) => { const dp = this.dataProvider;
this.dataProvider.decorateData(this.vue, data);
this.vue.isLoading = false; $.get('./conflicts.json')
}) .done( (data) => {
dp.decorateData(this.vue, data);
})
.error( (data) => {
dp.handleFailedRequest(this.vue, data);
})
.always( () => {
this.vue.isLoading = false;
})
} }
......
...@@ -141,7 +141,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -141,7 +141,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
begin begin
render json: Gitlab::Conflict::FileCollection.new(@merge_request) render json: Gitlab::Conflict::FileCollection.new(@merge_request)
rescue Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing => e rescue Gitlab::Conflict::Parser::ParserError, Gitlab::Conflict::FileCollection::ConflictSideMissing => e
render json: { message: 'Unable to resolve conflicts in the web interface for this merge request' } render json: {
message: 'Unable to resolve conflicts in the web interface for this merge request',
type: 'error'
}
end end
end end
end end
......
...@@ -2,14 +2,19 @@ ...@@ -2,14 +2,19 @@
= render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/mr_title"
.merge-request-details.issuable-details{data: {id: @merge_request.project.id}} .merge-request-details.issuable-details
= render "projects/merge_requests/show/mr_box" = render "projects/merge_requests/show/mr_box"
= render 'shared/issuable/sidebar', issuable: @merge_request
#conflicts #conflicts
.loading{ "v-if" => "isLoading" } .loading{"v-if" => "isLoading"}
%i.fa.fa-spinner.fa-spin %i.fa.fa-spinner.fa-spin
.content-block.oneline-block.files-changed{ "v-if" => "!isLoading" } .content-block.oneline-block{"v-if" => "hasError"}
%p {{conflictsData.errorMessage}}
.content-block.oneline-block.files-changed{"v-if" => "!isLoading && !hasError"}
.inline-parallel-buttons .inline-parallel-buttons
.btn-group .btn-group
%a.btn{ | %a.btn{ |
...@@ -30,7 +35,7 @@ ...@@ -30,7 +35,7 @@
into into
%strong {{conflictsData.target_branch}} %strong {{conflictsData.target_branch}}
.files-wrapper{ "v-if" => "!isLoading" } .files-wrapper{"v-if" => "!isLoading && !hasError"}
.files{"v-if" => "isParallel"} .files{"v-if" => "isParallel"}
.diff-file.file-holder.conflict.parallel-view{"v-for" => "file in conflictsData.files"} .diff-file.file-holder.conflict.parallel-view{"v-for" => "file in conflictsData.files"}
.file-title .file-title
......
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