Skip to content
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

[Backport 2.14] added fix for runAsync query without mds id #327

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions public/components/SQLPage/SQLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
onClear: () => void;
updateSQLQueries: (query: string) => void;
sqlQuery: string;
sqlTranslations: ResponseDetail<TranslateResult>[];
sqlTranslations: Array<ResponseDetail<TranslateResult>>;

Check failure on line 37 in public/components/SQLPage/SQLPage.tsx

View workflow job for this annotation

GitHub Actions / Lint

Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead
selectedDatasource: EuiComboBoxOptionOption[];
asyncLoading: boolean;
openAccelerationFlyout: boolean;
Expand Down Expand Up @@ -68,7 +68,10 @@
}

setAccelerationFlyout = () => {
this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label,this.props.dataSourceMDSId);
this.renderCreateAccelerationFlyout({

Check failure on line 71 in public/components/SQLPage/SQLPage.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `this.props.selectedDatasource[0].label,this.props.dataSourceMDSId` with `⏎······this.props.selectedDatasource[0].label,⏎······this.props.dataSourceMDSId⏎····`
dataSource: this.props.selectedDatasource[0].label,
dataSourceMDSId: this.props.dataSourceMDSId,
});
};

componentDidUpdate(prevProps: SQLPageProps) {
Expand Down Expand Up @@ -96,7 +99,7 @@
}
return false;
};

Check warning on line 102 in public/components/SQLPage/SQLPage.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const explainContent = sqlTranslationsNotEmpty()
? this.props.sqlTranslations
.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2))
Expand Down Expand Up @@ -211,10 +214,13 @@
{this.props.selectedDatasource &&
this.props.selectedDatasource[0].label !== 'OpenSearch' && (
<EuiFlexItem grow={false}>
<EuiButton

Check failure on line 217 in public/components/SQLPage/SQLPage.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `this.props.selectedDatasource[0].label,this.props.dataSourceMDSId` with `⏎························this.props.selectedDatasource[0].label,⏎························this.props.dataSourceMDSId⏎······················`
className="sql-accelerate-button"
onClick={() =>
this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label,this.props.dataSourceMDSId)
this.renderCreateAccelerationFlyout({
dataSource: this.props.selectedDatasource[0].label,
dataSourceMDSId: this.props.dataSourceMDSId,
})
}
isDisabled={this.props.asyncLoading}
>
Expand Down
7 changes: 4 additions & 3 deletions public/dependencies/register_observability_dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import { createGetterSetter } from '../../../../src/plugins/opensearch_dashboards_utils/public';
import { catalogCacheRefs } from '../framework/catalog_cache_refs';
import { ObservabilityStart } from '../types';

import { ObservabilityStart, RenderAccelerationFlyoutParams } from '../types';
export const [
getRenderAccelerationDetailsFlyout,
setRenderAccelerationDetailsFlyout,
Expand All @@ -20,7 +19,9 @@ export const [
export const [
getRenderCreateAccelerationFlyout,
setRenderCreateAccelerationFlyout,
] = createGetterSetter<(dataSource: string, dataSourceMDSId?: string) => void>('renderCreateAccelerationFlyout');
] = createGetterSetter<({ dataSource, dataSourceMDSId }: RenderAccelerationFlyoutParams) => void>(
'renderCreateAccelerationFlyout'
);

export const registerObservabilityDependencies = (start?: ObservabilityStart) => {
if (!start) {
Expand Down
6 changes: 4 additions & 2 deletions public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { DataSourcePluginStart } from '../../../src/plugins/data_source/public/t
import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public';
import { ObservabilityStart } from './types';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface WorkbenchPluginSetup {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface WorkbenchPluginStart {
}
export interface WorkbenchPluginStart {}

export interface AppPluginStartDependencies {
navigation: NavigationPublicPluginStart;
Expand All @@ -20,3 +20,5 @@ export interface AppPluginStartDependencies {
}

export type { ObservabilityStart } from '../../dashboards-observability/public';

export type { RenderAccelerationFlyoutParams } from '../../dashboards-observability/common/types/data_connections';
29 changes: 8 additions & 21 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/


import {
CoreSetup,
CoreStart,
ILegacyClusterClient,
Logger,
Plugin,
PluginInitializerContext,
} from '../../../src/core/server';
import { CoreSetup, Logger, Plugin, PluginInitializerContext } from '../../../src/core/server';

import { DataSourcePluginSetup } from '../../../src/plugins/data_source/server/types';
import { DataSourceManagementPlugin } from '../../../src/plugins/data_source_management/public/plugin';
import sqlPlugin from './clusters/sql/sqlPlugin';
import defineRoutes from './routes';
import { defineRoutes } from './routes';
import { WorkbenchPluginSetup, WorkbenchPluginStart } from './types';

export interface WorkbenchPluginSetupDependencies {
Expand All @@ -31,22 +23,17 @@ export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPl
this.logger = initializerContext.logger.get();
}

public setup(core: CoreSetup, {dataSource} : WorkbenchPluginSetupDependencies) {
public setup(core: CoreSetup, { dataSource }: WorkbenchPluginSetupDependencies) {
this.logger.debug('queryWorkbenchDashboards: Setup');
const router = core.http.createRouter();

const dataSourceEnabled = !!dataSource;

let client: ILegacyClusterClient | undefined = undefined;

client = core.opensearch.legacy.createClient(
'query_workbench',
{
plugins: [sqlPlugin]
}
)
const client = core.opensearch.legacy.createClient('query_workbench', {
plugins: [sqlPlugin],
});
if (dataSourceEnabled) {
dataSource.registerCustomApiSchema(sqlPlugin)
dataSource.registerCustomApiSchema(sqlPlugin);
}

// Register server side APIs
Expand All @@ -55,7 +42,7 @@ export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPl
return {};
}

public start(core: CoreStart) {
public start() {
this.logger.debug('queryWorkbenchDashboards: Started');
return {};
}
Expand Down
21 changes: 15 additions & 6 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
* SPDX-License-Identifier: Apache-2.0
*/


import { ILegacyClusterClient, IRouter, Logger, OpenSearchServiceSetup } from '../../../../src/core/server';
import {
ILegacyClusterClient,
IRouter,
Logger,
OpenSearchServiceSetup,
} from '../../../../src/core/server';
import QueryService from '../services/QueryService';
import TranslateService from '../services/TranslateService';
import registerQueryRoute from './query';
import { registerQueryRoute } from './query';
import registerTranslateRoute from './translate';


export default function (router: IRouter, client: ILegacyClusterClient | undefined, openSearchServiceSetup: OpenSearchServiceSetup, dataSourceEnabled: boolean, logger: Logger) {
export function defineRoutes(
router: IRouter,
client: ILegacyClusterClient | undefined,
openSearchServiceSetup: OpenSearchServiceSetup,
dataSourceEnabled: boolean,
logger: Logger
) {
const translateService = new TranslateService(client, dataSourceEnabled, logger);
registerTranslateRoute(router, translateService, openSearchServiceSetup);

const queryService = new QueryService(client, dataSourceEnabled, logger);
registerQueryRoute(router, queryService, openSearchServiceSetup);
registerQueryRoute(router, queryService);
}
Loading
Loading