[Links] Don't close the flyout if the user cancels save to library (#188995)

Fixes #188931 

## Summary

Fixes Links panel flyout closing if the user cancels the Save modal
This commit is contained in:
Nick Peihl 2024-07-24 13:09:24 -04:00 committed by GitHub
parent e1e5d2893d
commit 47c7137a95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -76,7 +76,7 @@ export const runSaveToLibrary = async (
});
return { id };
} catch (error) {
reject();
reject(error);
return { error };
}
};

View file

@ -96,11 +96,13 @@ export async function openEditorFlyout({
options: { references },
});
resolve(newState);
closeEditorFlyout(editorFlyout);
} else {
const saveResult = await runSaveToLibrary(newState);
resolve(saveResult);
// If saveResult is undefined, the user cancelled the save as modal and we should not close the flyout
if (saveResult) closeEditorFlyout(editorFlyout);
}
closeEditorFlyout(editorFlyout);
};
const onAddToDashboard = (newLinks: ResolvedLink[], newLayout: LinksLayoutType) => {

View file

@ -82,6 +82,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboard.clickDiscardChanges();
});
it('does not close the flyout when the user cancels the save as modal', async () => {
await dashboardAddPanel.clickEditorMenuButton();
await dashboardAddPanel.clickAddNewPanelFromUIActionLink('Links');
await createSomeLinks();
await dashboardLinks.toggleSaveByReference(true);
await dashboardLinks.clickPanelEditorSaveButton();
await testSubjects.exists('savedObjectSaveModal');
await testSubjects.click('saveCancelButton');
await testSubjects.existOrFail('links--panelEditor--flyout');
await dashboardLinks.clickPanelEditorCloseButton();
});
describe('by-value links panel', async () => {
it('can create a new by-value links panel', async () => {
await dashboardAddPanel.clickEditorMenuButton();