-
Notifications
You must be signed in to change notification settings - Fork 539
dbeaver/pro#4425 [CB] Confirmation for unsaved changes in administration #4439
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
SychevAndrey
wants to merge
13
commits into
devel
Choose a base branch
from
4425-cb-923-confirmation-for-unsaved-changes-in-administration
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ecd4be6
dbeaver/pro#4425 feat: add confirmation dialog for unsaved changes in…
SychevAndrey e4ae2c7
dbeaver/pro#4425 refactor: update confirmUnsavedChanges interface
SychevAndrey c96aff5
dbeaver/pro#4425 refactor: simplify confirmUnsavedChanges usage
SychevAndrey 2ebe8c4
dbeaver/pro#4425 feat: add controlled selection feature to TabsState …
SychevAndrey f4b3fbb
dbeaver/pro#4425 feat: add async confirmation action to ConfirmationD…
SychevAndrey 07e5190
Merge branch 'devel' into 4425-cb-923-confirmation-for-unsaved-change…
SychevAndrey 7d5d99c
dbeaver/pro#4425 style: fix lint
SychevAndrey dc1d912
Merge branch 'devel' into 4425-cb-923-confirmation-for-unsaved-change…
SychevAndrey 673f0c2
dbeaver/pro#4425 fix: sync currentTabId in render
SychevAndrey 6155100
dbeaver/pro#4425 feat: add confirmation for unsaved changes in admini…
SychevAndrey fcd783b
Merge branch 'devel' into 4425-cb-923-confirmation-for-unsaved-change…
SychevAndrey e8f52ac
dbeaver/pro#4425 style: improve comments for onConfirm action in Conf…
SychevAndrey bb43d70
Merge branch 'devel' into 4425-cb-923-confirmation-for-unsaved-change…
SychevAndrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
59 changes: 59 additions & 0 deletions
59
webapp/packages/core-blocks/src/CommonDialog/confirmUnsavedChanges.tsx
This file contains hidden or 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,59 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
| import { type CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs'; | ||
| import type { TLocalizationToken } from '@cloudbeaver/core-localization'; | ||
|
|
||
| import { ConfirmationDialog } from './ConfirmationDialog.js'; | ||
|
|
||
| export interface IUnsavedChangesProvider { | ||
| readonly isChanged: boolean; | ||
| readonly isSaving?: boolean; | ||
| /** Returns whether the save succeeded. `undefined` means there was nothing to save and navigation may proceed. */ | ||
| save(): Promise<boolean> | undefined; | ||
| reset(): void; | ||
| title?: string; | ||
| subTitle?: string; | ||
| message?: TLocalizationToken; | ||
| } | ||
|
|
||
| /** | ||
| * Shows a unified "Save / Don't save / Cancel" dialog when the provider has unsaved changes. | ||
| * | ||
| * @returns `true` when navigation may proceed (saved successfully or discarded), `false` to block it. | ||
| */ | ||
| export async function confirmUnsavedChanges(commonDialogService: CommonDialogService, provider: IUnsavedChangesProvider): Promise<boolean> { | ||
| if (!provider.isChanged) { | ||
| return true; | ||
| } | ||
|
|
||
| if (provider.isSaving) { | ||
| return false; | ||
| } | ||
|
|
||
| const { status, result } = await commonDialogService.open(ConfirmationDialog, { | ||
| title: provider.title ?? 'ui_save_reminder', | ||
| subTitle: provider.subTitle, | ||
| message: provider.message ?? 'ui_changes_might_be_lost', | ||
| confirmActionText: 'ui_processing_save', | ||
| extraActionText: 'ui_processing_dont_save', | ||
| cancelActionText: 'ui_processing_cancel', | ||
| showExtraAction: true, | ||
| onConfirm: async () => (await provider.save()) ?? true, | ||
| }); | ||
|
|
||
| if (status === DialogueStateResult.Resolved) { | ||
| return true; | ||
| } | ||
|
|
||
| if (result?.isExtraAction) { | ||
| provider.reset(); | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...in-authentication-administration/src/Administration/Users/Teams/TeamsTable/CreateTeam.tsx
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.