mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-05-19 08:48:08 +00:00
b2cfa37682
Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com>
69 lines
2.1 KiB
Vue
69 lines
2.1 KiB
Vue
<template>
|
|
<Panel>
|
|
<div class="grid justify-center gap-x-4 text-left grid-3-1">
|
|
<template v-for="(error, i) in pipeline.errors" :key="i">
|
|
<Icon
|
|
name="attention"
|
|
class="flex-shrink-0 my-1"
|
|
:class="{
|
|
'text-wp-state-warn-100': error.is_warning,
|
|
'text-wp-state-error-100': !error.is_warning,
|
|
}"
|
|
/>
|
|
<span>[{{ error.type }}]</span>
|
|
<span
|
|
v-if="isLinterError(error) || isDeprecationError(error) || isBadHabitError(error)"
|
|
class="whitespace-nowrap"
|
|
>
|
|
<span v-if="error.data?.file" class="font-bold">{{ error.data?.file }}: </span>
|
|
<span>{{ error.data?.field }}</span>
|
|
</span>
|
|
<span v-else />
|
|
<a
|
|
v-if="isDeprecationError(error) || isBadHabitError(error)"
|
|
:href="error.data?.docs"
|
|
target="_blank"
|
|
class="underline col-span-full col-start-2 md:col-span-auto md:col-start-auto"
|
|
>
|
|
{{ error.message }}
|
|
</a>
|
|
<span v-else class="col-span-full col-start-2 md:col-span-auto md:col-start-auto">
|
|
{{ error.message }}
|
|
</span>
|
|
</template>
|
|
</div>
|
|
</Panel>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { inject, Ref } from 'vue';
|
|
|
|
import Panel from '~/components/layout/Panel.vue';
|
|
import type { Pipeline, PipelineError } from '~/lib/api/types';
|
|
|
|
const pipeline = inject<Ref<Pipeline>>('pipeline');
|
|
if (!pipeline) {
|
|
throw new Error('Unexpected: "pipeline" should be provided at this place');
|
|
}
|
|
|
|
function isLinterError(error: PipelineError): error is PipelineError<{ file?: string; field: string }> {
|
|
return error.type === 'linter';
|
|
}
|
|
|
|
function isDeprecationError(
|
|
error: PipelineError,
|
|
): error is PipelineError<{ file: string; field: string; docs: string }> {
|
|
return error.type === 'deprecation';
|
|
}
|
|
|
|
function isBadHabitError(error: PipelineError): error is PipelineError<{ file?: string; field: string; docs: string }> {
|
|
return error.type === 'bad_habit';
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.grid-3-1 {
|
|
grid-template-columns: auto auto auto 1fr;
|
|
}
|
|
</style>
|