blob: 6fd45c45683c05ff6d0b06883146e3941aafe4cb [file] [log] [blame]
Adrià Vilanova Martínez035b5432021-09-03 14:16:59 +02001<script>
2import {browsers} from '../consts.js';
3
4export default {
5 props: {
6 killSwitch: Object,
7 canDisable: Boolean,
8 },
9 emits: [
10 'wantsToDisableKillSwitch',
11 ],
12 computed: {
13 versionsText() {
14 if (this.killSwitch?.getMinVersion() == '' && this.killSwitch?.getMaxVersion() == '')
15 return 'All';
16
17 return 'From ' + (this.killSwitch?.getMinVersion() || '...') + ' to '+ (this.killSwitch?.getMaxVersion() || '...');
18 },
19 browsersText() {
20 return this.killSwitch?.getBrowsersList()?.map(b => browsers[parseInt(b)]).join(', ') ?? 'undefined';
21 },
22 },
23};
24</script>
25
26<template>
27 <div class="main">
28 <mcw-button @click="$emit('wantsToDisableKillSwitch', killSwitch)" class="disable-btn" v-if="canDisable && killSwitch?.getActive()">
29 Disable
30 </mcw-button>
31 <div class="feature-name">{{ killSwitch?.getFeature()?.getCodename() }}</div>
32 <div class="status"><span class="status--label">Status:</span> <span class="status-text" :class="{'status-text--active': killSwitch?.getActive()}">{{ killSwitch?.getActive() ? 'active (feature is force disabled)' : 'no longer active' }}</span></div>
33 <div class="details-container">
34 <div class="details">
35 <div class="details--title">Versions affected</div>
36 <div class="details--content">{{ versionsText }}</div>
37 </div>
38 <div class="details">
39 <div class="details--title">Browsers affected</div>
40 <div class="details--content">{{ browsersText }}</div>
41 </div>
42 </div>
43 </div>
44</template>
45
46<style scoped lang="scss">
47@use "@material/theme/color-palette" as palette;
48
49.main {
50 position: relative;
51 width: calc(100% - 32px);
52 max-width: 500px;
53 padding: 16px;
54 border: solid 1px palette.$grey-500;
55 border-radius: 4px;
56}
57
58.disable-btn {
59 position: absolute;
60 top: 16px;
61 right: 16px;
62}
63
64.feature-name {
65 color: palette.$grey-900;
66 font-family: 'Roboto Mono', monospace;
67 font-weight: 500;
68 font-size: 20px;
69 margin-bottom: 8px;
70}
71
72.status {
73 color: palette.$grey-700;
74}
75
76.status--label {
77 font-weight: 500;
78}
79
80.status-text.status-text--active {
81 color: palette.$red-700;
82}
83
84.details-container {
85 margin-top: 16px;
86 display: flex;
87 flex-direction: row;
88 justify-content: space-around;
89}
90
91.details {
92 display: flex;
93 flex-direction: column;
94 align-items: center;
95}
96
97.details--title {
98 font-weight: 500;
99 font-size: 17px;
100 text-align: center;
101}
102
103.details--content {
104 font-size: 15px;
105 text-align: center;
106}
107</style>