-
Notifications
You must be signed in to change notification settings - Fork 894
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
Refactor workspace datasource association #8545
Changes from 4 commits
f3246bf
251ad2d
dc77275
1d43771
f28ec3a
3d1f537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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; | ||
} | ||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: How about use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is interface definition in core, |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we may need a TODO here to add other methods of client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those should be refactored as well