debian-mirror-gitlab/app/assets/javascripts/clusters/agents/components/show.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

172 lines
4.5 KiB
Vue
Raw Normal View History

2021-11-18 22:05:49 +05:30
<script>
import {
GlAlert,
GlBadge,
GlKeysetPagination,
GlLoadingIcon,
GlSprintf,
GlTab,
GlTabs,
} from '@gitlab/ui';
2022-01-26 12:08:38 +05:30
import { s__, __ } from '~/locale';
2021-11-18 22:05:49 +05:30
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
2022-04-04 11:22:00 +05:30
import { MAX_LIST_COUNT, TOKEN_STATUS_ACTIVE } from '../constants';
2021-11-18 22:05:49 +05:30
import getClusterAgentQuery from '../graphql/queries/get_cluster_agent.query.graphql';
import TokenTable from './token_table.vue';
2022-01-26 12:08:38 +05:30
import ActivityEvents from './activity_events_list.vue';
2022-10-11 01:57:18 +05:30
import IntegrationStatus from './integration_status.vue';
2021-11-18 22:05:49 +05:30
export default {
i18n: {
installedInfo: s__('ClusterAgents|Created by %{name} %{time}'),
loadingError: s__('ClusterAgents|An error occurred while loading your agent'),
tokens: s__('ClusterAgents|Access tokens'),
unknownUser: s__('ClusterAgents|Unknown user'),
2022-01-26 12:08:38 +05:30
activity: __('Activity'),
2021-11-18 22:05:49 +05:30
},
apollo: {
clusterAgent: {
query: getClusterAgentQuery,
variables() {
return {
agentName: this.agentName,
projectPath: this.projectPath,
2022-04-04 11:22:00 +05:30
tokenStatus: TOKEN_STATUS_ACTIVE,
2021-11-18 22:05:49 +05:30
...this.cursor,
};
},
update: (data) => data?.project?.clusterAgent,
error() {
this.clusterAgent = null;
},
},
},
components: {
GlAlert,
GlBadge,
GlKeysetPagination,
GlLoadingIcon,
GlSprintf,
GlTab,
GlTabs,
TimeAgoTooltip,
TokenTable,
2022-01-26 12:08:38 +05:30
ActivityEvents,
2022-10-11 01:57:18 +05:30
IntegrationStatus,
2021-11-18 22:05:49 +05:30
},
2022-03-02 08:16:31 +05:30
inject: ['agentName', 'projectPath'],
2021-11-18 22:05:49 +05:30
data() {
return {
cursor: {
first: MAX_LIST_COUNT,
last: null,
},
};
},
computed: {
createdAt() {
return this.clusterAgent?.createdAt;
},
createdBy() {
return this.clusterAgent?.createdByUser?.name || this.$options.i18n.unknownUser;
},
isLoading() {
return this.$apollo.queries.clusterAgent.loading;
},
showPagination() {
return this.tokenPageInfo.hasPreviousPage || this.tokenPageInfo.hasNextPage;
},
tokenCount() {
return this.clusterAgent?.tokens?.count;
},
tokenPageInfo() {
return this.clusterAgent?.tokens?.pageInfo || {};
},
tokens() {
return this.clusterAgent?.tokens?.nodes || [];
},
},
methods: {
nextPage() {
this.cursor = {
first: MAX_LIST_COUNT,
last: null,
afterToken: this.tokenPageInfo.endCursor,
};
},
prevPage() {
this.cursor = {
first: null,
last: MAX_LIST_COUNT,
beforeToken: this.tokenPageInfo.startCursor,
};
},
},
};
</script>
<template>
<section>
2022-10-11 01:57:18 +05:30
<h1>{{ agentName }}</h1>
2021-11-18 22:05:49 +05:30
<gl-loading-icon v-if="isLoading && clusterAgent == null" size="lg" class="gl-m-3" />
2022-10-11 01:57:18 +05:30
<template v-else-if="clusterAgent">
2021-11-18 22:05:49 +05:30
<p data-testid="cluster-agent-create-info">
<gl-sprintf :message="$options.i18n.installedInfo">
<template #name>
{{ createdBy }}
</template>
<template #time>
<time-ago-tooltip :time="createdAt" />
</template>
</gl-sprintf>
</p>
2022-10-11 01:57:18 +05:30
<integration-status
:tokens="tokens"
class="gl-py-5 gl-border-t-1 gl-border-t-solid gl-border-t-gray-100"
/>
<gl-tabs
sync-active-tab-with-query-params
lazy
class="gl-border-t-1 gl-border-t-solid gl-border-t-gray-100"
>
2022-01-26 12:08:38 +05:30
<gl-tab :title="$options.i18n.activity" query-param-value="activity">
<activity-events :agent-name="agentName" :project-path="projectPath" />
</gl-tab>
2022-03-02 08:16:31 +05:30
<slot name="ee-security-tab" :cluster-agent-id="clusterAgent.id"></slot>
2022-01-26 12:08:38 +05:30
<gl-tab query-param-value="tokens">
2021-11-18 22:05:49 +05:30
<template #title>
<span data-testid="cluster-agent-token-count">
{{ $options.i18n.tokens }}
<gl-badge v-if="tokenCount" size="sm" class="gl-tab-counter-badge">{{
tokenCount
}}</gl-badge>
</span>
</template>
2022-07-16 23:28:13 +05:30
<gl-loading-icon v-if="isLoading" size="lg" class="gl-m-3" />
2021-11-18 22:05:49 +05:30
<div v-else>
2022-05-07 20:08:51 +05:30
<token-table :tokens="tokens" :cluster-agent-id="clusterAgent.id" :cursor="cursor" />
2021-11-18 22:05:49 +05:30
<div v-if="showPagination" class="gl-display-flex gl-justify-content-center gl-mt-5">
<gl-keyset-pagination v-bind="tokenPageInfo" @prev="prevPage" @next="nextPage" />
</div>
</div>
</gl-tab>
</gl-tabs>
2022-10-11 01:57:18 +05:30
</template>
2021-11-18 22:05:49 +05:30
<gl-alert v-else variant="danger" :dismissible="false">
{{ $options.i18n.loadingError }}
</gl-alert>
</section>
</template>