Skip to content

show save button in ide when dirtyflag is sent to parent #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
39 changes: 15 additions & 24 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export default defineComponent({
showExceptionIcon() {
return this.$store.state.zap.showExceptionIcon
},
query() {
return this.$store.state.zap.query // Access the query string from Vuex
},
uiThemeCategory: {
get() {
if (this.$store.state.zap.isMultiConfig) {
Expand All @@ -171,12 +174,9 @@ export default defineComponent({
},
methods: {
parseQueryString() {
let search = window.location.search

if (search[0] === '?') {
search = search.substring(1)
}
this.query = querystring.parse(search)
const searchParams = new URLSearchParams(window.location.search)
const query = Object.fromEntries(searchParams.entries()) // Parse query string into an object
this.$store.commit('zap/setQuery', query) // Store it in Vuex
},

setTheme() {
Expand Down Expand Up @@ -263,37 +263,28 @@ export default defineComponent({
)
})
}

// Parse the query string into the front end.
let search = window.location.search

if (search[0] === '?') {
search = search.substring(1)
}

let query = querystring.parse(search)
if (query[`uiMode`]) {
this.$store.dispatch('zap/setDefaultUiMode', query[`uiMode`])
if (this.query[`uiMode`]) {
this.$store.dispatch('zap/setDefaultUiMode', this.query[`uiMode`])
}

if (`debugNavBar` in query) {
if (`debugNavBar` in this.query) {
this.$store.dispatch(
'zap/setDebugNavBar',
query[`debugNavBar`] === 'true'
this.query[`debugNavBar`] === 'true'
)
} else {
// If we don't specify it, default is on.
this.$store.dispatch('zap/setDebugNavBar', true)
}

if ('standalone' in query) {
this.$store.dispatch('zap/setStandalone', query['standalone'])
if ('standalone' in this.query) {
this.$store.dispatch('zap/setStandalone', this.query['standalone'])
}

if (`setSaveButtonVisible` in query) {
if (`setSaveButtonVisible` in this.query) {
this.$store.dispatch(
'zap/setSaveButtonVisible',
query[`setSaveButtonVisible`] === 'true'
this.query[`setSaveButtonVisible`] === 'true'
)
} else {
// If we don't specify it, default is off.
Expand All @@ -318,7 +309,7 @@ export default defineComponent({

// load initial UC component state
this.$store.dispatch(`zap/loadUcComponentState`)
if (query[`newConfig`]) {
if (this.query[`newConfig`]) {
this.loadInitialEndpoints()
}

Expand Down
10 changes: 7 additions & 3 deletions src/components/ZCLToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
flat
no-caps
@click="saveChanges"
v-if="
this.$store.state.zap.saveButtonVisible && this.$store.state.zap.isDirty
"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If saveButtonVisible and isDirty is not used in other places, after they are deleted, their related code to define or set their value should be removed too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thanks

v-if="showSaveButton"
>
<div class="text-center">
<q-icon name="o_save" />
Expand Down Expand Up @@ -245,6 +243,12 @@ export default {
name: 'ZCLToolbar',
mixins: [CommonMixin],
computed: {
query() {
return this.$store.state.zap.query // Access the query string from Vuex
},
showSaveButton() {
return !!this.query?.stsApplication // Use optional chaining and double negation for clarity
},
isCoreDocumentationAvailable() {
return (
this.$store.state.zap.genericOptions[
Expand Down
4 changes: 4 additions & 0 deletions src/store/zap/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export const updateShowDevTools = (state) => {
state.showDevTools = !state.showDevTools
}

export const setQuery = (state, query) => {
state.query = query
}

/**
* Set the information text in the state
* @param {*} state
Expand Down
1 change: 1 addition & 0 deletions src/store/zap/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function () {
featureMapValue: 0,
zclDeviceTypes: {},
endpoints: [],
query: {},
genericOptions: {},
selectedGenericOptions: {},
projectPackages: [],
Expand Down