forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Prompt for resetting layout (deephaven#1552)
User is not prompted to confirm when using the "reset layout" feature. - With unsaved notebook changes, prompt title will be "Reset layout and discard unsaved changes" - With open notebooks that are saved or no open notebooks, prompt title will be "Reset Layout" - If user clicks "Reset", layout will be reset. Unsaved notebook changes will be lost - If user clicks "Cancel", layout will not be reset and notebooks remain open fixes deephaven#1250
- Loading branch information
Showing
4 changed files
with
138 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/dashboard-core-plugins/src/panels/NotebookPanel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import NotebookPanel from './NotebookPanel'; | ||
|
||
beforeEach(() => { | ||
document.body.innerHTML = ''; | ||
jest.clearAllMocks(); | ||
expect.hasAssertions(); | ||
}); | ||
|
||
describe('unsavedNotebookCount', () => { | ||
function mockPanel(...classNames: string[]): HTMLDivElement { | ||
const el = document.createElement('div'); | ||
el.className = classNames.join(' '); | ||
return el; | ||
} | ||
|
||
const panel = { | ||
random: mockPanel('some-random-class'), | ||
saved: mockPanel(NotebookPanel.UNSAVED_INDICATOR_CLASS_NAME), | ||
statusOnly: mockPanel(NotebookPanel.UNSAVED_STATUS_CLASS_NAME), | ||
unsaved: mockPanel( | ||
NotebookPanel.UNSAVED_INDICATOR_CLASS_NAME, | ||
NotebookPanel.UNSAVED_STATUS_CLASS_NAME | ||
), | ||
}; | ||
|
||
it.each([ | ||
[[], 0], | ||
[[panel.random], 0], | ||
[[panel.saved], 0], | ||
[[panel.statusOnly], 0], | ||
[[panel.unsaved], 1], | ||
[[panel.unsaved, panel.unsaved], 2], | ||
[[panel.unsaved, panel.unsaved, panel.saved], 2], | ||
] as const)( | ||
'should return the count of unsaved notebooks: %s, %s', | ||
(panels, expectedCount) => { | ||
panels.forEach(p => document.body.appendChild(p.cloneNode())); | ||
expect(NotebookPanel.unsavedNotebookCount()).toBe(expectedCount); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters