Commit afc49404 authored by Kushal Pandya's avatar Kushal Pandya

Use Epic vuex app by default in place of older app

Use refactored Vuex Epic app in place of older Epic app.
parent 7b83a69e
...@@ -11,6 +11,11 @@ import EpicCreateApp from './components/epic_create.vue'; ...@@ -11,6 +11,11 @@ import EpicCreateApp from './components/epic_create.vue';
export default (epicCreate = false) => { export default (epicCreate = false) => {
const el = document.getElementById(epicCreate ? 'epic-create-root' : 'epic-app-root'); const el = document.getElementById(epicCreate ? 'epic-create-root' : 'epic-app-root');
if (!el) {
return false;
}
const store = createStore(); const store = createStore();
if (epicCreate) { if (epicCreate) {
......
import Cookies from 'js-cookie';
import { parseBoolean } from '~/lib/utils/common_utils';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics'; import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics';
import initNewEpic from 'ee/epics/new_epic/new_epic_bundle';
import initEpicCreateApp from 'ee/epic/epic_bundle'; import initEpicCreateApp from 'ee/epic/epic_bundle';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
...@@ -14,9 +11,5 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -14,9 +11,5 @@ document.addEventListener('DOMContentLoaded', () => {
stateFiltersSelector: '.epics-state-filters', stateFiltersSelector: '.epics-state-filters',
}); });
if (parseBoolean(Cookies.get('load_new_epic_app'))) {
initEpicCreateApp(true); initEpicCreateApp(true);
} else {
initNewEpic();
}
}); });
import ZenMode from '~/zen_mode'; import ZenMode from '~/zen_mode';
import Cookies from 'js-cookie';
import initEpicShow from 'ee/epics/epic_show/epic_show_bundle';
import ShortcutsEpic from 'ee/behaviors/shortcuts/shortcuts_epic'; import ShortcutsEpic from 'ee/behaviors/shortcuts/shortcuts_epic';
import initEpicApp from 'ee/epic/epic_bundle'; import initEpicApp from 'ee/epic/epic_bundle';
import '~/notes/index'; import '~/notes/index';
import { parseBoolean } from '~/lib/utils/common_utils';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new new ZenMode(); // eslint-disable-line no-new
if (parseBoolean(Cookies.get('load_new_epic_app'))) {
initEpicApp(); initEpicApp();
} else {
initEpicShow();
new ShortcutsEpic(); // eslint-disable-line no-new new ShortcutsEpic(); // eslint-disable-line no-new
}
}); });
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics'; import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics';
import initNewEpic from 'ee/epics/new_epic/new_epic_bundle'; import initEpicCreateApp from 'ee/epic/epic_bundle';
import initRoadmap from 'ee/roadmap/index'; import initRoadmap from 'ee/roadmap/index';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
...@@ -11,6 +11,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -11,6 +11,6 @@ document.addEventListener('DOMContentLoaded', () => {
filteredSearchTokenKeys: FilteredSearchTokenKeysEpics, filteredSearchTokenKeys: FilteredSearchTokenKeysEpics,
stateFiltersSelector: '.epics-state-filters', stateFiltersSelector: '.epics-state-filters',
}); });
initNewEpic(); initEpicCreateApp(true);
initRoadmap(); initRoadmap();
}); });
...@@ -4,12 +4,9 @@ import { dateInWords } from '~/lib/utils/datetime_utility'; ...@@ -4,12 +4,9 @@ import { dateInWords } from '~/lib/utils/datetime_utility';
import { PRESET_TYPES, emptyStateDefault, emptyStateWithFilters } from '../constants'; import { PRESET_TYPES, emptyStateDefault, emptyStateWithFilters } from '../constants';
import NewEpic from '../../epics/new_epic/components/new_epic.vue'; import initEpicCreate from '../../epic/epic_bundle';
export default { export default {
components: {
NewEpic,
},
props: { props: {
presetType: { presetType: {
type: String, type: String,
...@@ -93,6 +90,15 @@ export default { ...@@ -93,6 +90,15 @@ export default {
}); });
}, },
}, },
mounted() {
// If filters are not applied and yet user
// is seeing empty state, we need to show
// `New epic` button, so boot-up Epic app
// in create mode.
if (!this.hasFiltersApplied) {
initEpicCreate(true);
}
},
}; };
</script> </script>
...@@ -106,7 +112,11 @@ export default { ...@@ -106,7 +112,11 @@ export default {
<h4>{{ message }}</h4> <h4>{{ message }}</h4>
<p v-html="subMessage"></p> <p v-html="subMessage"></p>
<div class="text-center"> <div class="text-center">
<new-epic v-if="!hasFiltersApplied" :endpoint="newEpicEndpoint" /> <div
v-if="!hasFiltersApplied"
id="epic-create-root"
:data-endpoint="newEpicEndpoint"
></div>
<a :title="__('List')" :href="newEpicEndpoint" class="btn btn-default"> <a :title="__('List')" :href="newEpicEndpoint" class="btn btn-default">
<span>{{ s__('View epics list') }}</span> <span>{{ s__('View epics list') }}</span>
</a> </a>
......
.new-epic-dropdown,
.epic-create-dropdown { .epic-create-dropdown {
.dropdown-menu { .dropdown-menu {
padding-left: $gl-padding-top; padding-left: $gl-padding-top;
...@@ -15,12 +14,12 @@ ...@@ -15,12 +14,12 @@
} }
.empty-state { .empty-state {
.new-epic-dropdown,
.epic-create-dropdown { .epic-create-dropdown {
display: inline-flex; display: inline-flex;
.btn-success { .btn-success {
margin: 0; margin: 0;
margin-top: $gl-padding-top;
} }
} }
} }
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
= render 'shared/issuable/epic_nav', type: :epics = render 'shared/issuable/epic_nav', type: :epics
.nav-controls .nav-controls
- if can?(current_user, :create_epic, @group) - if can?(current_user, :create_epic, @group)
- if cookies[:load_new_epic_app] == 'true'
#epic-create-root{ data: { endpoint: request.url, 'align-right' => true } } #epic-create-root{ data: { endpoint: request.url, 'align-right' => true } }
- else
#new-epic-app{ data: { endpoint: request.url, 'align-right' => true } }
= render 'shared/epic/search_bar', type: :epics = render 'shared/epic/search_bar', type: :epics
......
...@@ -11,10 +11,7 @@ ...@@ -11,10 +11,7 @@
- page_card_attributes @epic.card_attributes - page_card_attributes @epic.card_attributes
- if cookies[:load_new_epic_app] == 'true' #epic-app-root{ data: epic_show_app_data(@epic, author_icon: avatar_icon_for_user(@epic.author), initial: issuable_initial_data(@epic)) }
#epic-app-root{ data: epic_show_app_data(@epic, author_icon: avatar_icon_for_user(@epic.author), initial: issuable_initial_data(@epic)) }
- else
#epic-show-app{ data: epic_show_app_data(@epic, author_icon: avatar_icon_for_user(@epic.author), initial: issuable_initial_data(@epic)) }
.content-block.emoji-block .content-block.emoji-block
.row .row
......
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
= _('To view the roadmap, add a start or due date to one of your epics in this group or its subgroups. In the months view, only epics in the past month, current month, and next 5 months are shown.') = _('To view the roadmap, add a start or due date to one of your epics in this group or its subgroups. In the months view, only epics in the past month, current month, and next 5 months are shown.')
.text-center .text-center
- if can?(current_user, :create_epic, @group) - if can?(current_user, :create_epic, @group)
#new-epic-app{ data: { endpoint: request.url } } #epic-create-root{ data: { endpoint: request.url } }
= link_to group_epics_path(@group), title: 'List', class: 'btn' do = link_to group_epics_path(@group), title: 'List', class: 'btn' do
%span= _('View epics list') %span= _('View epics list')
...@@ -15,7 +15,7 @@ describe 'New Epic', :js do ...@@ -15,7 +15,7 @@ describe 'New Epic', :js do
it 'does not show the create button' do it 'does not show the create button' do
visit group_epics_path(group) visit group_epics_path(group)
expect(page).not_to have_selector('.new-epic-dropdown .btn-success') expect(page).not_to have_selector('.epic-create-dropdown .btn-success')
end end
end end
...@@ -26,7 +26,7 @@ describe 'New Epic', :js do ...@@ -26,7 +26,7 @@ describe 'New Epic', :js do
end end
it 'does show the create button' do it 'does show the create button' do
expect(page).to have_selector('.new-epic-dropdown .btn-success') expect(page).to have_selector('.epic-create-dropdown .btn-success')
end end
end end
end end
...@@ -40,7 +40,7 @@ describe 'New Epic', :js do ...@@ -40,7 +40,7 @@ describe 'New Epic', :js do
end end
it 'does not show the create button' do it 'does not show the create button' do
expect(page).not_to have_selector('.new-epic-dropdown .btn-success') expect(page).not_to have_selector('.epic-create-dropdown .btn-success')
end end
end end
...@@ -51,13 +51,13 @@ describe 'New Epic', :js do ...@@ -51,13 +51,13 @@ describe 'New Epic', :js do
end end
it 'does show the create button' do it 'does show the create button' do
expect(page).to have_selector('.new-epic-dropdown .btn-success') expect(page).to have_selector('.epic-create-dropdown .btn-success')
end end
it 'can create epic' do it 'can create epic' do
find('.new-epic-dropdown .btn-success').click find('.epic-create-dropdown .btn-success').click
find('.new-epic-dropdown .dropdown-menu input').set('test epic title') find('.epic-create-dropdown .dropdown-menu input').set('test epic title')
find('.new-epic-dropdown .dropdown-menu .btn-success').click find('.epic-create-dropdown .dropdown-menu .btn-success').click
wait_for_requests wait_for_requests
......
...@@ -174,18 +174,15 @@ describe('EpicsListEmptyComponent', () => { ...@@ -174,18 +174,15 @@ describe('EpicsListEmptyComponent', () => {
); );
}); });
it('renders new epic button element', () => { it('renders mount point for new epic button to boot via Epic app', () => {
const newEpicBtnEl = vm.$el.querySelector('.new-epic-dropdown'); expect(vm.$el.querySelector('#epic-create-root')).not.toBeNull();
expect(newEpicBtnEl).not.toBeNull();
expect(newEpicBtnEl.querySelector('button.btn-success').innerText.trim()).toBe('New epic');
}); });
it('does not render new epic button element when `hasFiltersApplied` prop is true', done => { it('does not render new epic button element when `hasFiltersApplied` prop is true', done => {
vm.hasFiltersApplied = true; vm.hasFiltersApplied = true;
Vue.nextTick() Vue.nextTick()
.then(() => { .then(() => {
expect(vm.$el.querySelector('.new-epic-dropdown')).toBeNull(); expect(vm.$el.querySelector('.epic-create-dropdown')).toBeNull();
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -6,7 +6,7 @@ module QA ...@@ -6,7 +6,7 @@ module QA
module Group module Group
module Epic module Epic
class Index < QA::Page::Base class Index < QA::Page::Base
view 'ee/app/assets/javascripts/epics/new_epic/components/new_epic.vue' do view 'ee/app/assets/javascripts/epic/components/epic_create.vue' do
element :new_epic_button element :new_epic_button
element :epic_title element :epic_title
element :create_epic_button element :create_epic_button
......
...@@ -21,7 +21,7 @@ module QA ...@@ -21,7 +21,7 @@ module QA
element :remove_issue_button element :remove_issue_button
end end
view 'ee/app/assets/javascripts/epics/epic_show/components/epic_header.vue' do view 'ee/app/assets/javascripts/epic/components/epic_header.vue' do
element :close_reopen_epic_button element :close_reopen_epic_button
end end
......
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