-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add an appStatus to app controllers and scope #7984
Conversation
without this change, the directive is rendered in isolation and can not properly read the DOM, so require statements in custom config controls don't work
continue to use all the same controller code
cleanupFn(unlisten); | ||
} | ||
|
||
module.exports = monitorStateChanges; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use es6 modules: export default monitorStateChanges;
Can you get some tests in for these changes wherever it is practical? |
<i class="fa fa-chevron-up"></i> | ||
</div> | ||
</div> | ||
`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup job!
I left a few comments, but I also have a suggestion for making the interface for this new service more intuitive. How about if it was used this way: const StateChangeMonitor = require('ui/state_management/state_change_monitor');
const stateChangeMonitor = new StateChangeMonitor($state, stateDefaults);
stateChangeMonitor.onStateChange(isDirty => {
$appStatus.isDirty = isDirty;
});
$scope.$on('$destroy', () => {
stateChangeMonitor.destroy();
}); I find this easier to follow for a few reasons:
The only thing I think I'm not anticipating is the use case where you force the dirtyChecker to return true if it's already dirty. If you like my idea then maybe we can discuss the requirement in that case and figure out how to work it in? |
fix passing by reference, trigger dirty on column changes
fix objects passed by reference there as well
a refactor of how monitor_state_changes works
immediately fire if the state is already dirty
includes tests for functionality
the listeners are bound at weird times, and don't actually indicate the state of the app
This looks great! Reviewed the code and implemented a test in Editor. LGTM |
LGTM once w33ble#7 gets merged! |
Refactor state_monitor for clarity.
This PR adds an
appStatus
to the controller and scopes for Discover, Visualize and Dashboard. It uses this status to track whether or not the app is "dirty", that is, if it has been modified since it was last saved.appState
, and in the case of Visualize,editableVis
as wellconfig
rendering, firing postLink after injecting in the DOM so that directives with arequire
will function