diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /app/assets/javascripts/clusters_list/components/agents.vue | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'app/assets/javascripts/clusters_list/components/agents.vue')
-rw-r--r-- | app/assets/javascripts/clusters_list/components/agents.vue | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/app/assets/javascripts/clusters_list/components/agents.vue b/app/assets/javascripts/clusters_list/components/agents.vue index 8a4a81d3e96..36f0f8e61ba 100644 --- a/app/assets/javascripts/clusters_list/components/agents.vue +++ b/app/assets/javascripts/clusters_list/components/agents.vue @@ -3,13 +3,9 @@ import { GlAlert, GlKeysetPagination, GlLoadingIcon, GlBanner } from '@gitlab/ui import { s__ } from '~/locale'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; -import { - MAX_LIST_COUNT, - ACTIVE_CONNECTION_TIME, - AGENT_FEEDBACK_ISSUE, - AGENT_FEEDBACK_KEY, -} from '../constants'; +import { MAX_LIST_COUNT, AGENT_FEEDBACK_ISSUE, AGENT_FEEDBACK_KEY } from '../constants'; import getAgentsQuery from '../graphql/queries/get_agents.query.graphql'; +import { getAgentLastContact, getAgentStatus } from '../clusters_util'; import AgentEmptyState from './agent_empty_state.vue'; import AgentTable from './agent_table.vue'; @@ -88,8 +84,8 @@ export default { if (list) { list = list.map((agent) => { const configFolder = this.folderList[agent.name]; - const lastContact = this.getLastContact(agent); - const status = this.getStatus(lastContact); + const lastContact = getAgentLastContact(agent?.tokens?.nodes); + const status = getAgentStatus(lastContact); return { ...agent, configFolder, lastContact, status }; }); } @@ -141,28 +137,6 @@ export default { }); } }, - getLastContact(agent) { - const tokens = agent?.tokens?.nodes; - let lastContact = null; - if (tokens?.length) { - tokens.forEach((token) => { - const lastContactToDate = new Date(token.lastUsedAt).getTime(); - if (lastContactToDate > lastContact) { - lastContact = lastContactToDate; - } - }); - } - return lastContact; - }, - getStatus(lastContact) { - if (lastContact) { - const now = new Date().getTime(); - const diff = now - lastContact; - - return diff > ACTIVE_CONNECTION_TIME ? 'inactive' : 'active'; - } - return 'unused'; - }, emitAgentsLoaded() { const count = this.agents?.project?.clusterAgents?.count; this.$emit('onAgentsLoad', count); |