1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<script>
import { GlTable, GlButton, GlModalDirective, GlSprintf } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex';
import { s__ } from '~/locale';
export default {
fields: [
{
key: 'freezeStart',
label: s__('DeployFreeze|Freeze start'),
},
{
key: 'freezeEnd',
label: s__('DeployFreeze|Freeze end'),
},
{
key: 'cronTimezone',
label: s__('DeployFreeze|Time zone'),
},
{
key: 'edit',
label: s__('DeployFreeze|Edit'),
},
],
translations: {
addDeployFreeze: s__('DeployFreeze|Add deploy freeze'),
emptyStateText: s__(
'DeployFreeze|No deploy freezes exist for this project. To add one, select %{strongStart}Add deploy freeze%{strongEnd}',
),
},
components: {
GlTable,
GlButton,
GlSprintf,
},
directives: {
GlModal: GlModalDirective,
},
computed: {
...mapState(['freezePeriods']),
tableIsNotEmpty() {
return this.freezePeriods?.length > 0;
},
},
mounted() {
this.fetchFreezePeriods();
},
methods: {
...mapActions(['fetchFreezePeriods', 'setFreezePeriod']),
},
};
</script>
<template>
<div class="deploy-freeze-table">
<gl-table
data-testid="deploy-freeze-table"
:items="freezePeriods"
:fields="$options.fields"
show-empty
stacked="lg"
>
<template #cell(cronTimezone)="{ item }">
{{ item.cronTimezone.formattedTimezone }}
</template>
<template #cell(edit)="{ item }">
<gl-button
v-gl-modal.deploy-freeze-modal
icon="pencil"
data-testid="edit-deploy-freeze"
:aria-label="__('Edit deploy freeze')"
@click="setFreezePeriod(item)"
/>
</template>
<template #empty>
<p data-testid="empty-freeze-periods" class="gl-text-center text-plain">
<gl-sprintf :message="$options.translations.emptyStateText">
<template #strong="{ content }">
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
</p>
</template>
</gl-table>
<gl-button
v-gl-modal.deploy-freeze-modal
data-testid="add-deploy-freeze"
category="primary"
variant="confirm"
>
{{ $options.translations.addDeployFreeze }}
</gl-button>
</div>
</template>
|