forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard De-Angular] Add dashboard class for discard flow (opensear…
…ch-project#4478) * Add Dashboard class for state managing Signed-off-by: abbyhu2000 <[email protected]> * isDirty working for cancel flow Signed-off-by: abbyhu2000 <[email protected]> --------- Signed-off-by: abbyhu2000 <[email protected]>
- Loading branch information
1 parent
b22c7c1
commit c7a5364
Showing
14 changed files
with
488 additions
and
52 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
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
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
44 changes: 44 additions & 0 deletions
44
src/plugins/dashboard/public/application/utils/get_dashboard_instance.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,44 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import { Dashboard, DashboardParams } from '../../dashboard'; | ||
import { SavedObjectDashboard } from '../../saved_dashboards'; | ||
import { convertToSerializedDashboard } from '../../saved_dashboards/_saved_dashboard'; | ||
import { DashboardServices } from '../../types'; | ||
|
||
export const getDashboardInstance = async ( | ||
dashboardServices: DashboardServices, | ||
/** | ||
* opts can be either a saved dashboard id passed as string, | ||
* or an object of new dashboard params. | ||
* Both come from url search query | ||
*/ | ||
opts?: Record<string, unknown> | string | ||
): Promise<{ | ||
savedDashboard: SavedObjectDashboard; | ||
dashboard: Dashboard<DashboardParams>; | ||
}> => { | ||
const { savedDashboards } = dashboardServices; | ||
|
||
// Get the existing dashboard/default new dashboard from saved object loader | ||
const savedDashboard: SavedObjectDashboard = await savedDashboards.get(opts); | ||
// Serialized the saved object dashboard | ||
const serializedDashboard = convertToSerializedDashboard(savedDashboard); | ||
// Create a Dashboard class using the serialized dashboard | ||
// const dashboard = (await dashboards.createDashboard(serializedDashboard)) as Dashboard; | ||
const dashboard = new Dashboard(serializedDashboard); | ||
await dashboard.setState(serializedDashboard); | ||
|
||
return { | ||
savedDashboard, | ||
dashboard, | ||
}; | ||
}; |
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
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
Oops, something went wrong.