Commit 24c84ea6 authored by Himanshu Kapoor's avatar Himanshu Kapoor

Remove stage_button and unstage_button

Remove dead code in stage_button and unstage_button and the files
where these components are used
parent 77a84ebe
...@@ -41,10 +41,6 @@ export default { ...@@ -41,10 +41,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
itemActionComponent: {
type: String,
required: true,
},
stagedList: { stagedList: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -142,7 +138,6 @@ export default { ...@@ -142,7 +138,6 @@ export default {
<li v-for="file in fileList" :key="file.key"> <li v-for="file in fileList" :key="file.key">
<list-item <list-item
:file="file" :file="file"
:action-component="itemActionComponent"
:key-prefix="keyPrefix" :key-prefix="keyPrefix"
:staged-list="stagedList" :staged-list="stagedList"
:active-file-key="activeFileKey" :active-file-key="activeFileKey"
......
...@@ -19,10 +19,6 @@ export default { ...@@ -19,10 +19,6 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
actionComponent: {
type: String,
required: true,
},
keyPrefix: { keyPrefix: {
type: String, type: String,
required: false, required: false,
......
<script>
import $ from 'jquery';
import { mapActions } from 'vuex';
import { sprintf, __ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
export default {
components: {
Icon,
GlModal: DeprecatedModal2,
},
directives: {
tooltip,
},
props: {
path: {
type: String,
required: true,
},
},
computed: {
modalId() {
return `discard-file-${this.path}`;
},
modalTitle() {
return sprintf(__('Discard changes to %{path}?'), { path: this.path });
},
},
methods: {
...mapActions(['stageChange', 'discardFileChanges']),
showDiscardModal() {
$(document.getElementById(this.modalId)).modal('show');
},
},
};
</script>
<template>
<div v-once class="multi-file-discard-btn d-flex">
<button
v-tooltip
:aria-label="__('Stage changes')"
:title="__('Stage changes')"
type="button"
class="btn btn-blank align-items-center"
data-container="body"
data-boundary="viewport"
data-placement="bottom"
@click.stop.prevent="stageChange(path)"
>
<icon :size="16" name="mobile-issue-close" class="ml-auto mr-auto" />
</button>
<button
v-tooltip
:aria-label="__('Discard changes')"
:title="__('Discard changes')"
type="button"
class="btn btn-blank align-items-center"
data-container="body"
data-boundary="viewport"
data-placement="bottom"
@click.stop.prevent="showDiscardModal"
>
<icon :size="16" name="remove" class="ml-auto mr-auto" />
</button>
<gl-modal
:id="modalId"
:header-title-text="modalTitle"
:footer-primary-button-text="__('Discard changes')"
footer-primary-button-variant="danger"
@submit="discardFileChanges(path)"
>
{{ __("You will lose all changes you've made to this file. This action cannot be undone.") }}
</gl-modal>
</div>
</template>
<script>
import { mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
export default {
components: {
Icon,
},
directives: {
tooltip,
},
props: {
path: {
type: String,
required: true,
},
},
methods: {
...mapActions(['unstageChange']),
},
};
</script>
<template>
<div v-once class="multi-file-discard-btn d-flex">
<button
v-tooltip
:aria-label="__('Unstage changes')"
:title="__('Unstage changes')"
type="button"
class="btn btn-blank align-items-center"
data-container="body"
data-boundary="viewport"
data-placement="bottom"
@click.stop.prevent="unstageChange(path)"
>
<icon :size="16" name="redo" class="ml-auto mr-auto" />
</button>
</div>
</template>
...@@ -94,7 +94,6 @@ export default { ...@@ -94,7 +94,6 @@ export default {
:empty-state-text="__('There are no unstaged changes')" :empty-state-text="__('There are no unstaged changes')"
action="stageAllChanges" action="stageAllChanges"
action-btn-icon="stage-all" action-btn-icon="stage-all"
item-action-component="stage-button"
class="is-first" class="is-first"
icon-name="unstaged" icon-name="unstaged"
/> />
...@@ -108,7 +107,6 @@ export default { ...@@ -108,7 +107,6 @@ export default {
:empty-state-text="__('There are no staged changes')" :empty-state-text="__('There are no staged changes')"
action="unstageAllChanges" action="unstageAllChanges"
action-btn-icon="unstage-all" action-btn-icon="unstage-all"
item-action-component="unstage-button"
icon-name="staged" icon-name="staged"
/> />
</template> </template>
......
...@@ -17338,9 +17338,6 @@ msgstr "" ...@@ -17338,9 +17338,6 @@ msgstr ""
msgid "Stage all changes" msgid "Stage all changes"
msgstr "" msgstr ""
msgid "Stage changes"
msgstr ""
msgid "Stage data updated" msgid "Stage data updated"
msgstr "" msgstr ""
...@@ -19698,9 +19695,6 @@ msgstr "" ...@@ -19698,9 +19695,6 @@ msgstr ""
msgid "Unstage all changes" msgid "Unstage all changes"
msgstr "" msgstr ""
msgid "Unstage changes"
msgstr ""
msgid "Unstaged" msgid "Unstaged"
msgstr "" msgstr ""
......
import Vue from 'vue';
import store from '~/ide/stores';
import stageButton from '~/ide/components/commit_sidebar/stage_button.vue';
import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper';
import { file, resetStore } from '../../helpers';
describe('IDE stage file button', () => {
let vm;
let f;
beforeEach(() => {
const Component = Vue.extend(stageButton);
f = file();
vm = createComponentWithStore(Component, store, {
path: f.path,
});
jest.spyOn(vm, 'stageChange').mockImplementation(() => {});
jest.spyOn(vm, 'discardFileChanges').mockImplementation(() => {});
vm.$mount();
});
afterEach(() => {
vm.$destroy();
resetStore(vm.$store);
});
it('renders button to discard & stage', () => {
expect(vm.$el.querySelectorAll('.btn-blank').length).toBe(2);
});
it('calls store with stage button', () => {
vm.$el.querySelectorAll('.btn')[0].click();
expect(vm.stageChange).toHaveBeenCalledWith(f.path);
});
it('calls store with discard button', () => {
vm.$el.querySelector('.btn-danger').click();
expect(vm.discardFileChanges).toHaveBeenCalledWith(f.path);
});
});
import Vue from 'vue';
import store from '~/ide/stores';
import unstageButton from '~/ide/components/commit_sidebar/unstage_button.vue';
import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper';
import { file, resetStore } from '../../helpers';
describe('IDE unstage file button', () => {
let vm;
let f;
beforeEach(() => {
const Component = Vue.extend(unstageButton);
f = file();
vm = createComponentWithStore(Component, store, {
path: f.path,
});
jest.spyOn(vm, 'unstageChange').mockImplementation(() => {});
vm.$mount();
});
afterEach(() => {
vm.$destroy();
resetStore(vm.$store);
});
it('renders button to unstage', () => {
expect(vm.$el.querySelectorAll('.btn').length).toBe(1);
});
it('calls store with unnstage button', () => {
vm.$el.querySelector('.btn').click();
expect(vm.unstageChange).toHaveBeenCalledWith(f.path);
});
});
...@@ -20,7 +20,6 @@ describe('Multi-file editor commit sidebar list item', () => { ...@@ -20,7 +20,6 @@ describe('Multi-file editor commit sidebar list item', () => {
vm = createComponentWithStore(Component, store, { vm = createComponentWithStore(Component, store, {
file: f, file: f,
actionComponent: 'stage-button',
activeFileKey: `staged-${f.key}`, activeFileKey: `staged-${f.key}`,
}).$mount(); }).$mount();
......
...@@ -17,7 +17,6 @@ describe('Multi-file editor commit sidebar list', () => { ...@@ -17,7 +17,6 @@ describe('Multi-file editor commit sidebar list', () => {
action: 'stageAllChanges', action: 'stageAllChanges',
actionBtnText: 'stage all', actionBtnText: 'stage all',
actionBtnIcon: 'history', actionBtnIcon: 'history',
itemActionComponent: 'stage-button',
activeFileKey: 'staged-testing', activeFileKey: 'staged-testing',
keyPrefix: 'staged', keyPrefix: 'staged',
}); });
......
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