-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor workspace datasource association (#8545)
* refactor: add data source association button to data source management page Signed-off-by: Yulong Ruan <[email protected]> * feat: add action button to dissociate data source from data source table Signed-off-by: Yulong Ruan <[email protected]> * Changeset file for PR #8545 created/updated * fix: automatically set a default data source if default data source been dissociated Signed-off-by: Yulong Ruan <[email protected]> * feat: implement bulk dissociate in data source management page Signed-off-by: Yulong Ruan <[email protected]> * fix lint Signed-off-by: Yulong Ruan <[email protected]> --------- Signed-off-by: Yulong Ruan <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c4049eb
commit fc03639
Showing
22 changed files
with
1,346 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Refactor data source list page to include data source association features for workspace ([#8545](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8545)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { WorkspaceAttribute } from '../../types'; | ||
|
||
export type WorkspaceObject = WorkspaceAttribute & { readonly?: boolean }; | ||
|
||
export type IWorkspaceResponse<T> = | ||
| { | ||
result: T; | ||
success: true; | ||
} | ||
| { | ||
success: false; | ||
error?: string; | ||
}; | ||
|
||
export interface AssociationResult { | ||
id: string; | ||
error?: string; | ||
} | ||
|
||
/** | ||
* This interface representing a client for managing workspace-related operations. | ||
* Workspace client should implement this interface. | ||
* | ||
* TODO: Refactor the current workspace client implementation in workspace plugin to add the missing operations to this interface | ||
*/ | ||
export interface IWorkspaceClient { | ||
/** | ||
* copy saved objects to target workspace | ||
* | ||
* @param {Array<{ id: string; type: string }>} objects | ||
* @param {string} targetWorkspace | ||
* @param {boolean} includeReferencesDeep | ||
* @returns {Promise<IResponse<any>>} result for this operation | ||
*/ | ||
copy(objects: any[], targetWorkspace: string, includeReferencesDeep?: boolean): Promise<any>; | ||
|
||
/** | ||
* Associates a list of objects with the given workspace ID. | ||
* | ||
* This method takes a workspace ID and an array of objects, where each object contains | ||
* an `id` and `type`. It attempts to associate each object with the specified workspace. | ||
* If the association succeeds, the object is included in the result without an error. | ||
* If there is an issue associating an object, an error message is returned for that object. | ||
* | ||
* @returns A promise that resolves to a response object containing an array of results for each object. | ||
* Each result will include the object's `id` and, if there was an error during association, an `error` field | ||
* with the error message. | ||
*/ | ||
associate( | ||
savedObjects: Array<{ id: string; type: string }>, | ||
workspaceId: string | ||
): Promise<IWorkspaceResponse<AssociationResult[]>>; | ||
|
||
/** | ||
* Dissociates a list of objects from the given workspace ID. | ||
* | ||
* This method takes a workspace ID and an array of objects, where each object contains | ||
* an `id` and `type`. It attempts to dissociate each object from the specified workspace. | ||
* If the dissociation succeeds, the object is included in the result without an error. | ||
* If there is an issue dissociating an object, an error message is returned for that object. | ||
* | ||
* @returns A promise that resolves to a response object containing an array of results for each object. | ||
* Each result will include the object's `id` and, if there was an error during dissociation, an `error` field | ||
* with the error message. | ||
*/ | ||
dissociate( | ||
savedObjects: Array<{ id: string; type: string }>, | ||
workspaceId: string | ||
): Promise<IWorkspaceResponse<AssociationResult[]>>; | ||
|
||
ui(): WorkspaceUI; | ||
} | ||
|
||
interface DataSourceAssociationProps { | ||
excludedDataSourceIds: string[]; | ||
onComplete?: () => void; | ||
onError?: () => void; | ||
} | ||
|
||
export interface WorkspaceUI { | ||
DataSourceAssociation: (props: DataSourceAssociationProps) => JSX.Element; | ||
} |
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.