debian-mirror-gitlab/app/assets/javascripts/ide/stores/mutations/alert.js

22 lines
632 B
JavaScript
Raw Normal View History

2021-06-08 01:23:25 +05:30
import {
DETECT_ENVIRONMENTS_GUIDANCE_ALERT,
DISMISS_ENVIRONMENTS_GUIDANCE_ALERT,
} from '../mutation_types';
export default {
[DETECT_ENVIRONMENTS_GUIDANCE_ALERT](state, stages) {
if (!stages) {
return;
}
const hasEnvironments = stages?.nodes?.some((stage) =>
stage.groups.nodes.some((group) => group.jobs.nodes.some((job) => job.environment)),
);
const hasParsedCi = Array.isArray(stages.nodes);
state.environmentsGuidanceAlertDetected = !hasEnvironments && hasParsedCi;
},
[DISMISS_ENVIRONMENTS_GUIDANCE_ALERT](state) {
state.environmentsGuidanceAlertDismissed = true;
},
};