Skip to content

Commit

Permalink
[Workspace]DQC can not be assigned to a workspace due to validation (#…
Browse files Browse the repository at this point in the history
…9259) (#9271)

* new try



* Changeset file for PR #9259 created/updated

* correction



* use header



* fix test



* a little fix



* use PrependOptions



* typo



* fix test



---------



(cherry picked from commit c91df47)

Signed-off-by: Qxisylolo <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 24, 2025
1 parent be60a80 commit 28732f7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/9259.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- DQC can not be assigned to a workspace due to validation ([#9259](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9259))
4 changes: 3 additions & 1 deletion src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export class Fetch {
};

const url = format({
pathname: shouldPrependBasePath ? this.params.basePath.prepend(options.path) : options.path,
pathname: shouldPrependBasePath
? this.params.basePath.prepend(options.path, options.prependOptions)
: options.path,
query: removedUndefined(query),
});

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export interface HttpFetchOptions extends HttpRequestInit {

/** @deprecated use {@link withLongNumeralsSupport} instead */
withLongNumerals?: boolean;

prependOptions?: PrependOptions;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/workspace/public/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ describe('workspace utils: fetchDataSourceConnections', () => {
],
},
]);
expect(httpMock.get).toHaveBeenCalledWith(expect.stringContaining('dataSourceMDSId=id1'));
expect(httpMock.get).toHaveBeenCalledWith(
expect.stringContaining('dataSourceMDSId=id1'),
expect.objectContaining({ prependOptions: { withoutClientBasePath: true } })
);
expect(notificationsMock.toasts.addDanger).not.toHaveBeenCalled();
});
it('should not retrieve direct query connections if mode is opensearch connection', async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/workspace/public/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ export const getDataSourcesList = (

export const getDirectQueryConnections = async (dataSourceId: string, http: HttpSetup) => {
const endpoint = `${DATACONNECTIONS_BASE}/dataSourceMDSId=${dataSourceId}`;
const res = await http.get(endpoint);
const res = await http.get(endpoint, {
prependOptions: { withoutClientBasePath: true },
});
const directQueryConnections: DataSourceConnection[] = res.map(
(dataConnection: DirectQueryDatasourceDetails) => ({
id: `${dataSourceId}-${dataConnection.name}`,
Expand Down

0 comments on commit 28732f7

Please sign in to comment.