All files / ee/app/assets/javascripts/boards/components epic_board_content_sidebar.vue

88.88% Statements 8/9
100% Branches 1/1
83.33% Functions 5/6
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174                                2x                                                   21x 2x   19x                       23x     21x     20x         1x                                                                                                                                                                                                                  
<script>
import { GlDrawer } from '@gitlab/ui';
import { MountingPortal } from 'portal-vue';
import activeBoardItemQuery from 'ee_else_ce/boards/graphql/client/active_board_item.query.graphql';
import setActiveBoardItemMutation from 'ee_else_ce/boards/graphql/client/set_active_board_item.mutation.graphql';
import SidebarAncestorsWidget from 'ee_component/sidebar/components/ancestors_tree/sidebar_ancestors_widget.vue';
import { s__ } from '~/locale';
import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue';
import { setError } from '~/boards/graphql/cache_updates';
import SidebarConfidentialityWidget from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
import SidebarDateWidget from '~/sidebar/components/date/sidebar_date_widget.vue';
import SidebarParticipantsWidget from '~/sidebar/components/participants/sidebar_participants_widget.vue';
import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue';
import SidebarTodoWidget from '~/sidebar/components/todo_toggle/sidebar_todo_widget.vue';
import SidebarLabelsWidget from '~/sidebar/components/labels/labels_select_widget/labels_select_root.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import ColorSelectDropdown from '~/vue_shared/components/color_select_dropdown/color_select_root.vue';
 
export default {
  components: {
    BoardSidebarTitle,
    ColorSelectDropdown,
    GlDrawer,
    MountingPortal,
    SidebarAncestorsWidget,
    SidebarConfidentialityWidget,
    SidebarDateWidget,
    SidebarLabelsWidget,
    SidebarParticipantsWidget,
    SidebarSubscriptionsWidget,
    SidebarTodoWidget,
  },
  mixins: [glFeatureFlagMixin()],
  inject: ['canUpdate', 'labelsFilterBasePath', 'issuableType', 'allowSubEpics'],
  inheritAttrs: false,
  apollo: {
    activeBoardCard: {
      query: activeBoardItemQuery,
      variables: {
        isIssue: false,
      },
      update(data) {
        if (!data.activeBoardItem?.id) {
          return { id: '', iid: '' };
        }
        return data.activeBoardItem;
      },
      error(error) {
        setError({
          error,
          message: s__('Boards|An error occurred while selecting the card. Please try again.'),
        });
      },
    },
  },
  computed: {
    isSidebarOpen() {
      return Boolean(this.activeBoardCard?.id);
    },
    fullPath() {
      return this.activeBoardCard?.referencePath?.split('&')[0] || '';
    },
    isEpicColorEnabled() {
      return this.glFeatures.epicColorHighlight;
    },
  },
  methods: {
    handleClose() {
      this.$apollo.mutate({
        mutation: setActiveBoardItemMutation,
        variables: {
          boardItem: null,
          listId: null,
        },
      });
    },
  },
};
</script>
 
<template>
  <mounting-portal mount-to="#js-right-sidebar-portal" name="epic-board-sidebar" append>
    <gl-drawer
      v-bind="$attrs"
      class="boards-sidebar"
      :open="isSidebarOpen"
      variant="sidebar"
      @close="handleClose"
    >
      <template #title>
        <h2 class="gl-my-0 gl-font-size-h2 gl-line-height-24">{{ __('Epic details') }}</h2>
      </template>
      <template #header>
        <sidebar-todo-widget
          class="gl-mt-3"
          :issuable-id="activeBoardCard.id"
          :issuable-iid="activeBoardCard.iid"
          :full-path="fullPath"
          :issuable-type="issuableType"
        />
      </template>
      <template #default>
        <board-sidebar-title :active-item="activeBoardCard" data-testid="sidebar-title" />
        <sidebar-date-widget
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          date-type="startDate"
          :issuable-type="issuableType"
          :can-inherit="true"
        />
        <sidebar-date-widget
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          date-type="dueDate"
          :issuable-type="issuableType"
          :can-inherit="true"
        />
        <sidebar-labels-widget
          class="block labels"
          data-testid="sidebar-labels"
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          :allow-label-remove="canUpdate"
          :allow-multiselect="true"
          :labels-filter-base-path="labelsFilterBasePath"
          :attr-workspace-path="fullPath"
          workspace-type="group"
          :issuable-type="issuableType"
          label-create-type="group"
        >
          {{ __('None') }}
        </sidebar-labels-widget>
 
        <color-select-dropdown
          v-if="isEpicColorEnabled"
          class="block colors js-colors-block"
          :allow-edit="canUpdate"
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          workspace-type="group"
          issuable-type="epic"
          variant="sidebar"
          data-testid="colors-select"
        >
          {{ __('None') }}
        </color-select-dropdown>
 
        <sidebar-confidentiality-widget
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          :issuable-type="issuableType"
        />
        <sidebar-ancestors-widget
          v-if="allowSubEpics"
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          issuable-type="epic"
        />
        <sidebar-participants-widget
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          issuable-type="epic"
        />
        <sidebar-subscriptions-widget
          :iid="activeBoardCard.iid"
          :full-path="fullPath"
          :issuable-type="issuableType"
          :show-in-dropdown="false"
        />
      </template>
    </gl-drawer>
  </mounting-portal>
</template>