Skip to content

Commit 9630d1a

Browse files
author
Guillaume Chau
committed
feat(settings): new tags
1 parent 5f0a913 commit 9630d1a

File tree

4 files changed

+77
-6
lines changed

4 files changed

+77
-6
lines changed

src/devtools/App.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@
130130
<VueGroupButton
131131
v-tooltip="$t('App.settings.tooltip')"
132132
:class="{
133-
'icon-button': !$responsive.wide
133+
'icon-button': !$responsive.wide,
134+
info: hasNewSettings
134135
}"
136+
:tag="hasNewSettings ? 'new' : null"
135137
value="settings"
136138
icon-left="settings_applications"
137139
class="settings-tab flat"
@@ -164,8 +166,8 @@
164166
import { SPECIAL_TOKENS } from '../util'
165167
import Keyboard from './mixins/keyboard'
166168
import GroupDropdown from 'components/GroupDropdown.vue'
167-
168169
import { mapState } from 'vuex'
170+
import { SETTINGS_VERSION_ID, SETTINGS_VERSION } from './views/settings/SettingsTab.vue'
169171
170172
export default {
171173
name: 'App',
@@ -222,7 +224,8 @@ export default {
222224
routingTabs: [
223225
{ name: 'router', label: 'History', icon: 'directions' },
224226
{ name: 'routes', label: 'Routes', icon: 'book' }
225-
]
227+
],
228+
settingsVersion: parseInt(localStorage.getItem(SETTINGS_VERSION_ID))
226229
}
227230
},
228231
@@ -241,7 +244,18 @@ export default {
241244
get () { return this.$route.matched[0].name },
242245
set (value) {
243246
this.$router.push({ name: value })
247+
248+
this.$nextTick(() => {
249+
if (value === 'settings') {
250+
this.settingsVersion = SETTINGS_VERSION
251+
localStorage.setItem(SETTINGS_VERSION_ID, SETTINGS_VERSION)
252+
}
253+
})
244254
}
255+
},
256+
257+
hasNewSettings () {
258+
return this.settingsVersion !== SETTINGS_VERSION
245259
}
246260
},
247261

src/devtools/views/settings/GlobalPreferences.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@
7777
</VueSwitch>
7878
</VueFormField>
7979

80-
<VueFormField
81-
title="New Vuex backend"
82-
>
80+
<VueFormField>
81+
<template #title>
82+
New Vuex backend
83+
<NewTag :version="1" />
84+
</template>
8385
<VueSwitch v-model="$shared.vuexNewBackend">
8486
Enable
8587
</VueSwitch>
@@ -104,3 +106,13 @@
104106
</VueFormField>
105107
</div>
106108
</template>
109+
110+
<script>
111+
import NewTag from './NewTag.vue'
112+
113+
export default {
114+
components: {
115+
NewTag
116+
}
117+
}
118+
</script>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<template>
2+
<div
3+
v-if="version > currentSettingsVersion"
4+
class="new-tag"
5+
>
6+
New
7+
</div>
8+
</template>
9+
10+
<script>
11+
export default {
12+
inject: [
13+
'currentSettingsVersion'
14+
],
15+
16+
props: {
17+
version: {
18+
type: Number,
19+
required: true
20+
}
21+
}
22+
}
23+
</script>
24+
25+
<style lang="stylus" scoped>
26+
.new-tag
27+
display inline-block
28+
background $vue-ui-color-info
29+
color $vue-ui-color-light
30+
font-size 9px
31+
font-weight bold
32+
text-transform uppercase
33+
padding 1px 3px
34+
border-radius $br
35+
</style>

src/devtools/views/settings/SettingsTab.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@
88
import GlobalPreferences from './GlobalPreferences.vue'
99
import { mapState } from 'vuex'
1010
11+
export const SETTINGS_VERSION = 1
12+
export const SETTINGS_VERSION_ID = 'vue-devtools-settings-version'
13+
1114
export default {
1215
components: { GlobalPreferences },
1316
17+
provide () {
18+
return {
19+
settingsVersion: SETTINGS_VERSION,
20+
currentSettingsVersion: parseInt(localStorage.getItem(SETTINGS_VERSION_ID)) || 0
21+
}
22+
},
23+
1424
computed: mapState('events', [
1525
'enabled'
1626
])

0 commit comments

Comments
 (0)