diff options
Diffstat (limited to 'app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue')
-rw-r--r-- | app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue b/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue index af6bd7079ba..96b82a20364 100644 --- a/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue +++ b/app/assets/javascripts/packages_and_registries/package_registry/components/details/package_history.vue @@ -1,5 +1,6 @@ <script> -import { GlLink, GlSprintf } from '@gitlab/ui'; +import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui'; +import * as Sentry from '@sentry/browser'; import { first } from 'lodash'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { truncateSha } from '~/lib/utils/text_utility'; @@ -7,6 +8,12 @@ import { s__, n__ } from '~/locale'; import { HISTORY_PIPELINES_LIMIT } from '~/packages_and_registries/shared/constants'; import HistoryItem from '~/vue_shared/components/registry/history_item.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; +import { + GRAPHQL_PACKAGE_PIPELINES_PAGE_SIZE, + FETCH_PACKAGE_PIPELINES_ERROR_MESSAGE, +} from '../../constants'; +import getPackagePipelinesQuery from '../../graphql/queries/get_package_pipelines.query.graphql'; +import PackageHistoryLoader from './package_history_loader.vue'; export default { name: 'PackageHistory', @@ -20,11 +27,14 @@ export default { combinedUpdateText: s__( 'PackageRegistry|Package updated by commit %{link} on branch %{branch}, built by pipeline %{pipeline}, and published to the registry %{datetime}', ), + fetchPackagePipelinesErrorMessage: FETCH_PACKAGE_PIPELINES_ERROR_MESSAGE, }, components: { + GlAlert, GlLink, GlSprintf, HistoryItem, + PackageHistoryLoader, TimeAgoTooltip, }, props: { @@ -37,15 +47,28 @@ export default { required: true, }, }, + apollo: { + pipelines: { + query: getPackagePipelinesQuery, + variables() { + return this.queryVariables; + }, + update(data) { + return data.package?.pipelines?.nodes || []; + }, + error(error) { + this.fetchPackagePipelinesError = true; + Sentry.captureException(error); + }, + }, + }, data() { return { - showDescription: false, + pipelines: [], + fetchPackagePipelinesError: false, }; }, computed: { - pipelines() { - return this.packageEntity?.pipelines?.nodes || []; - }, firstPipeline() { return first(this.pipelines); }, @@ -65,6 +88,15 @@ export default { this.archivedLines, ); }, + isLoading() { + return this.$apollo.queries.pipelines.loading; + }, + queryVariables() { + return { + id: this.packageEntity.id, + first: GRAPHQL_PACKAGE_PIPELINES_PAGE_SIZE, + }; + }, }, methods: { truncate(value) { @@ -80,7 +112,15 @@ export default { <template> <div class="issuable-discussion"> <h3 class="gl-font-lg" data-testid="title">{{ __('History') }}</h3> - <ul class="timeline main-notes-list notes gl-mb-4" data-testid="timeline"> + <gl-alert + v-if="fetchPackagePipelinesError" + variant="danger" + @dismiss="fetchPackagePipelinesError = false" + > + {{ $options.i18n.fetchPackagePipelinesErrorMessage }} + </gl-alert> + <package-history-loader v-if="isLoading" /> + <ul v-else class="timeline main-notes-list notes gl-mb-4" data-testid="timeline"> <history-item icon="clock" data-testid="created-on"> <gl-sprintf :message="$options.i18n.createdOn"> <template #name> |