summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/bridge/components/sidebar.vue
blob: 3ba07cf55d1f5315bef45336bfe3284e9752b376 (plain)
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
<script>
import { GlButton, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue';
import { JOB_SIDEBAR } from '../../constants';
import CommitBlock from '../../components/commit_block.vue';

export default {
  styles: {
    width: '290px',
  },
  name: 'BridgeSidebar',
  i18n: {
    ...JOB_SIDEBAR,
    retryButton: __('Retry'),
    retryTriggerJob: __('Retry the trigger job'),
    retryDownstreamPipeline: __('Retry the downstream pipeline'),
  },
  sectionClass: ['gl-border-t-solid', 'gl-border-t-1', 'gl-border-t-gray-100', 'gl-py-5'],
  components: {
    CommitBlock,
    GlButton,
    GlDropdown,
    GlDropdownItem,
    TooltipOnTruncate,
  },
  mixins: [glFeatureFlagsMixin()],
  props: {
    bridgeJob: {
      type: Object,
      required: true,
    },
    commit: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      topPosition: 0,
    };
  },
  computed: {
    rootStyle() {
      return { ...this.$options.styles, top: `${this.topPosition}px` };
    },
  },
  mounted() {
    this.setTopPosition();
  },
  methods: {
    onSidebarButtonClick() {
      this.$emit('toggleSidebar');
    },
    setTopPosition() {
      const navbarEl = document.querySelector('.js-navbar');

      if (navbarEl) {
        this.topPosition = navbarEl.getBoundingClientRect().bottom;
      }
    },
  },
};
</script>
<template>
  <aside
    class="gl-fixed gl-right-0 gl-px-5 gl-bg-gray-10 gl-h-full gl-border-l-solid gl-border-1 gl-border-gray-100 gl-z-index-200 gl-overflow-hidden"
    :style="rootStyle"
  >
    <div class="gl-py-5 gl-display-flex gl-align-items-center">
      <tooltip-on-truncate :title="bridgeJob.name" truncate-target="child"
        ><h4 class="gl-mb-0 gl-mr-2 gl-text-truncate">
          {{ bridgeJob.name }}
        </h4>
      </tooltip-on-truncate>
      <!-- TODO: implement retry actions -->
      <div
        v-if="glFeatures.triggerJobRetryAction"
        class="gl-flex-grow-1 gl-flex-shrink-0 gl-text-right"
      >
        <gl-dropdown
          :text="$options.i18n.retryButton"
          category="primary"
          variant="confirm"
          right
          size="medium"
        >
          <gl-dropdown-item>{{ $options.i18n.retryTriggerJob }}</gl-dropdown-item>
          <gl-dropdown-item>{{ $options.i18n.retryDownstreamPipeline }}</gl-dropdown-item>
        </gl-dropdown>
      </div>
      <gl-button
        :aria-label="$options.i18n.toggleSidebar"
        data-testid="sidebar-expansion-toggle"
        category="tertiary"
        class="gl-md-display-none gl-ml-2"
        icon="chevron-double-lg-right"
        @click="onSidebarButtonClick"
      />
    </div>
    <commit-block :commit="commit" :class="$options.sectionClass" />
    <!-- TODO: show stage dropdown, jobs list -->
  </aside>
</template>