diff options
Diffstat (limited to 'app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue')
-rw-r--r-- | app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue | 123 |
1 files changed, 15 insertions, 108 deletions
diff --git a/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue b/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue index b6c4e617a90..572abe2a24a 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue @@ -1,22 +1,17 @@ <script> import { GlButton, GlTooltipDirective, GlModalDirective } from '@gitlab/ui'; -import eventHub from '../../event_hub'; import { __ } from '~/locale'; +import CiBadge from '~/vue_shared/components/ci_badge_link.vue'; +import CommitComponent from '~/vue_shared/components/commit.vue'; +import { PIPELINES_TABLE } from '../../constants'; +import eventHub from '../../event_hub'; +import PipelineTriggerer from './pipeline_triggerer.vue'; +import PipelineUrl from './pipeline_url.vue'; import PipelinesActionsComponent from './pipelines_actions.vue'; import PipelinesArtifactsComponent from './pipelines_artifacts.vue'; -import CiBadge from '~/vue_shared/components/ci_badge_link.vue'; import PipelineStage from './stage.vue'; -import PipelineUrl from './pipeline_url.vue'; -import PipelineTriggerer from './pipeline_triggerer.vue'; import PipelinesTimeago from './time_ago.vue'; -import CommitComponent from '~/vue_shared/components/commit.vue'; -import { PIPELINES_TABLE } from '../../constants'; -/** - * Pipeline table row. - * - * Given the received object renders a table row in the pipelines' table. - */ export default { i18n: { cancelTitle: __('Cancel'), @@ -127,116 +122,30 @@ export default { return commitAuthorInformation; }, - - /** - * If provided, returns the commit tag. - * Needed to render the commit component column. - * - * @returns {String|Undefined} - */ commitTag() { - if (this.pipeline.ref && this.pipeline.ref.tag) { - return this.pipeline.ref.tag; - } - return undefined; + return this.pipeline?.ref?.tag; }, - - /** - * If provided, returns the commit ref. - * Needed to render the commit component column. - * - * Matches `path` prop sent in the API to `ref_url` prop needed - * in the commit component. - * - * @returns {Object|Undefined} - */ commitRef() { - if (this.pipeline.ref) { - return Object.keys(this.pipeline.ref).reduce((accumulator, prop) => { - if (prop === 'path') { - accumulator.ref_url = this.pipeline.ref[prop]; - } else { - accumulator[prop] = this.pipeline.ref[prop]; - } - return accumulator; - }, {}); - } - - return undefined; + return this.pipeline?.ref; }, - - /** - * If provided, returns the commit url. - * Needed to render the commit component column. - * - * @returns {String|Undefined} - */ commitUrl() { - if (this.pipeline.commit && this.pipeline.commit.commit_path) { - return this.pipeline.commit.commit_path; - } - return undefined; + return this.pipeline?.commit?.commit_path; }, - - /** - * If provided, returns the commit short sha. - * Needed to render the commit component column. - * - * @returns {String|Undefined} - */ commitShortSha() { - if (this.pipeline.commit && this.pipeline.commit.short_id) { - return this.pipeline.commit.short_id; - } - return undefined; + return this.pipeline?.commit?.short_id; }, - - /** - * If provided, returns the commit title. - * Needed to render the commit component column. - * - * @returns {String|Undefined} - */ commitTitle() { - if (this.pipeline.commit && this.pipeline.commit.title) { - return this.pipeline.commit.title; - } - return undefined; + return this.pipeline?.commit?.title; }, - - /** - * Timeago components expects a number - * - * @return {type} description - */ pipelineDuration() { - if (this.pipeline.details && this.pipeline.details.duration) { - return this.pipeline.details.duration; - } - - return 0; + return this.pipeline?.details?.duration ?? 0; }, - - /** - * Timeago component expects a String. - * - * @return {String} - */ pipelineFinishedAt() { - if (this.pipeline.details && this.pipeline.details.finished_at) { - return this.pipeline.details.finished_at; - } - - return ''; + return this.pipeline?.details?.finished_at ?? ''; }, - pipelineStatus() { - if (this.pipeline.details && this.pipeline.details.status) { - return this.pipeline.details.status; - } - return {}; + return this.pipeline?.details?.status ?? {}; }, - displayPipelineActions() { return ( this.pipeline.flags.retryable || @@ -245,11 +154,9 @@ export default { this.pipeline.details.artifacts.length ); }, - isChildView() { return this.viewType === 'child'; }, - isCancelling() { return this.cancelingPipeline === this.pipeline.id; }, @@ -355,7 +262,7 @@ export default { :title="$options.i18n.redeployTitle" :disabled="isRetrying" :loading="isRetrying" - class="js-pipelines-retry-button btn-retry" + class="js-pipelines-retry-button" data-qa-selector="pipeline_retry_button" icon="repeat" variant="default" |