debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/ci_icon.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlIcon } from '@gitlab/ui';
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
/**
* Renders CI icon based on API response shared between all places where it is used.
*
* Receives status object containing:
* status: {
* group:"running" // used for CSS class
* icon: "icon_status_running" // used to render the icon
* }
*
* Used in:
2022-07-16 23:28:13 +05:30
* - Extended MR Popover
2018-10-15 14:42:47 +05:30
* - Jobs show view header
* - Jobs show view sidebar
2022-07-16 23:28:13 +05:30
* - Jobs table
2019-07-07 11:18:12 +05:30
* - Linked pipelines
2022-07-16 23:28:13 +05:30
* - Pipeline graph
* - Pipeline mini graph
* - Pipeline show view badge
* - Pipelines table Badge
*/
/*
* These sizes are defined in gitlab-ui/src/scss/variables.scss
* under '$gl-icon-sizes'
2018-10-15 14:42:47 +05:30
*/
2022-07-16 23:28:13 +05:30
const validSizes = [8, 12, 14, 16, 24, 32, 48, 72];
2018-11-08 19:23:39 +05:30
2018-10-15 14:42:47 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2018-10-15 14:42:47 +05:30
},
props: {
status: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
size: {
type: Number,
required: false,
default: 16,
validator(value) {
return validSizes.includes(value);
},
},
2022-07-23 23:45:48 +05:30
isActive: {
type: Boolean,
required: false,
default: false,
},
isBorderless: {
2018-11-08 19:23:39 +05:30
type: Boolean,
required: false,
default: false,
},
2022-07-16 23:28:13 +05:30
isInteractive: {
type: Boolean,
required: false,
default: false,
},
2019-07-07 11:18:12 +05:30
cssClasses: {
type: String,
required: false,
default: '',
},
2018-10-15 14:42:47 +05:30
},
computed: {
2022-07-16 23:28:13 +05:30
wrapperStyleClasses() {
2018-10-15 14:42:47 +05:30
const status = this.status.group;
2022-07-16 23:28:13 +05:30
return `ci-status-icon ci-status-icon-${status} js-ci-status-icon-${status} gl-rounded-full gl-justify-content-center`;
2017-08-17 22:00:37 +05:30
},
2018-11-08 19:23:39 +05:30
icon() {
2022-07-23 23:45:48 +05:30
return this.isBorderless ? `${this.status.icon}_borderless` : this.status.icon;
2018-11-08 19:23:39 +05:30
},
2018-10-15 14:42:47 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
2022-07-16 23:28:13 +05:30
<span
2022-07-23 23:45:48 +05:30
:class="[
wrapperStyleClasses,
{ interactive: isInteractive, active: isActive, borderless: isBorderless },
]"
2022-07-16 23:28:13 +05:30
:style="{ height: `${size}px`, width: `${size}px` }"
2022-07-23 23:45:48 +05:30
data-testid="ci-icon-wrapper"
2022-07-16 23:28:13 +05:30
>
2021-09-30 23:02:18 +05:30
<gl-icon :name="icon" :size="size" :class="cssClasses" :aria-label="status.icon" />
2021-02-22 17:27:13 +05:30
</span>
2017-08-17 22:00:37 +05:30
</template>