debian-mirror-gitlab/app/assets/javascripts/ci/artifacts/components/job_checkbox.vue

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

71 lines
1.6 KiB
Vue
Raw Normal View History

2023-05-27 22:25:52 +05:30
<script>
2023-07-09 08:55:56 +05:30
import { GlFormCheckbox, GlTooltipDirective } from '@gitlab/ui';
import { I18N_BULK_DELETE_MAX_SELECTED } from '~/ci/artifacts/constants';
2023-05-27 22:25:52 +05:30
export default {
name: 'JobCheckbox',
components: {
GlFormCheckbox,
},
2023-07-09 08:55:56 +05:30
directives: {
GlTooltip: GlTooltipDirective,
},
2023-05-27 22:25:52 +05:30
props: {
hasArtifacts: {
type: Boolean,
required: true,
},
selectedArtifacts: {
type: Array,
required: true,
},
unselectedArtifacts: {
type: Array,
required: true,
},
2023-07-09 08:55:56 +05:30
isSelectedArtifactsLimitReached: {
type: Boolean,
required: true,
},
2023-05-27 22:25:52 +05:30
},
computed: {
disabled() {
2023-07-09 08:55:56 +05:30
return (
!this.hasArtifacts ||
(this.isSelectedArtifactsLimitReached && !(this.checked || this.indeterminate))
);
2023-05-27 22:25:52 +05:30
},
checked() {
return this.hasArtifacts && this.unselectedArtifacts.length === 0;
},
indeterminate() {
return this.selectedArtifacts.length > 0 && this.unselectedArtifacts.length > 0;
},
2023-07-09 08:55:56 +05:30
tooltipText() {
return this.isSelectedArtifactsLimitReached && this.disabled
? I18N_BULK_DELETE_MAX_SELECTED
: '';
},
2023-05-27 22:25:52 +05:30
},
methods: {
handleInput(checked) {
if (checked) {
this.unselectedArtifacts.forEach((node) => this.$emit('selectArtifact', node, true));
} else {
this.selectedArtifacts.forEach((node) => this.$emit('selectArtifact', node, false));
}
},
},
};
</script>
<template>
<gl-form-checkbox
2023-07-09 08:55:56 +05:30
v-gl-tooltip.right
:title="tooltipText"
2023-05-27 22:25:52 +05:30
:disabled="disabled"
:checked="checked"
:indeterminate="indeterminate"
@input="handleInput"
/>
</template>