2021-02-03 21:09:17 +00:00
|
|
|
<script>
|
2021-04-19 12:09:04 +00:00
|
|
|
import { GlAlert, GlLoadingIcon, GlTabs } from '@gitlab/ui';
|
2021-02-03 21:09:17 +00:00
|
|
|
import { s__ } from '~/locale';
|
2021-02-04 09:09:30 +00:00
|
|
|
import PipelineGraph from '~/pipelines/components/pipeline_graph/pipeline_graph.vue';
|
2021-02-12 18:08:59 +00:00
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
import {
|
|
|
|
CREATE_TAB,
|
2021-04-19 12:09:04 +00:00
|
|
|
EDITOR_APP_STATUS_EMPTY,
|
2021-03-22 21:08:59 +00:00
|
|
|
EDITOR_APP_STATUS_ERROR,
|
2021-04-19 12:09:04 +00:00
|
|
|
EDITOR_APP_STATUS_INVALID,
|
2021-03-22 21:08:59 +00:00
|
|
|
EDITOR_APP_STATUS_LOADING,
|
|
|
|
EDITOR_APP_STATUS_VALID,
|
2021-02-12 18:08:59 +00:00
|
|
|
LINT_TAB,
|
|
|
|
MERGED_TAB,
|
|
|
|
VISUALIZE_TAB,
|
|
|
|
} from '../constants';
|
2021-03-22 21:08:59 +00:00
|
|
|
import getAppStatus from '../graphql/queries/client/app_status.graphql';
|
2021-02-12 18:08:59 +00:00
|
|
|
import CiConfigMergedPreview from './editor/ci_config_merged_preview.vue';
|
2021-02-14 18:09:20 +00:00
|
|
|
import TextEditor from './editor/text_editor.vue';
|
2021-02-03 21:09:17 +00:00
|
|
|
import CiLint from './lint/ci_lint.vue';
|
|
|
|
import EditorTab from './ui/editor_tab.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
i18n: {
|
|
|
|
tabEdit: s__('Pipelines|Write pipeline configuration'),
|
|
|
|
tabGraph: s__('Pipelines|Visualize'),
|
|
|
|
tabLint: s__('Pipelines|Lint'),
|
2021-02-12 18:08:59 +00:00
|
|
|
tabMergedYaml: s__('Pipelines|View merged YAML'),
|
2021-04-19 12:09:04 +00:00
|
|
|
empty: {
|
|
|
|
visualization: s__(
|
|
|
|
'PipelineEditor|The pipeline visualization is displayed when the CI/CD configuration file has valid syntax.',
|
|
|
|
),
|
|
|
|
lint: s__(
|
|
|
|
'PipelineEditor|The CI/CD configuration is continuously validated. Errors and warnings are displayed when the CI/CD configuration file is not empty.',
|
|
|
|
),
|
|
|
|
merge: s__(
|
|
|
|
'PipelineEditor|The merged YAML view is displayed when the CI/CD configuration file has valid syntax.',
|
|
|
|
),
|
|
|
|
},
|
2021-02-12 18:08:59 +00:00
|
|
|
},
|
|
|
|
errorTexts: {
|
|
|
|
loadMergedYaml: s__('Pipelines|Could not load merged YAML content'),
|
|
|
|
},
|
|
|
|
tabConstants: {
|
|
|
|
CREATE_TAB,
|
|
|
|
LINT_TAB,
|
|
|
|
MERGED_TAB,
|
|
|
|
VISUALIZE_TAB,
|
2021-02-03 21:09:17 +00:00
|
|
|
},
|
|
|
|
components: {
|
2021-02-12 18:08:59 +00:00
|
|
|
CiConfigMergedPreview,
|
2021-02-03 21:09:17 +00:00
|
|
|
CiLint,
|
|
|
|
EditorTab,
|
2021-02-12 18:08:59 +00:00
|
|
|
GlAlert,
|
2021-02-03 21:09:17 +00:00
|
|
|
GlLoadingIcon,
|
|
|
|
GlTabs,
|
|
|
|
PipelineGraph,
|
|
|
|
TextEditor,
|
|
|
|
},
|
|
|
|
mixins: [glFeatureFlagsMixin()],
|
|
|
|
props: {
|
|
|
|
ciConfigData: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
ciFileContent: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-03-22 21:08:59 +00:00
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
appStatus: {
|
|
|
|
query: getAppStatus,
|
2021-02-03 21:09:17 +00:00
|
|
|
},
|
|
|
|
},
|
2021-02-12 18:08:59 +00:00
|
|
|
computed: {
|
2021-03-22 21:08:59 +00:00
|
|
|
hasAppError() {
|
|
|
|
// Not an invalid config and with `mergedYaml` data missing
|
|
|
|
return this.appStatus === EDITOR_APP_STATUS_ERROR;
|
|
|
|
},
|
2021-04-19 12:09:04 +00:00
|
|
|
isEmpty() {
|
|
|
|
return this.appStatus === EDITOR_APP_STATUS_EMPTY;
|
|
|
|
},
|
|
|
|
isInvalid() {
|
|
|
|
return this.appStatus === EDITOR_APP_STATUS_INVALID;
|
|
|
|
},
|
2021-03-22 21:08:59 +00:00
|
|
|
isValid() {
|
|
|
|
return this.appStatus === EDITOR_APP_STATUS_VALID;
|
|
|
|
},
|
|
|
|
isLoading() {
|
|
|
|
return this.appStatus === EDITOR_APP_STATUS_LOADING;
|
2021-02-12 18:08:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setCurrentTab(tabName) {
|
|
|
|
this.$emit('set-current-tab', tabName);
|
|
|
|
},
|
|
|
|
},
|
2021-02-03 21:09:17 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<gl-tabs class="file-editor gl-mb-3">
|
2021-02-12 18:08:59 +00:00
|
|
|
<editor-tab
|
|
|
|
class="gl-mb-3"
|
|
|
|
:title="$options.i18n.tabEdit"
|
|
|
|
lazy
|
|
|
|
data-testid="editor-tab"
|
|
|
|
@click="setCurrentTab($options.tabConstants.CREATE_TAB)"
|
|
|
|
>
|
2021-02-03 21:09:17 +00:00
|
|
|
<text-editor :value="ciFileContent" v-on="$listeners" />
|
|
|
|
</editor-tab>
|
2021-04-19 12:09:04 +00:00
|
|
|
<editor-tab
|
2021-02-12 18:08:59 +00:00
|
|
|
class="gl-mb-3"
|
2021-04-19 12:09:04 +00:00
|
|
|
:empty-message="$options.i18n.empty.visualization"
|
|
|
|
:is-empty="isEmpty"
|
|
|
|
:is-invalid="isInvalid"
|
2021-02-03 21:09:17 +00:00
|
|
|
:title="$options.i18n.tabGraph"
|
|
|
|
lazy
|
|
|
|
data-testid="visualization-tab"
|
2021-02-12 18:08:59 +00:00
|
|
|
@click="setCurrentTab($options.tabConstants.VISUALIZE_TAB)"
|
2021-02-03 21:09:17 +00:00
|
|
|
>
|
2021-03-22 21:08:59 +00:00
|
|
|
<gl-loading-icon v-if="isLoading" size="lg" class="gl-m-3" />
|
2021-02-03 21:09:17 +00:00
|
|
|
<pipeline-graph v-else :pipeline-data="ciConfigData" />
|
2021-04-19 12:09:04 +00:00
|
|
|
</editor-tab>
|
2021-02-12 18:08:59 +00:00
|
|
|
<editor-tab
|
|
|
|
class="gl-mb-3"
|
2021-04-19 12:09:04 +00:00
|
|
|
:empty-message="$options.i18n.empty.lint"
|
|
|
|
:is-empty="isEmpty"
|
2021-02-12 18:08:59 +00:00
|
|
|
:title="$options.i18n.tabLint"
|
|
|
|
data-testid="lint-tab"
|
|
|
|
@click="setCurrentTab($options.tabConstants.LINT_TAB)"
|
|
|
|
>
|
2021-03-22 21:08:59 +00:00
|
|
|
<gl-loading-icon v-if="isLoading" size="lg" class="gl-m-3" />
|
|
|
|
<ci-lint v-else :is-valid="isValid" :ci-config="ciConfigData" />
|
2021-02-03 21:09:17 +00:00
|
|
|
</editor-tab>
|
2021-04-19 12:09:04 +00:00
|
|
|
<editor-tab
|
2021-02-12 18:08:59 +00:00
|
|
|
v-if="glFeatures.ciConfigMergedTab"
|
|
|
|
class="gl-mb-3"
|
2021-04-19 12:09:04 +00:00
|
|
|
:empty-message="$options.i18n.empty.merge"
|
|
|
|
:keep-component-mounted="false"
|
|
|
|
:is-empty="isEmpty"
|
|
|
|
:is-invalid="isInvalid"
|
2021-02-12 18:08:59 +00:00
|
|
|
:title="$options.i18n.tabMergedYaml"
|
|
|
|
lazy
|
|
|
|
data-testid="merged-tab"
|
|
|
|
@click="setCurrentTab($options.tabConstants.MERGED_TAB)"
|
|
|
|
>
|
2021-03-22 21:08:59 +00:00
|
|
|
<gl-loading-icon v-if="isLoading" size="lg" class="gl-m-3" />
|
|
|
|
<gl-alert v-else-if="hasAppError" variant="danger" :dismissible="false">
|
2021-02-12 18:08:59 +00:00
|
|
|
{{ $options.errorTexts.loadMergedYaml }}
|
|
|
|
</gl-alert>
|
2021-04-19 12:09:04 +00:00
|
|
|
<ci-config-merged-preview v-else :ci-config-data="ciConfigData" v-on="$listeners" />
|
|
|
|
</editor-tab>
|
2021-02-03 21:09:17 +00:00
|
|
|
</gl-tabs>
|
|
|
|
</template>
|