2018-12-05 23:21:45 +05:30
|
|
|
import _ from 'underscore';
|
|
|
|
import { __ } from '~/locale';
|
2018-12-13 13:39:08 +05:30
|
|
|
import { isScrolledToBottom } from '~/lib/utils/scroll_utils';
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
export const headerActions = state => {
|
|
|
|
if (state.job.new_issue_path) {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: __('New issue'),
|
|
|
|
path: state.job.new_issue_path,
|
|
|
|
cssClass:
|
|
|
|
'js-new-issue btn btn-success btn-inverted d-none d-md-block d-lg-block d-xl-block',
|
|
|
|
type: 'link',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const headerTime = state => (state.job.started ? state.job.started : state.job.created_at);
|
|
|
|
|
|
|
|
export const shouldRenderCalloutMessage = state =>
|
|
|
|
!_.isEmpty(state.job.status) && !_.isEmpty(state.job.callout_message);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When job has not started the key will be null
|
|
|
|
* When job started the key will be a string with a date.
|
|
|
|
*/
|
|
|
|
export const shouldRenderTriggeredLabel = state => _.isString(state.job.started);
|
|
|
|
|
|
|
|
export const hasEnvironment = state => !_.isEmpty(state.job.deployment_status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if it the job has trace.
|
|
|
|
* Used to check if it should render the job log or the empty state
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
2018-12-13 13:39:08 +05:30
|
|
|
export const hasTrace = state =>
|
|
|
|
state.job.has_trace || (!_.isEmpty(state.job.status) && state.job.status.group === 'running');
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
export const emptyStateIllustration = state =>
|
|
|
|
(state.job && state.job.status && state.job.status.illustration) || {};
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export const emptyStateAction = state =>
|
2019-01-03 12:48:30 +05:30
|
|
|
(state.job && state.job.status && state.job.status.action) || {};
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
export const isScrollingDown = state => isScrolledToBottom() && !state.isTraceComplete;
|
|
|
|
|
|
|
|
export const hasRunnersForProject = state =>
|
|
|
|
state.job.runners.available && !state.job.runners.online;
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
// prevent babel-plugin-rewire from generating an invalid default during karma tests
|
|
|
|
export default () => {};
|