2022-01-21 00:12:56 +00:00
|
|
|
<script>
|
2022-07-12 18:08:46 +00:00
|
|
|
import { GlBadge, GlTabs, GlTab, GlTooltipDirective } from '@gitlab/ui';
|
2022-04-28 21:09:03 +00:00
|
|
|
import { createAlert, VARIANT_SUCCESS } from '~/flash';
|
2022-01-21 00:12:56 +00:00
|
|
|
import { TYPE_CI_RUNNER } from '~/graphql_shared/constants';
|
|
|
|
import { convertToGraphQLId } from '~/graphql_shared/utils';
|
2022-04-28 21:09:03 +00:00
|
|
|
import { redirectTo } from '~/lib/utils/url_utility';
|
2022-06-14 12:08:53 +00:00
|
|
|
import { formatJobCount } from '../utils';
|
2022-04-28 21:09:03 +00:00
|
|
|
import RunnerDeleteButton from '../components/runner_delete_button.vue';
|
2022-01-21 00:12:56 +00:00
|
|
|
import RunnerEditButton from '../components/runner_edit_button.vue';
|
2022-01-27 15:14:51 +00:00
|
|
|
import RunnerPauseButton from '../components/runner_pause_button.vue';
|
2022-01-21 00:12:56 +00:00
|
|
|
import RunnerHeader from '../components/runner_header.vue';
|
|
|
|
import RunnerDetails from '../components/runner_details.vue';
|
2022-06-14 12:08:53 +00:00
|
|
|
import RunnerJobs from '../components/runner_jobs.vue';
|
2022-07-12 18:08:46 +00:00
|
|
|
import { I18N_DETAILS, I18N_FETCH_ERROR } from '../constants';
|
2022-05-11 18:07:55 +00:00
|
|
|
import runnerQuery from '../graphql/show/runner.query.graphql';
|
2022-01-21 00:12:56 +00:00
|
|
|
import { captureException } from '../sentry_utils';
|
2022-04-28 21:09:03 +00:00
|
|
|
import { saveAlertToLocalStorage } from '../local_storage_alert/save_alert_to_local_storage';
|
2022-01-21 00:12:56 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'AdminRunnerShowApp',
|
|
|
|
components: {
|
2022-06-14 12:08:53 +00:00
|
|
|
GlBadge,
|
2022-07-12 18:08:46 +00:00
|
|
|
GlTabs,
|
2022-06-14 12:08:53 +00:00
|
|
|
GlTab,
|
2022-04-28 21:09:03 +00:00
|
|
|
RunnerDeleteButton,
|
2022-01-21 00:12:56 +00:00
|
|
|
RunnerEditButton,
|
2022-01-27 15:14:51 +00:00
|
|
|
RunnerPauseButton,
|
2022-01-21 00:12:56 +00:00
|
|
|
RunnerHeader,
|
|
|
|
RunnerDetails,
|
2022-06-14 12:08:53 +00:00
|
|
|
RunnerJobs,
|
2022-01-21 00:12:56 +00:00
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
runnerId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-04-28 21:09:03 +00:00
|
|
|
runnersPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-01-21 00:12:56 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
runner: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
runner: {
|
2022-03-01 15:22:06 +00:00
|
|
|
query: runnerQuery,
|
2022-01-21 00:12:56 +00:00
|
|
|
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;
|
|
|
|
},
|
2022-04-28 21:09:03 +00:00
|
|
|
canDelete() {
|
|
|
|
return this.runner.userPermissions?.deleteRunner;
|
|
|
|
},
|
2022-06-14 12:08:53 +00:00
|
|
|
jobCount() {
|
|
|
|
return formatJobCount(this.runner?.jobCount);
|
|
|
|
},
|
2022-01-21 00:12:56 +00:00
|
|
|
},
|
|
|
|
errorCaptured(error) {
|
|
|
|
this.reportToSentry(error);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
reportToSentry(error) {
|
|
|
|
captureException({ error, component: this.$options.name });
|
|
|
|
},
|
2022-04-28 21:09:03 +00:00
|
|
|
onDeleted({ message }) {
|
|
|
|
saveAlertToLocalStorage({ message, variant: VARIANT_SUCCESS });
|
|
|
|
redirectTo(this.runnersPath);
|
|
|
|
},
|
2022-01-21 00:12:56 +00:00
|
|
|
},
|
2022-07-12 18:08:46 +00:00
|
|
|
I18N_DETAILS,
|
2022-01-21 00:12:56 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<runner-header v-if="runner" :runner="runner">
|
|
|
|
<template #actions>
|
|
|
|
<runner-edit-button v-if="canUpdate && runner.editAdminUrl" :href="runner.editAdminUrl" />
|
2022-01-27 15:14:51 +00:00
|
|
|
<runner-pause-button v-if="canUpdate" :runner="runner" />
|
2022-05-03 15:07:55 +00:00
|
|
|
<runner-delete-button v-if="canDelete" :runner="runner" @deleted="onDeleted" />
|
2022-01-21 00:12:56 +00:00
|
|
|
</template>
|
|
|
|
</runner-header>
|
|
|
|
|
2022-07-12 18:08:46 +00:00
|
|
|
<gl-tabs>
|
|
|
|
<gl-tab>
|
|
|
|
<template #title>{{ $options.I18N_DETAILS }}</template>
|
2022-06-14 12:08:53 +00:00
|
|
|
|
2022-07-12 18:08:46 +00:00
|
|
|
<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>
|
2022-01-21 00:12:56 +00:00
|
|
|
</div>
|
|
|
|
</template>
|