debian-mirror-gitlab/app/assets/javascripts/jobs/store/getters.js

50 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-03-13 15:44:24 +05:30
import { isEmpty, isString } from 'lodash';
2018-12-13 13:39:08 +05:30
import { isScrolledToBottom } from '~/lib/utils/scroll_utils';
2018-12-05 23:21:45 +05:30
2021-04-17 20:07:23 +05:30
export const headerTime = (state) => (state.job.started ? state.job.started : state.job.created_at);
2018-12-05 23:21:45 +05:30
2021-03-08 18:12:59 +05:30
export const hasForwardDeploymentFailure = (state) =>
2021-01-29 00:20:46 +05:30
state?.job?.failure_reason === 'forward_deployment_failure';
2021-03-08 18:12:59 +05:30
export const hasUnmetPrerequisitesFailure = (state) =>
2021-01-29 00:20:46 +05:30
state?.job?.failure_reason === 'unmet_prerequisites';
2019-07-07 11:18:12 +05:30
2021-03-08 18:12:59 +05:30
export const shouldRenderCalloutMessage = (state) =>
2020-03-13 15:44:24 +05:30
!isEmpty(state.job.status) && !isEmpty(state.job.callout_message);
2018-12-05 23:21:45 +05:30
/**
* When job has not started the key will be null
* When job started the key will be a string with a date.
*/
2021-03-08 18:12:59 +05:30
export const shouldRenderTriggeredLabel = (state) => isString(state.job.started);
2018-12-05 23:21:45 +05:30
2021-03-08 18:12:59 +05:30
export const hasEnvironment = (state) => !isEmpty(state.job.deployment_status);
2018-12-05 23:21:45 +05:30
/**
* Checks if it the job has trace.
* Used to check if it should render the job log or the empty state
* @returns {Boolean}
*/
2021-03-08 18:12:59 +05:30
export const hasTrace = (state) =>
2020-03-13 15:44:24 +05:30
state.job.has_trace || (!isEmpty(state.job.status) && state.job.status.group === 'running');
2018-12-05 23:21:45 +05:30
2021-03-11 19:13:27 +05:30
export const emptyStateIllustration = (state) => state?.job?.status?.illustration || {};
2018-12-05 23:21:45 +05:30
2021-03-11 19:13:27 +05:30
export const emptyStateAction = (state) => state?.job?.status?.action || null;
2018-12-13 13:39:08 +05:30
2019-07-07 11:18:12 +05:30
/**
* Shared runners limit is only rendered when
* used quota is bigger or equal than the limit
*
* @returns {Boolean}
*/
2021-03-08 18:12:59 +05:30
export const shouldRenderSharedRunnerLimitWarning = (state) =>
2020-03-13 15:44:24 +05:30
!isEmpty(state.job.runners) &&
!isEmpty(state.job.runners.quota) &&
2019-07-07 11:18:12 +05:30
state.job.runners.quota.used >= state.job.runners.quota.limit;
2021-03-08 18:12:59 +05:30
export const isScrollingDown = (state) => isScrolledToBottom() && !state.isTraceComplete;
2018-12-13 13:39:08 +05:30
2021-03-08 18:12:59 +05:30
export const hasRunnersForProject = (state) =>
2021-03-11 19:13:27 +05:30
state?.job?.runners?.available && !state?.job?.runners?.online;