Skip to content

Commit

Permalink
feat(ui): Added a warning popup before closing the application create…
Browse files Browse the repository at this point in the history
… panel (#20807)

* added-warning

Signed-off-by: Surajyadav <[email protected]>

* removed?

Signed-off-by: Surajyadav <[email protected]>

---------

Signed-off-by: Surajyadav <[email protected]>
  • Loading branch information
surajyadav1108 authored Nov 18, 2024
1 parent 00d45ed commit d8dd2fc
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,20 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
{(applications: models.Application[]) => {
const healthBarPrefs = pref.statusBarView || ({} as HealthStatusBarPreferences);
const {filteredApps, filterResults} = filterApps(applications, pref, pref.search);
const handleCreatePanelClose = async () => {
const outsideDiv = document.querySelector('.sliding-panel__outside');
const closeButton = document.querySelector('.sliding-panel__close');

if (outsideDiv && closeButton && closeButton !== document.activeElement) {
const confirmed = await ctx.popup.confirm('Close Panel', 'Closing this panel will discard all entered values. Continue?');
if (confirmed) {
ctx.navigation.goto('.', {new: null}, {replace: true});
}
} else if (closeButton === document.activeElement) {
// If the close button is focused or clicked, close without confirmation
ctx.navigation.goto('.', {new: null}, {replace: true});
}
};
return (
<React.Fragment>
<FlexTopBar
Expand Down Expand Up @@ -598,7 +612,7 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
</ObservableQuery>
<SlidingPanel
isShown={!!appInput}
onClose={() => ctx.navigation.goto('.', {new: null}, {replace: true})}
onClose={() => handleCreatePanelClose()} //Separate handling for outside click.
header={
<div>
<button
Expand Down

0 comments on commit d8dd2fc

Please sign in to comment.