Commit 0d711f5c authored by Axel García's avatar Axel García Committed by Miguel Rincon

Add "New epic" button to epic pages

This adds a button that redirects to the new epic creation form.

It also updates the epic_header.vue specs to be able to provide feature
flags to the component.
parent 1047ae11
...@@ -7,6 +7,7 @@ import { __ } from '~/locale'; ...@@ -7,6 +7,7 @@ import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue'; import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import epicUtils from '../utils/epic_utils'; import epicUtils from '../utils/epic_utils';
import { statusType } from '../constants'; import { statusType } from '../constants';
...@@ -23,6 +24,7 @@ export default { ...@@ -23,6 +24,7 @@ export default {
GitlabTeamMemberBadge: () => GitlabTeamMemberBadge: () =>
import('ee_component/vue_shared/components/user_avatar/badges/gitlab_team_member_badge.vue'), import('ee_component/vue_shared/components/user_avatar/badges/gitlab_team_member_badge.vue'),
}, },
mixins: [glFeatureFlagsMixin()],
computed: { computed: {
...mapState([ ...mapState([
'sidebarCollapsed', 'sidebarCollapsed',
...@@ -32,6 +34,7 @@ export default { ...@@ -32,6 +34,7 @@ export default {
'created', 'created',
'canUpdate', 'canUpdate',
'confidential', 'confidential',
'newEpicWebUrl',
]), ]),
...mapGetters(['isEpicOpen']), ...mapGetters(['isEpicOpen']),
statusIcon() { statusIcon() {
...@@ -51,6 +54,11 @@ export default { ...@@ -51,6 +54,11 @@ export default {
actionButtonText() { actionButtonText() {
return this.isEpicOpen ? __('Close epic') : __('Reopen epic'); return this.isEpicOpen ? __('Close epic') : __('Reopen epic');
}, },
canCreate() {
const { canCreate } = this.$store.state;
return canCreate && this.glFeatures.createEpicForm;
},
}, },
mounted() { mounted() {
/** /**
...@@ -108,13 +116,22 @@ export default { ...@@ -108,13 +116,22 @@ export default {
</strong> </strong>
</div> </div>
</div> </div>
<div v-if="canUpdate" class="detail-page-header-actions js-issuable-actions"> <div class="detail-page-header-actions js-issuable-actions">
<gl-deprecated-button <gl-deprecated-button
v-if="canUpdate"
:loading="epicStatusChangeInProgress" :loading="epicStatusChangeInProgress"
:class="actionButtonClass" :class="actionButtonClass"
@click="toggleEpicStatus(isEpicOpen)" @click="toggleEpicStatus(isEpicOpen)"
>{{ actionButtonText }}</gl-deprecated-button >{{ actionButtonText }}</gl-deprecated-button
> >
<gl-deprecated-button
v-if="canCreate"
class="btn btn-grouped btn-success btn-inverted js-new-epic-button"
:href="newEpicWebUrl"
>
{{ __('New epic') }}
</gl-deprecated-button>
</div> </div>
<gl-deprecated-button <gl-deprecated-button
:aria-label="__('Toggle sidebar')" :aria-label="__('Toggle sidebar')"
......
...@@ -14,8 +14,10 @@ export default () => ({ ...@@ -14,8 +14,10 @@ export default () => ({
epicsWebUrl: '', epicsWebUrl: '',
labelsWebUrl: '', labelsWebUrl: '',
markdownDocsPath: '', markdownDocsPath: '',
newEpicWebUrl: '',
// Flags // Flags
canCreate: false,
canUpdate: false, canUpdate: false,
canDestroy: false, canDestroy: false,
canAdmin: false, canAdmin: false,
......
...@@ -19,6 +19,7 @@ class Groups::EpicsController < Groups::ApplicationController ...@@ -19,6 +19,7 @@ class Groups::EpicsController < Groups::ApplicationController
before_action do before_action do
push_frontend_feature_flag(:vue_issuable_epic_sidebar, @group) push_frontend_feature_flag(:vue_issuable_epic_sidebar, @group)
push_frontend_feature_flag(:confidential_epics, @group, default_enabled: true) push_frontend_feature_flag(:confidential_epics, @group, default_enabled: true)
push_frontend_feature_flag(:create_epic_form, @group)
end end
def new; end def new; end
......
...@@ -44,7 +44,8 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated ...@@ -44,7 +44,8 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated
def initial_data def initial_data
{ {
labels: epic.labels, labels: epic.labels,
subscribed: subscribed? subscribed: subscribed?,
canCreate: can?(current_user, :create_epic, epic)
} }
end end
...@@ -78,7 +79,8 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated ...@@ -78,7 +79,8 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated
labels_path: group_labels_path(group, format: :json, only_group_labels: true, include_ancestor_groups: true), labels_path: group_labels_path(group, format: :json, only_group_labels: true, include_ancestor_groups: true),
toggle_subscription_path: toggle_subscription_group_epic_path(group, epic), toggle_subscription_path: toggle_subscription_group_epic_path(group, epic),
labels_web_url: group_labels_path(group), labels_web_url: group_labels_path(group),
epics_web_url: group_epics_path(group) epics_web_url: group_epics_path(group),
new_epic_web_url: new_group_epic_path(group)
} }
paths[:todo_delete_path] = dashboard_todo_path(epic_pending_todo) if epic_pending_todo.present? paths[:todo_delete_path] = dashboard_todo_path(epic_pending_todo) if epic_pending_todo.present?
......
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