Welcome to mirror list, hosted at ThFree Co, Russian Federation.

admin_runner_show_app.vue « admin_runner_show « runner « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9fa4b521ebc2c26218a5fe002a0885bcbe477808 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<script>
import { GlBadge, GlTabs, GlTab, GlTooltipDirective } from '@gitlab/ui';
import { createAlert, VARIANT_SUCCESS } from '~/flash';
import { TYPE_CI_RUNNER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { redirectTo } from '~/lib/utils/url_utility';
import { formatJobCount } from '../utils';
import RunnerDeleteButton from '../components/runner_delete_button.vue';
import RunnerEditButton from '../components/runner_edit_button.vue';
import RunnerPauseButton from '../components/runner_pause_button.vue';
import RunnerHeader from '../components/runner_header.vue';
import RunnerDetails from '../components/runner_details.vue';
import RunnerJobs from '../components/runner_jobs.vue';
import { I18N_DETAILS, I18N_FETCH_ERROR } from '../constants';
import runnerQuery from '../graphql/show/runner.query.graphql';
import { captureException } from '../sentry_utils';
import { saveAlertToLocalStorage } from '../local_storage_alert/save_alert_to_local_storage';

export default {
  name: 'AdminRunnerShowApp',
  components: {
    GlBadge,
    GlTabs,
    GlTab,
    RunnerDeleteButton,
    RunnerEditButton,
    RunnerPauseButton,
    RunnerHeader,
    RunnerDetails,
    RunnerJobs,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    runnerId: {
      type: String,
      required: true,
    },
    runnersPath: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      runner: null,
    };
  },
  apollo: {
    runner: {
      query: runnerQuery,
      variables() {
        return {
          id: convertToGraphQLId(TYPE_CI_RUNNER, this.runnerId),
        };
      },
      error(error) {
        createAlert({ message: I18N_FETCH_ERROR });

        this.reportToSentry(error);
      },
    },
  },
  computed: {
    canUpdate() {
      return this.runner.userPermissions?.updateRunner;
    },
    canDelete() {
      return this.runner.userPermissions?.deleteRunner;
    },
    jobCount() {
      return formatJobCount(this.runner?.jobCount);
    },
  },
  errorCaptured(error) {
    this.reportToSentry(error);
  },
  methods: {
    reportToSentry(error) {
      captureException({ error, component: this.$options.name });
    },
    onDeleted({ message }) {
      saveAlertToLocalStorage({ message, variant: VARIANT_SUCCESS });
      redirectTo(this.runnersPath);
    },
  },
  I18N_DETAILS,
};
</script>
<template>
  <div>
    <runner-header v-if="runner" :runner="runner">
      <template #actions>
        <runner-edit-button v-if="canUpdate && runner.editAdminUrl" :href="runner.editAdminUrl" />
        <runner-pause-button v-if="canUpdate" :runner="runner" />
        <runner-delete-button v-if="canDelete" :runner="runner" @deleted="onDeleted" />
      </template>
    </runner-header>

    <gl-tabs>
      <gl-tab>
        <template #title>{{ $options.I18N_DETAILS }}</template>

        <runner-details v-if="runner" :runner="runner" />
      </gl-tab>
      <gl-tab>
        <template #title>
          {{ s__('Runners|Jobs') }}
          <gl-badge
            v-if="jobCount"
            data-testid="job-count-badge"
            class="gl-tab-counter-badge"
            size="sm"
          >
            {{ jobCount }}
          </gl-badge>
        </template>

        <runner-jobs v-if="runner" :runner="runner" />
      </gl-tab>
    </gl-tabs>
  </div>
</template>