Skip to content

Commit f3e70da

Browse files
authored
show save button in ide when dirtyflag is sent to parent (#1594)
* show save button in ide when dirtyflag is sent to parent * remove redundant logic * no point in having the button disapear the way the current logic works * only show if stsApplication * further cleanup, adding query to state so do not have redundant logic * more cleanup * even more cleanup * cleanup * remove unused code
1 parent 22a7ca3 commit f3e70da

File tree

5 files changed

+27
-47
lines changed

5 files changed

+27
-47
lines changed

src/App.vue

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export default defineComponent({
152152
showExceptionIcon() {
153153
return this.$store.state.zap.showExceptionIcon
154154
},
155+
query() {
156+
return this.$store.state.zap.query // Access the query string from Vuex
157+
},
155158
uiThemeCategory: {
156159
get() {
157160
if (this.$store.state.zap.isMultiConfig) {
@@ -171,12 +174,9 @@ export default defineComponent({
171174
},
172175
methods: {
173176
parseQueryString() {
174-
let search = window.location.search
175-
176-
if (search[0] === '?') {
177-
search = search.substring(1)
178-
}
179-
this.query = querystring.parse(search)
177+
const searchParams = new URLSearchParams(window.location.search)
178+
const query = Object.fromEntries(searchParams.entries()) // Parse query string into an object
179+
this.$store.commit('zap/setQuery', query) // Store it in Vuex
180180
},
181181
182182
setTheme() {
@@ -263,37 +263,28 @@ export default defineComponent({
263263
)
264264
})
265265
}
266-
267-
// Parse the query string into the front end.
268-
let search = window.location.search
269-
270-
if (search[0] === '?') {
271-
search = search.substring(1)
272-
}
273-
274-
let query = querystring.parse(search)
275-
if (query[`uiMode`]) {
276-
this.$store.dispatch('zap/setDefaultUiMode', query[`uiMode`])
266+
if (this.query[`uiMode`]) {
267+
this.$store.dispatch('zap/setDefaultUiMode', this.query[`uiMode`])
277268
}
278269
279-
if (`debugNavBar` in query) {
270+
if (`debugNavBar` in this.query) {
280271
this.$store.dispatch(
281272
'zap/setDebugNavBar',
282-
query[`debugNavBar`] === 'true'
273+
this.query[`debugNavBar`] === 'true'
283274
)
284275
} else {
285276
// If we don't specify it, default is on.
286277
this.$store.dispatch('zap/setDebugNavBar', true)
287278
}
288279
289-
if ('standalone' in query) {
290-
this.$store.dispatch('zap/setStandalone', query['standalone'])
280+
if ('standalone' in this.query) {
281+
this.$store.dispatch('zap/setStandalone', this.query['standalone'])
291282
}
292283
293-
if (`setSaveButtonVisible` in query) {
284+
if (`setSaveButtonVisible` in this.query) {
294285
this.$store.dispatch(
295286
'zap/setSaveButtonVisible',
296-
query[`setSaveButtonVisible`] === 'true'
287+
this.query[`setSaveButtonVisible`] === 'true'
297288
)
298289
} else {
299290
// If we don't specify it, default is off.
@@ -318,7 +309,7 @@ export default defineComponent({
318309
319310
// load initial UC component state
320311
this.$store.dispatch(`zap/loadUcComponentState`)
321-
if (query[`newConfig`]) {
312+
if (this.query[`newConfig`]) {
322313
this.loadInitialEndpoints()
323314
}
324315

src/components/ZCLToolbar.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@
6161
flat
6262
no-caps
6363
@click="saveChanges"
64-
v-if="
65-
this.$store.state.zap.saveButtonVisible && this.$store.state.zap.isDirty
66-
"
64+
v-if="showSaveButton"
6765
>
6866
<div class="text-center">
6967
<q-icon name="o_save" />
@@ -245,6 +243,12 @@ export default {
245243
name: 'ZCLToolbar',
246244
mixins: [CommonMixin],
247245
computed: {
246+
query() {
247+
return this.$store.state.zap.query // Access the query string from Vuex
248+
},
249+
showSaveButton() {
250+
return !!this.query['stsApplicationId'] // Use optional chaining and double negation for clarity
251+
},
248252
isCoreDocumentationAvailable() {
249253
return (
250254
this.$store.state.zap.genericOptions[

src/store/zap/actions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,15 +1171,6 @@ export function setDebugNavBar(context, debugNavBar) {
11711171
context.commit('setDebugNavBar', debugNavBar)
11721172
}
11731173

1174-
/**
1175-
* Show or hide the Save button in ZAP UI.
1176-
* @param {*} context
1177-
* @param {*} saveButtonVisible
1178-
*/
1179-
export function setSaveButtonVisible(context, saveButtonVisible) {
1180-
context.commit('setSaveButtonVisible', saveButtonVisible)
1181-
}
1182-
11831174
/**
11841175
* Set the mode of ZAP UI.
11851176
* @param {*} context

src/store/zap/mutations.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export const updateShowDevTools = (state) => {
4949
state.showDevTools = !state.showDevTools
5050
}
5151

52+
export const setQuery = (state, query) => {
53+
state.query = query
54+
}
55+
5256
/**
5357
* Set the information text in the state
5458
* @param {*} state
@@ -785,15 +789,6 @@ export function setDebugNavBar(state, debugNavBar) {
785789
state.debugNavBar = debugNavBar
786790
}
787791

788-
/**
789-
* Show save button in the UI using the state.
790-
* @param {*} state
791-
* @param {*} saveButtonVisible
792-
*/
793-
export function setSaveButtonVisible(state, saveButtonVisible) {
794-
state.saveButtonVisible = saveButtonVisible
795-
}
796-
797792
/**
798793
* Set standalone mode for ZAP using the state.
799794
* @param {*} state

src/store/zap/state.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ export default function () {
5252
featureMapValue: 0,
5353
zclDeviceTypes: {},
5454
endpoints: [],
55+
query: {},
5556
genericOptions: {},
5657
selectedGenericOptions: {},
5758
projectPackages: [],
5859
allPackages: [],
59-
isDirty: false,
60-
saveButtonVisible: false,
6160
clusterManager: {
6261
openDomains: {},
6362
lastSelectedDomain: null,

0 commit comments

Comments
 (0)