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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-23 21:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-23 21:08:47 +0300
commit82f12c20905e97952cf673e74ec05267fee0b43b (patch)
treea0e49d069165ef4227537b129e43825fb4689c51 /app/assets/javascripts/runner
parent16dbaf57bc4d87aa8a2bca8bf9db7cab26d841c4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/runner')
-rw-r--r--app/assets/javascripts/runner/components/runner_delete_button.vue29
-rw-r--r--app/assets/javascripts/runner/components/runner_status_badge.vue31
-rw-r--r--app/assets/javascripts/runner/constants.js17
3 files changed, 42 insertions, 35 deletions
diff --git a/app/assets/javascripts/runner/components/runner_delete_button.vue b/app/assets/javascripts/runner/components/runner_delete_button.vue
index f436ac0ce52..b58665ecbc9 100644
--- a/app/assets/javascripts/runner/components/runner_delete_button.vue
+++ b/app/assets/javascripts/runner/components/runner_delete_button.vue
@@ -115,36 +115,37 @@ export default {
// should only change back if the operation fails.
this.deleting = true;
try {
- const {
- data: {
- runnerDelete: { errors },
- },
- } = await this.$apollo.mutate({
+ await this.$apollo.mutate({
mutation: runnerDeleteMutation,
variables: {
input: {
id: this.runner.id,
},
},
- update: (cache) => {
+ update: (cache, { data }) => {
+ const { errors } = data.runnerDelete;
+
+ if (errors?.length) {
+ this.onError(new Error(errors.join(' ')));
+ return;
+ }
+
+ this.$emit('deleted', {
+ message: sprintf(I18N_DELETED_TOAST, { name: this.runnerName }),
+ });
+
// Remove deleted runner from the cache
const cacheId = cache.identify(this.runner);
cache.evict({ id: cacheId });
+ cache.gc();
},
});
- if (errors && errors.length) {
- throw new Error(errors.join(' '));
- } else {
- this.$emit('deleted', {
- message: sprintf(I18N_DELETED_TOAST, { name: this.runnerName }),
- });
- }
} catch (e) {
- this.deleting = false;
this.onError(e);
}
},
onError(error) {
+ this.deleting = false;
const { message } = error;
createAlert({ message });
diff --git a/app/assets/javascripts/runner/components/runner_status_badge.vue b/app/assets/javascripts/runner/components/runner_status_badge.vue
index 6d0445ecb7a..073d0a49f59 100644
--- a/app/assets/javascripts/runner/components/runner_status_badge.vue
+++ b/app/assets/javascripts/runner/components/runner_status_badge.vue
@@ -3,10 +3,11 @@ import { GlBadge, GlTooltipDirective } from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale';
import { getTimeago } from '~/lib/utils/datetime_utility';
import {
- I18N_ONLINE_RUNNER_TIMEAGO_DESCRIPTION,
- I18N_NEVER_CONTACTED_RUNNER_DESCRIPTION,
- I18N_OFFLINE_RUNNER_TIMEAGO_DESCRIPTION,
- I18N_STALE_RUNNER_DESCRIPTION,
+ I18N_ONLINE_TIMEAGO_TOOLTIP,
+ I18N_NEVER_CONTACTED_TOOLTIP,
+ I18N_OFFLINE_TIMEAGO_TOOLTIP,
+ I18N_STALE_TIMEAGO_TOOLTIP,
+ I18N_STALE_NEVER_CONTACTED_TOOLTIP,
STATUS_ONLINE,
STATUS_NEVER_CONTACTED,
STATUS_OFFLINE,
@@ -32,7 +33,7 @@ export default {
return getTimeago().format(this.runner.contactedAt);
}
// Prevent "just now" from being rendered, in case data is missing.
- return __('n/a');
+ return __('never');
},
badge() {
switch (this.runner?.status) {
@@ -40,35 +41,39 @@ export default {
return {
variant: 'success',
label: s__('Runners|online'),
- tooltip: sprintf(I18N_ONLINE_RUNNER_TIMEAGO_DESCRIPTION, {
- timeAgo: this.contactedAtTimeAgo,
- }),
+ tooltip: this.timeAgoTooltip(I18N_ONLINE_TIMEAGO_TOOLTIP),
};
case STATUS_NEVER_CONTACTED:
return {
variant: 'muted',
label: s__('Runners|never contacted'),
- tooltip: I18N_NEVER_CONTACTED_RUNNER_DESCRIPTION,
+ tooltip: I18N_NEVER_CONTACTED_TOOLTIP,
};
case STATUS_OFFLINE:
return {
variant: 'muted',
label: s__('Runners|offline'),
- tooltip: sprintf(I18N_OFFLINE_RUNNER_TIMEAGO_DESCRIPTION, {
- timeAgo: this.contactedAtTimeAgo,
- }),
+ tooltip: this.timeAgoTooltip(I18N_OFFLINE_TIMEAGO_TOOLTIP),
};
case STATUS_STALE:
return {
variant: 'warning',
label: s__('Runners|stale'),
- tooltip: I18N_STALE_RUNNER_DESCRIPTION,
+ // runner may have contacted (or not) and be stale: consider both cases.
+ tooltip: this.runner.contactedAt
+ ? this.timeAgoTooltip(I18N_STALE_TIMEAGO_TOOLTIP)
+ : I18N_STALE_NEVER_CONTACTED_TOOLTIP,
};
default:
return null;
}
},
},
+ methods: {
+ timeAgoTooltip(text) {
+ return sprintf(text, { timeAgo: this.contactedAtTimeAgo });
+ },
+ },
};
</script>
<template>
diff --git a/app/assets/javascripts/runner/constants.js b/app/assets/javascripts/runner/constants.js
index 1e6f9d7c669..c6afa728424 100644
--- a/app/assets/javascripts/runner/constants.js
+++ b/app/assets/javascripts/runner/constants.js
@@ -21,18 +21,19 @@ export const I18N_GROUP_RUNNER_DESCRIPTION = s__(
);
export const I18N_PROJECT_RUNNER_DESCRIPTION = s__('Runners|Associated with one or more projects');
-// Status
-export const I18N_ONLINE_RUNNER_TIMEAGO_DESCRIPTION = s__(
+// Status tooltips
+export const I18N_ONLINE_TIMEAGO_TOOLTIP = s__(
'Runners|Runner is online; last contact was %{timeAgo}',
);
-export const I18N_NEVER_CONTACTED_RUNNER_DESCRIPTION = s__(
- 'Runners|This runner has never contacted this instance',
+export const I18N_NEVER_CONTACTED_TOOLTIP = s__('Runners|Runner has never contacted this instance');
+export const I18N_OFFLINE_TIMEAGO_TOOLTIP = s__(
+ 'Runners|Runner is offline; last contact was %{timeAgo}',
);
-export const I18N_OFFLINE_RUNNER_TIMEAGO_DESCRIPTION = s__(
- 'Runners|No recent contact from this runner; last contact was %{timeAgo}',
+export const I18N_STALE_TIMEAGO_TOOLTIP = s__(
+ 'Runners|Runner is stale; last contact was %{timeAgo}',
);
-export const I18N_STALE_RUNNER_DESCRIPTION = s__(
- 'Runners|No contact from this runner in over 3 months',
+export const I18N_STALE_NEVER_CONTACTED_TOOLTIP = s__(
+ 'Runners|Runner is stale; it has never contacted this instance',
);
// Actions