Commit 94f3df64 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'winh-rename-create-item-form' into 'master'

Rename CreateItemForm component to CreateEpicForm in epics tree

See merge request gitlab-org/gitlab!17249
parents c13704b5 44c9b4de
...@@ -33,10 +33,10 @@ export default { ...@@ -33,10 +33,10 @@ export default {
}, },
methods: { methods: {
onFormSubmit() { onFormSubmit() {
this.$emit('createItemFormSubmit', this.inputValue.trim()); this.$emit('createEpicFormSubmit', this.inputValue.trim());
}, },
onFormCancel() { onFormCancel() {
this.$emit('createItemFormCancel'); this.$emit('createEpicFormCancel');
}, },
}, },
}; };
......
...@@ -4,7 +4,7 @@ import { mapState, mapActions, mapGetters } from 'vuex'; ...@@ -4,7 +4,7 @@ import { mapState, mapActions, mapGetters } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import AddItemForm from 'ee/related_issues/components/add_issuable_form.vue'; import AddItemForm from 'ee/related_issues/components/add_issuable_form.vue';
import CreateItemForm from './create_item_form.vue'; import CreateEpicForm from './create_epic_form.vue';
import TreeItemRemoveModal from './tree_item_remove_modal.vue'; import TreeItemRemoveModal from './tree_item_remove_modal.vue';
import RelatedItemsTreeHeader from './related_items_tree_header.vue'; import RelatedItemsTreeHeader from './related_items_tree_header.vue';
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
RelatedItemsTreeHeader, RelatedItemsTreeHeader,
RelatedItemsTreeBody, RelatedItemsTreeBody,
AddItemForm, AddItemForm,
CreateItemForm, CreateEpicForm,
TreeItemRemoveModal, TreeItemRemoveModal,
}, },
computed: { computed: {
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
'itemAddInProgress', 'itemAddInProgress',
'itemCreateInProgress', 'itemCreateInProgress',
'showAddItemForm', 'showAddItemForm',
'showCreateItemForm', 'showCreateEpicForm',
'autoCompleteEpics', 'autoCompleteEpics',
'autoCompleteIssues', 'autoCompleteIssues',
'pendingReferences', 'pendingReferences',
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
...mapActions([ ...mapActions([
'fetchItems', 'fetchItems',
'toggleAddItemForm', 'toggleAddItemForm',
'toggleCreateItemForm', 'toggleCreateEpicForm',
'setPendingReferences', 'setPendingReferences',
'addPendingReferences', 'addPendingReferences',
'removePendingReference', 'removePendingReference',
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
this.addItem(); this.addItem();
} }
}, },
handleCreateItemFormSubmit(newValue) { handleCreateEpicFormSubmit(newValue) {
this.createItem({ this.createItem({
itemTitle: newValue, itemTitle: newValue,
}); });
...@@ -94,8 +94,8 @@ export default { ...@@ -94,8 +94,8 @@ export default {
this.setPendingReferences([]); this.setPendingReferences([]);
this.setItemInputValue(''); this.setItemInputValue('');
}, },
handleCreateItemFormCancel() { handleCreateEpicFormCancel() {
this.toggleCreateItemForm({ toggleState: false, actionType: this.actionType }); this.toggleCreateEpicForm({ toggleState: false, actionType: this.actionType });
this.setItemInputValue(''); this.setItemInputValue('');
}, },
}, },
...@@ -117,7 +117,7 @@ export default { ...@@ -117,7 +117,7 @@ export default {
> >
<related-items-tree-header :class="{ 'border-bottom-0': itemsFetchResultEmpty }" /> <related-items-tree-header :class="{ 'border-bottom-0': itemsFetchResultEmpty }" />
<div <div
v-if="showAddItemForm || showCreateItemForm" v-if="showAddItemForm || showCreateEpicForm"
class="card-body add-item-form-container" class="card-body add-item-form-container"
:class="{ 'border-bottom-0': itemsFetchResultEmpty }" :class="{ 'border-bottom-0': itemsFetchResultEmpty }"
> >
...@@ -135,11 +135,11 @@ export default { ...@@ -135,11 +135,11 @@ export default {
@addIssuableFormSubmit="handleAddItemFormSubmit" @addIssuableFormSubmit="handleAddItemFormSubmit"
@addIssuableFormCancel="handleAddItemFormCancel" @addIssuableFormCancel="handleAddItemFormCancel"
/> />
<create-item-form <create-epic-form
v-if="showCreateItemForm" v-if="showCreateEpicForm"
:is-submitting="itemCreateInProgress" :is-submitting="itemCreateInProgress"
@createItemFormSubmit="handleCreateItemFormSubmit" @createEpicFormSubmit="handleCreateEpicFormSubmit"
@createItemFormCancel="handleCreateItemFormCancel" @createEpicFormCancel="handleCreateEpicFormCancel"
/> />
</div> </div>
<related-items-tree-body <related-items-tree-body
......
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['toggleAddItemForm', 'toggleCreateItemForm']), ...mapActions(['toggleAddItemForm', 'toggleCreateEpicForm']),
handleActionClick({ id, actionType }) { handleActionClick({ id, actionType }) {
if (id === 0) { if (id === 0) {
this.toggleAddItemForm({ this.toggleAddItemForm({
...@@ -40,7 +40,7 @@ export default { ...@@ -40,7 +40,7 @@ export default {
toggleState: true, toggleState: true,
}); });
} else { } else {
this.toggleCreateItemForm({ this.toggleCreateEpicForm({
actionType, actionType,
toggleState: true, toggleState: true,
}); });
......
...@@ -244,8 +244,8 @@ export const removeItem = ({ dispatch }, { parentItem, item }) => { ...@@ -244,8 +244,8 @@ export const removeItem = ({ dispatch }, { parentItem, item }) => {
}; };
export const toggleAddItemForm = ({ commit }, data) => commit(types.TOGGLE_ADD_ITEM_FORM, data); export const toggleAddItemForm = ({ commit }, data) => commit(types.TOGGLE_ADD_ITEM_FORM, data);
export const toggleCreateItemForm = ({ commit }, data) => export const toggleCreateEpicForm = ({ commit }, data) =>
commit(types.TOGGLE_CREATE_ITEM_FORM, data); commit(types.TOGGLE_CREATE_EPIC_FORM, data);
export const setPendingReferences = ({ commit }, data) => export const setPendingReferences = ({ commit }, data) =>
commit(types.SET_PENDING_REFERENCES, data); commit(types.SET_PENDING_REFERENCES, data);
...@@ -342,7 +342,7 @@ export const receiveCreateItemSuccess = ( ...@@ -342,7 +342,7 @@ export const receiveCreateItemSuccess = (
isSubItem: false, isSubItem: false,
}); });
dispatch('toggleCreateItemForm', { dispatch('toggleCreateEpicForm', {
actionType, actionType,
toggleState: false, toggleState: false,
}); });
......
...@@ -21,7 +21,7 @@ export const EXPAND_ITEM = 'EXPAND_ITEM'; ...@@ -21,7 +21,7 @@ export const EXPAND_ITEM = 'EXPAND_ITEM';
export const COLLAPSE_ITEM = 'COLLAPSE_ITEM'; export const COLLAPSE_ITEM = 'COLLAPSE_ITEM';
export const TOGGLE_ADD_ITEM_FORM = 'TOGGLE_ADD_ITEM_FORM'; export const TOGGLE_ADD_ITEM_FORM = 'TOGGLE_ADD_ITEM_FORM';
export const TOGGLE_CREATE_ITEM_FORM = 'TOGGLE_CREATE_ITEM_FORM'; export const TOGGLE_CREATE_EPIC_FORM = 'TOGGLE_CREATE_EPIC_FORM';
export const SET_PENDING_REFERENCES = 'SET_PENDING_REFERENCES'; export const SET_PENDING_REFERENCES = 'SET_PENDING_REFERENCES';
export const ADD_PENDING_REFERENCES = 'ADD_PENDING_REFERENCES'; export const ADD_PENDING_REFERENCES = 'ADD_PENDING_REFERENCES';
......
...@@ -123,12 +123,12 @@ export default { ...@@ -123,12 +123,12 @@ export default {
[types.TOGGLE_ADD_ITEM_FORM](state, { actionType, toggleState }) { [types.TOGGLE_ADD_ITEM_FORM](state, { actionType, toggleState }) {
state.actionType = actionType; state.actionType = actionType;
state.showAddItemForm = toggleState; state.showAddItemForm = toggleState;
state.showCreateItemForm = false; state.showCreateEpicForm = false;
}, },
[types.TOGGLE_CREATE_ITEM_FORM](state, { actionType, toggleState }) { [types.TOGGLE_CREATE_EPIC_FORM](state, { actionType, toggleState }) {
state.actionType = actionType; state.actionType = actionType;
state.showCreateItemForm = toggleState; state.showCreateEpicForm = toggleState;
state.showAddItemForm = false; state.showAddItemForm = false;
}, },
......
...@@ -22,7 +22,7 @@ export default () => ({ ...@@ -22,7 +22,7 @@ export default () => ({
itemAddInProgress: false, itemAddInProgress: false,
itemCreateInProgress: false, itemCreateInProgress: false,
showAddItemForm: false, showAddItemForm: false,
showCreateItemForm: false, showCreateEpicForm: false,
autoCompleteEpics: false, autoCompleteEpics: false,
autoCompleteIssues: false, autoCompleteIssues: false,
removeItemModalProps: { removeItemModalProps: {
......
...@@ -364,7 +364,7 @@ describe('RelatedItemsTree', () => { ...@@ -364,7 +364,7 @@ describe('RelatedItemsTree', () => {
}); });
describe(types.TOGGLE_ADD_ITEM_FORM, () => { describe(types.TOGGLE_ADD_ITEM_FORM, () => {
it('should set value of `actionType`, `showAddItemForm` as it is and `showCreateItemForm` as false on state', () => { it('should set value of `actionType`, `showAddItemForm` as it is and `showCreateEpicForm` as false on state', () => {
const data = { const data = {
actionType: 'Epic', actionType: 'Epic',
toggleState: true, toggleState: true,
...@@ -374,21 +374,21 @@ describe('RelatedItemsTree', () => { ...@@ -374,21 +374,21 @@ describe('RelatedItemsTree', () => {
expect(state.actionType).toBe(data.actionType); expect(state.actionType).toBe(data.actionType);
expect(state.showAddItemForm).toBe(data.toggleState); expect(state.showAddItemForm).toBe(data.toggleState);
expect(state.showCreateItemForm).toBe(false); expect(state.showCreateEpicForm).toBe(false);
}); });
}); });
describe(types.TOGGLE_CREATE_ITEM_FORM, () => { describe(types.TOGGLE_CREATE_EPIC_FORM, () => {
it('should set value of `actionType`, `showCreateItemForm` as it is and `showAddItemForm` as false on state', () => { it('should set value of `actionType`, `showCreateEpicForm` as it is and `showAddItemForm` as false on state', () => {
const data = { const data = {
actionType: 'Epic', actionType: 'Epic',
toggleState: true, toggleState: true,
}; };
mutations[types.TOGGLE_CREATE_ITEM_FORM](state, data); mutations[types.TOGGLE_CREATE_EPIC_FORM](state, data);
expect(state.actionType).toBe(data.actionType); expect(state.actionType).toBe(data.actionType);
expect(state.showCreateItemForm).toBe(data.toggleState); expect(state.showCreateEpicForm).toBe(data.toggleState);
expect(state.showAddItemForm).toBe(false); expect(state.showAddItemForm).toBe(false);
}); });
}); });
......
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import CreateItemForm from 'ee/related_items_tree/components/create_item_form.vue'; import CreateEpicForm from 'ee/related_items_tree/components/create_epic_form.vue';
const createComponent = (isSubmitting = false) => { const createComponent = (isSubmitting = false) => {
const localVue = createLocalVue(); const localVue = createLocalVue();
return mount(CreateItemForm, { return mount(CreateEpicForm, {
localVue, localVue,
propsData: { propsData: {
isSubmitting, isSubmitting,
...@@ -15,7 +15,7 @@ const createComponent = (isSubmitting = false) => { ...@@ -15,7 +15,7 @@ const createComponent = (isSubmitting = false) => {
}; };
describe('RelatedItemsTree', () => { describe('RelatedItemsTree', () => {
describe('CreateItemForm', () => { describe('CreateEpicForm', () => {
let wrapper; let wrapper;
beforeEach(() => { beforeEach(() => {
...@@ -68,22 +68,22 @@ describe('RelatedItemsTree', () => { ...@@ -68,22 +68,22 @@ describe('RelatedItemsTree', () => {
describe('methods', () => { describe('methods', () => {
describe('onFormSubmit', () => { describe('onFormSubmit', () => {
it('emits `createItemFormSubmit` event on component with input value as param', () => { it('emits `createEpicFormSubmit` event on component with input value as param', () => {
const value = 'foo'; const value = 'foo';
wrapper.find('input.form-control').setValue(value); wrapper.find('input.form-control').setValue(value);
wrapper.vm.onFormSubmit(); wrapper.vm.onFormSubmit();
expect(wrapper.emitted().createItemFormSubmit).toBeTruthy(); expect(wrapper.emitted().createEpicFormSubmit).toBeTruthy();
expect(wrapper.emitted().createItemFormSubmit[0]).toEqual([value]); expect(wrapper.emitted().createEpicFormSubmit[0]).toEqual([value]);
}); });
}); });
describe('onFormCancel', () => { describe('onFormCancel', () => {
it('emits `createItemFormCancel` event on component', () => { it('emits `createEpicFormCancel` event on component', () => {
wrapper.vm.onFormCancel(); wrapper.vm.onFormCancel();
expect(wrapper.emitted().createItemFormCancel).toBeTruthy(); expect(wrapper.emitted().createEpicFormCancel).toBeTruthy();
}); });
}); });
}); });
......
...@@ -105,12 +105,12 @@ describe('RelatedItemsTreeApp', () => { ...@@ -105,12 +105,12 @@ describe('RelatedItemsTreeApp', () => {
}); });
}); });
describe('handleCreateItemFormSubmit', () => { describe('handleCreateEpicFormSubmit', () => {
it('calls `createItem` action with `itemTitle` param', () => { it('calls `createItem` action with `itemTitle` param', () => {
const newValue = 'foo'; const newValue = 'foo';
spyOn(wrapper.vm, 'createItem'); spyOn(wrapper.vm, 'createItem');
wrapper.vm.handleCreateItemFormSubmit(newValue); wrapper.vm.handleCreateEpicFormSubmit(newValue);
expect(wrapper.vm.createItem).toHaveBeenCalledWith({ expect(wrapper.vm.createItem).toHaveBeenCalledWith({
itemTitle: newValue, itemTitle: newValue,
...@@ -147,13 +147,13 @@ describe('RelatedItemsTreeApp', () => { ...@@ -147,13 +147,13 @@ describe('RelatedItemsTreeApp', () => {
}); });
}); });
describe('handleCreateItemFormCancel', () => { describe('handleCreateEpicFormCancel', () => {
it('calls `toggleCreateItemForm` actions with params `toggleState` and `actionType`', () => { it('calls `toggleCreateEpicForm` actions with params `toggleState` and `actionType`', () => {
spyOn(wrapper.vm, 'toggleCreateItemForm'); spyOn(wrapper.vm, 'toggleCreateEpicForm');
wrapper.vm.handleCreateItemFormCancel(); wrapper.vm.handleCreateEpicFormCancel();
expect(wrapper.vm.toggleCreateItemForm).toHaveBeenCalledWith({ expect(wrapper.vm.toggleCreateEpicForm).toHaveBeenCalledWith({
toggleState: false, toggleState: false,
actionType: '', actionType: '',
}); });
...@@ -162,7 +162,7 @@ describe('RelatedItemsTreeApp', () => { ...@@ -162,7 +162,7 @@ describe('RelatedItemsTreeApp', () => {
it('calls `setItemInputValue` action with empty string', () => { it('calls `setItemInputValue` action with empty string', () => {
spyOn(wrapper.vm, 'setItemInputValue'); spyOn(wrapper.vm, 'setItemInputValue');
wrapper.vm.handleCreateItemFormCancel(); wrapper.vm.handleCreateEpicFormCancel();
expect(wrapper.vm.setItemInputValue).toHaveBeenCalledWith(''); expect(wrapper.vm.setItemInputValue).toHaveBeenCalledWith('');
}); });
......
...@@ -70,15 +70,15 @@ describe('RelatedItemsTree', () => { ...@@ -70,15 +70,15 @@ describe('RelatedItemsTree', () => {
}); });
}); });
it('calls `toggleCreateItemForm` action when provided `id` param value is not `0`', () => { it('calls `toggleCreateEpicForm` action when provided `id` param value is not `0`', () => {
spyOn(wrapper.vm, 'toggleCreateItemForm'); spyOn(wrapper.vm, 'toggleCreateEpicForm');
wrapper.vm.handleActionClick({ wrapper.vm.handleActionClick({
id: 1, id: 1,
actionType, actionType,
}); });
expect(wrapper.vm.toggleCreateItemForm).toHaveBeenCalledWith({ expect(wrapper.vm.toggleCreateEpicForm).toHaveBeenCalledWith({
actionType, actionType,
toggleState: true, toggleState: true,
}); });
......
...@@ -732,13 +732,13 @@ describe('RelatedItemTree', () => { ...@@ -732,13 +732,13 @@ describe('RelatedItemTree', () => {
}); });
}); });
describe('toggleCreateItemForm', () => { describe('toggleCreateEpicForm', () => {
it('should set `state.showCreateItemForm` to true', done => { it('should set `state.showCreateEpicForm` to true', done => {
testAction( testAction(
actions.toggleCreateItemForm, actions.toggleCreateEpicForm,
{}, {},
{}, {},
[{ type: types.TOGGLE_CREATE_ITEM_FORM, payload: {} }], [{ type: types.TOGGLE_CREATE_EPIC_FORM, payload: {} }],
[], [],
done, done,
); );
...@@ -997,7 +997,7 @@ describe('RelatedItemTree', () => { ...@@ -997,7 +997,7 @@ describe('RelatedItemTree', () => {
payload: { children: [createdEpic], isSubItem: false }, payload: { children: [createdEpic], isSubItem: false },
}, },
{ {
type: 'toggleCreateItemForm', type: 'toggleCreateEpicForm',
payload: { actionType: ActionType.Epic, toggleState: false }, payload: { actionType: ActionType.Epic, toggleState: false },
}, },
], ],
......
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