debian-mirror-gitlab/app/assets/javascripts/projects/compare/components/app.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

144 lines
3.9 KiB
Vue
Raw Normal View History

2021-03-11 19:13:27 +05:30
<script>
import { GlButton } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
2021-06-08 01:23:25 +05:30
import { joinPaths } from '~/lib/utils/url_utility';
2021-04-17 20:07:23 +05:30
import RevisionCard from './revision_card.vue';
2021-03-11 19:13:27 +05:30
export default {
csrf,
components: {
2021-04-17 20:07:23 +05:30
RevisionCard,
2021-03-11 19:13:27 +05:30
GlButton,
},
props: {
projectCompareIndexPath: {
type: String,
required: true,
},
refsProjectPath: {
type: String,
required: true,
},
paramsFrom: {
type: String,
required: false,
default: null,
},
paramsTo: {
type: String,
required: false,
default: null,
},
projectMergeRequestPath: {
type: String,
required: true,
},
createMrPath: {
type: String,
required: true,
},
2021-06-08 01:23:25 +05:30
defaultProject: {
type: Object,
required: true,
},
projects: {
type: Array,
required: true,
},
},
data() {
return {
from: {
projects: this.projects,
selectedProject: this.defaultProject,
revision: this.paramsFrom,
refsProjectPath: this.refsProjectPath,
},
to: {
selectedProject: this.defaultProject,
revision: this.paramsTo,
refsProjectPath: this.refsProjectPath,
},
};
2021-03-11 19:13:27 +05:30
},
methods: {
onSubmit() {
this.$refs.form.submit();
},
2021-06-08 01:23:25 +05:30
onSelectProject({ direction, project }) {
const refsPath = joinPaths(gon.relative_url_root || '', `/${project.name}`, '/refs');
// direction is either 'from' or 'to'
this[direction].refsProjectPath = refsPath;
this[direction].selectedProject = project;
},
onSelectRevision({ direction, revision }) {
this[direction].revision = revision; // direction is either 'from' or 'to'
},
onSwapRevision() {
[this.from, this.to] = [this.to, this.from]; // swaps 'from' and 'to'
},
2021-03-11 19:13:27 +05:30
},
};
</script>
<template>
<form
ref="form"
2021-04-17 20:07:23 +05:30
class="js-requires-input js-signature-container"
2021-03-11 19:13:27 +05:30
method="POST"
:action="projectCompareIndexPath"
>
<input :value="$options.csrf.token" type="hidden" name="authenticity_token" />
2021-04-17 20:07:23 +05:30
<div
class="gl-lg-flex-direction-row gl-lg-display-flex gl-align-items-center compare-revision-cards"
2021-03-11 19:13:27 +05:30
>
2021-04-17 20:07:23 +05:30
<revision-card
2021-06-08 01:23:25 +05:30
data-testid="sourceRevisionCard"
:refs-project-path="to.refsProjectPath"
2021-04-17 20:07:23 +05:30
revision-text="Source"
params-name="to"
2021-06-08 01:23:25 +05:30
:params-branch="to.revision"
:projects="to.projects"
:selected-project="to.selectedProject"
@selectProject="onSelectProject"
@selectRevision="onSelectRevision"
2021-04-17 20:07:23 +05:30
/>
<div
2022-07-23 23:45:48 +05:30
class="compare-ellipsis gl-display-flex gl-justify-content-center gl-align-items-center gl-align-self-end gl-my-4 gl-md-my-0"
2021-04-17 20:07:23 +05:30
data-testid="ellipsis"
>
...
</div>
<revision-card
2021-06-08 01:23:25 +05:30
data-testid="targetRevisionCard"
:refs-project-path="from.refsProjectPath"
2021-04-17 20:07:23 +05:30
revision-text="Target"
params-name="from"
2021-06-08 01:23:25 +05:30
:params-branch="from.revision"
:projects="from.projects"
:selected-project="from.selectedProject"
@selectProject="onSelectProject"
@selectRevision="onSelectRevision"
2021-04-17 20:07:23 +05:30
/>
</div>
2022-08-13 15:12:31 +05:30
<div class="gl-display-flex gl-mt-6 gl-gap-3">
2021-10-27 15:23:28 +05:30
<gl-button category="primary" variant="confirm" @click="onSubmit">
2021-04-17 20:07:23 +05:30
{{ s__('CompareRevisions|Compare') }}
</gl-button>
2022-08-13 15:12:31 +05:30
<gl-button data-testid="swapRevisionsButton" @click="onSwapRevision">
2021-06-08 01:23:25 +05:30
{{ s__('CompareRevisions|Swap revisions') }}
</gl-button>
2021-04-17 20:07:23 +05:30
<gl-button
v-if="projectMergeRequestPath"
:href="projectMergeRequestPath"
data-testid="projectMrButton"
>
{{ s__('CompareRevisions|View open merge request') }}
</gl-button>
2022-08-13 15:12:31 +05:30
<gl-button v-else-if="createMrPath" :href="createMrPath" data-testid="createMrButton">
2021-04-17 20:07:23 +05:30
{{ s__('CompareRevisions|Create merge request') }}
</gl-button>
</div>
2021-03-11 19:13:27 +05:30
</form>
</template>