Studio V6 Add WebSocket listener to track unsaved changes and update dirty state for ZAP configuration #1495
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces functionality to track and manage the "dirty" state of ZAP configuration by listening for WebSocket events indicating unsaved changes. Specifically, the code listens for the dirtyFlag WebSocket event, and upon receiving this event, it triggers an action to update the application's dirty state.
Changes:
WebSocket listener: Added a WebSocket listener for the dirtyFlag event, which dispatches the setDirtyState action to update the application state when unsaved changes are detected.
Action: The setDirtyState action is responsible for fetching the current dirty state from the backend using the isDirty API endpoint and committing the result to the store.
Mutation: The setDirtyState mutation updates the state with the new dirty flag (isDirty) and sends a postMessage to the parent window to notify about the state change.
Detailed Changes:
WebSocket Listener:
Listens for the dirtyFlag event (dbEnum.wsCategory.dirtyFlag).
Dispatches the zap/setDirtyState action when the event is received.
setDirtyState Action:
Calls the backend API (restApi.ide.isDirty) to check if there are unsaved changes.
Commits the result (DIRTY status) to the store using the mutation.
setDirtyState Mutation:
Updates the Vuex state with the new isDirty value.
Sends a message to the parent window indicating the new dirty state, enabling external applications or processes to be aware of unsaved changes.
Purpose:
Ensure the application's dirty state is accurately tracked when there are unsaved changes in the ZAP configuration.
Improve integration with external systems by notifying them of dirty state changes through postMessage.