Commit fd058a92 authored by Lukas 'Eipi' Eipert's avatar Lukas 'Eipi' Eipert Committed by Nicolò Maria Mezzopera

Improve template of conflicts app

parent 94c22179
<script> <script>
import { GlButton } from '@gitlab/ui';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
...@@ -7,6 +8,9 @@ import { __ } from '~/locale'; ...@@ -7,6 +8,9 @@ import { __ } from '~/locale';
import { INTERACTIVE_RESOLVE_MODE } from '../constants'; import { INTERACTIVE_RESOLVE_MODE } from '../constants';
export default { export default {
components: {
GlButton,
},
props: { props: {
file: { file: {
type: Object, type: Object,
...@@ -100,21 +104,21 @@ export default { ...@@ -100,21 +104,21 @@ export default {
}; };
</script> </script>
<template> <template>
<div v-show="file.showEditor" class="diff-editor-wrap"> <div v-show="file.showEditor">
<div v-if="file.promptDiscardConfirmation" class="discard-changes-alert-wrap"> <div v-if="file.promptDiscardConfirmation" class="discard-changes-alert">
<div class="discard-changes-alert"> {{ __('Are you sure you want to discard your changes?') }}
{{ __('Are you sure you want to discard your changes?') }} <div class="gl-ml-3 gl-display-inline-block">
<div class="discard-actions"> <gl-button
<button size="small"
class="btn btn-sm btn-danger-secondary gl-button" variant="danger"
@click="acceptDiscardConfirmation(file)" category="secondary"
> @click="acceptDiscardConfirmation(file)"
{{ __('Discard changes') }} >
</button> {{ __('Discard changes') }}
<button class="btn btn-default btn-sm gl-button" @click="cancelDiscardConfirmation(file)"> </gl-button>
{{ __('Cancel') }} <gl-button size="small" @click="cancelDiscardConfirmation(file)">
</button> {{ __('Cancel') }}
</div> </gl-button>
</div> </div>
</div> </div>
<div :class="classObject" class="editor-wrap"> <div :class="classObject" class="editor-wrap">
......
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
<td :class="lineCssClass(line)" class="diff-line-num header"></td> <td :class="lineCssClass(line)" class="diff-line-num header"></td>
<td :class="lineCssClass(line)" class="line_content header"> <td :class="lineCssClass(line)" class="line_content header">
<strong>{{ line.richText }}</strong> <strong>{{ line.richText }}</strong>
<button class="btn" @click="handleSelected({ file, line })"> <button type="button" @click="handleSelected({ file, line })">
{{ line.buttonTitle }} {{ line.buttonTitle }}
</button> </button>
</td> </td>
......
...@@ -35,7 +35,7 @@ export default { ...@@ -35,7 +35,7 @@ export default {
<td class="diff-line-num header" :class="lineCssClass(line)"></td> <td class="diff-line-num header" :class="lineCssClass(line)"></td>
<td class="line_content header" :class="lineCssClass(line)"> <td class="line_content header" :class="lineCssClass(line)">
<strong>{{ line.richText }}</strong> <strong>{{ line.richText }}</strong>
<button class="btn" @click="handleSelected({ file, line })"> <button type="button" @click="handleSelected({ file, line })">
{{ line.buttonTitle }} {{ line.buttonTitle }}
</button> </button>
</td> </td>
......
<script> <script>
import { GlSprintf } from '@gitlab/ui'; import { GlSprintf, GlButton, GlButtonGroup } from '@gitlab/ui';
import { mapGetters, mapState, mapActions } from 'vuex'; import { mapGetters, mapState, mapActions } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
...@@ -20,6 +20,8 @@ import { INTERACTIVE_RESOLVE_MODE } from './constants'; ...@@ -20,6 +20,8 @@ import { INTERACTIVE_RESOLVE_MODE } from './constants';
*/ */
export default { export default {
components: { components: {
GlButton,
GlButtonGroup,
GlSprintf, GlSprintf,
FileIcon, FileIcon,
DiffFileEditor, DiffFileEditor,
...@@ -77,28 +79,23 @@ export default { ...@@ -77,28 +79,23 @@ export default {
{{ conflictsData.errorMessage }} {{ conflictsData.errorMessage }}
</div> </div>
<template v-if="!isLoading && !hasError"> <template v-if="!isLoading && !hasError">
<div class="content-block oneline-block files-changed"> <div class="gl-border-b-0 gl-py-5 gl-line-height-32">
<div v-if="fileTextTypePresent" class="inline-parallel-buttons"> <div v-if="fileTextTypePresent" class="gl-float-right">
<div class="btn-group"> <gl-button-group>
<button <gl-button :selected="!isParallel" @click="setViewType('inline')">
:class="{ active: !isParallel }"
class="btn gl-button"
@click="setViewType('inline')"
>
{{ __('Inline') }} {{ __('Inline') }}
</button> </gl-button>
<button <gl-button
:class="{ active: isParallel }" :selected="isParallel"
class="btn gl-button"
data-testid="side-by-side" data-testid="side-by-side"
@click="setViewType('parallel')" @click="setViewType('parallel')"
> >
{{ __('Side-by-side') }} {{ __('Side-by-side') }}
</button> </gl-button>
</div> </gl-button-group>
</div> </div>
<div class="js-toggle-container"> <div class="js-toggle-container">
<div class="commit-stat-summary" data-testid="conflicts-count"> <div data-testid="conflicts-count">
<gl-sprintf :message="$options.i18n.commitStatSummary"> <gl-sprintf :message="$options.i18n.commitStatSummary">
<template #conflict> <template #conflict>
<strong class="cred">{{ getConflictsCountText }}</strong> <strong class="cred">{{ getConflictsCountText }}</strong>
...@@ -127,47 +124,43 @@ export default { ...@@ -127,47 +124,43 @@ export default {
<strong class="file-title-name">{{ file.filePath }}</strong> <strong class="file-title-name">{{ file.filePath }}</strong>
</div> </div>
<div class="file-actions d-flex align-items-center gl-ml-auto gl-align-self-start"> <div class="file-actions d-flex align-items-center gl-ml-auto gl-align-self-start">
<div v-if="file.type === 'text'" class="btn-group gl-mr-3"> <gl-button-group v-if="file.type === 'text'" class="gl-mr-3">
<button <gl-button
:class="{ active: file.resolveMode === 'interactive' }" :selected="file.resolveMode === 'interactive'"
class="btn gl-button"
type="button"
data-testid="interactive-button" data-testid="interactive-button"
@click="onClickResolveModeButton(file, 'interactive')" @click="onClickResolveModeButton(file, 'interactive')"
> >
{{ __('Interactive mode') }} {{ __('Interactive mode') }}
</button> </gl-button>
<button <gl-button
:class="{ active: file.resolveMode === 'edit' }" :selected="file.resolveMode === 'edit'"
class="btn gl-button"
type="button"
data-testid="inline-button" data-testid="inline-button"
@click="onClickResolveModeButton(file, 'edit')" @click="onClickResolveModeButton(file, 'edit')"
> >
{{ __('Edit inline') }} {{ __('Edit inline') }}
</button> </gl-button>
</div> </gl-button-group>
<a :href="file.blobPath" class="btn gl-button view-file"> <gl-button :href="file.blobPath">
<gl-sprintf :message="__('View file @ %{commitSha}')"> <gl-sprintf :message="__('View file @ %{commitSha}')">
<template #commitSha> <template #commitSha>
{{ conflictsData.shortCommitSha }} {{ conflictsData.shortCommitSha }}
</template> </template>
</gl-sprintf> </gl-sprintf>
</a> </gl-button>
</div> </div>
</div> </div>
<div class="diff-content diff-wrap-lines"> <div class="diff-content diff-wrap-lines">
<template v-if="file.resolveMode === 'interactive' && file.type === 'text'"> <div
<div v-if="!isParallel" class="file-content"> v-if="file.resolveMode === 'interactive' && file.type === 'text'"
<inline-conflict-lines :file="file" /> class="file-content"
</div> >
<div v-if="isParallel" class="file-content"> <parallel-conflict-lines v-if="isParallel" :file="file" />
<parallel-conflict-lines :file="file" /> <inline-conflict-lines v-else :file="file" />
</div>
</template>
<div v-if="file.resolveMode === 'edit' || file.type === 'text-editor'">
<diff-file-editor :file="file" />
</div> </div>
<diff-file-editor
v-if="file.resolveMode === 'edit' || file.type === 'text-editor'"
:file="file"
/>
</div> </div>
</div> </div>
</div> </div>
...@@ -176,10 +169,10 @@ export default { ...@@ -176,10 +169,10 @@ export default {
<div class="resolve-conflicts-form"> <div class="resolve-conflicts-form">
<div class="form-group row"> <div class="form-group row">
<div class="col-md-4"> <div class="col-md-4">
<h4> <h4 class="gl-mt-0">
{{ __('Resolve conflicts on source branch') }} {{ __('Resolve conflicts on source branch') }}
</h4> </h4>
<div class="resolve-info"> <div class="gl-mb-5" data-testid="resolve-info">
<gl-sprintf :message="$options.i18n.resolveInfo"> <gl-sprintf :message="$options.i18n.resolveInfo">
<template #use_ours> <template #use_ours>
<code>{{ s__('MergeConflict|Use ours') }}</code> <code>{{ s__('MergeConflict|Use ours') }}</code>
...@@ -199,7 +192,7 @@ export default { ...@@ -199,7 +192,7 @@ export default {
<label class="label-bold" for="commit-message"> <label class="label-bold" for="commit-message">
{{ __('Commit message') }} {{ __('Commit message') }}
</label> </label>
<div class="commit-message-container"> <div class="commit-message-container gl-mb-4">
<div class="max-width-marker"></div> <div class="max-width-marker"></div>
<textarea <textarea
id="commit-message" id="commit-message"
...@@ -209,27 +202,17 @@ export default { ...@@ -209,27 +202,17 @@ export default {
rows="5" rows="5"
></textarea> ></textarea>
</div> </div>
</div> <gl-button
</div> :disabled="!isReadyToCommit"
<div class="form-group row"> variant="confirm"
<div class="offset-md-4 col-md-8"> class="js-submit-button"
<div class="row"> @click="submitResolvedConflicts(resolveConflictsPath)"
<div class="col-6"> >
<button {{ getCommitButtonText }}
:disabled="!isReadyToCommit" </gl-button>
class="btn gl-button btn-success js-submit-button" <gl-button :href="mergeRequestPath">
type="button" {{ __('Cancel') }}
@click="submitResolvedConflicts(resolveConflictsPath)" </gl-button>
>
<span>{{ getCommitButtonText }}</span>
</button>
</div>
<div class="col-6 text-right">
<a :href="mergeRequestPath" class="gl-button btn btn-default">
{{ __('Cancel') }}
</a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -670,10 +670,6 @@ table.code { ...@@ -670,10 +670,6 @@ table.code {
float: right; float: right;
} }
.files-changed {
border-bottom: 0;
}
.merge-request-details .file-content.image_file img { .merge-request-details .file-content.image_file img {
max-height: 50vh; max-height: 50vh;
} }
......
...@@ -173,22 +173,5 @@ ...@@ -173,22 +173,5 @@
text-align: right; text-align: right;
padding: $gl-padding-top $gl-padding; padding: $gl-padding-top $gl-padding;
color: var(--gl-text-color, $gl-text-color); color: var(--gl-text-color, $gl-text-color);
.discard-actions {
display: inline-block;
margin-left: 10px;
}
}
.resolve-conflicts-form {
h4 {
margin-top: 0;
}
.resolve-info {
@media(max-width: map-get($grid-breakpoints, lg)-1) {
margin-bottom: $gl-padding;
}
}
} }
} }
---
title: Align UI of Merge Conflicts app with our design system
merge_request: 59400
author:
type: other
...@@ -173,7 +173,7 @@ RSpec.describe 'Merge request > User resolves conflicts', :js do ...@@ -173,7 +173,7 @@ RSpec.describe 'Merge request > User resolves conflicts', :js do
end end
it "renders bad name without xss issues" do it "renders bad name without xss issues" do
expect(find('.resolve-conflicts-form .resolve-info')).to have_content(bad_branch_name) expect(find('[data-testid="resolve-info"]')).to have_content(bad_branch_name)
end end
end end
end end
......
...@@ -82,20 +82,20 @@ describe('Merge Conflict Resolver App', () => { ...@@ -82,20 +82,20 @@ describe('Merge Conflict Resolver App', () => {
const interactiveButton = findFileInteractiveButton(findFiles().at(0)); const interactiveButton = findFileInteractiveButton(findFiles().at(0));
const inlineButton = findFileInlineButton(findFiles().at(0)); const inlineButton = findFileInlineButton(findFiles().at(0));
expect(interactiveButton.classes('active')).toBe(true); expect(interactiveButton.props('selected')).toBe(true);
expect(inlineButton.classes('active')).toBe(false); expect(inlineButton.props('selected')).toBe(false);
}); });
it('clicking inline set inline as default', async () => { it('clicking inline set inline as default', async () => {
mountComponent(); mountComponent();
const inlineButton = findFileInlineButton(findFiles().at(0)); const inlineButton = findFileInlineButton(findFiles().at(0));
expect(inlineButton.classes('active')).toBe(false); expect(inlineButton.props('selected')).toBe(false);
inlineButton.trigger('click'); inlineButton.vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(inlineButton.classes('active')).toBe(true); expect(inlineButton.props('selected')).toBe(true);
}); });
it('inline mode shows a inline-conflict-lines', () => { it('inline mode shows a inline-conflict-lines', () => {
...@@ -110,7 +110,7 @@ describe('Merge Conflict Resolver App', () => { ...@@ -110,7 +110,7 @@ describe('Merge Conflict Resolver App', () => {
it('parallel mode shows a parallel-conflict-lines', async () => { it('parallel mode shows a parallel-conflict-lines', async () => {
mountComponent(); mountComponent();
findSideBySideButton().trigger('click'); findSideBySideButton().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
const parallelConflictLinesComponent = findParallelConflictLines(findFiles().at(0)); const parallelConflictLinesComponent = findParallelConflictLines(findFiles().at(0));
......
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