Skip to content

Commit

Permalink
fix scss and use existing service getter and setter for application s…
Browse files Browse the repository at this point in the history
…ervice

Signed-off-by: Zhongnan Su <szhongna@amazon.com>
  • Loading branch information
zhongnansu committed Apr 16, 2024
1 parent 0ab8e90 commit 37b6567
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"ui": true,
"requiredPlugins": ["management", "dataSource", "indexPatternManagement"],
"optionalPlugins": [],
"requiredBundles": ["opensearchDashboardsReact", "dataSource"],
"requiredBundles": ["opensearchDashboardsReact", "dataSource", "opensearchDashboardsUtils"],
"extraPublicDirs": ["public/components/utils"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { DataSourceMenu } from './data_source_menu';
import { DataSourceMenuProps } from './types';
import { MountPointPortal } from '../../../../opensearch_dashboards_react/public';
import { applicationService } from '../utils';
import { getApplication } from '../utils';

export function createDataSourceMenu<T>(
uiSettings: IUiSettingsClient,
dataSourcePluginSetup: DataSourcePluginSetup
) {
const application = applicationService.getApplication();
const application = getApplication();
return (props: DataSourceMenuProps<T>) => {
const { hideLocalCluster } = dataSourcePluginSetup;
if (props.setMenuMountPoint) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dataSourceDropDownHeaderInvisibleFocusable {
opacity: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import './_drop_down_header.scss';
import './drop_down_header.scss';
import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui';
import React from 'react';
import { ApplicationStart } from 'opensearch-dashboards/public';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const DataSourceDropDownHeader: React.FC<DataSourceOptionItemProps> = ({
<EuiFlexItem>
{dataSourceCounterPrefix} ({dataSourceCounter})
</EuiFlexItem>
<div tabIndex={0} id="invisibleFocusable" />
<div tabIndex={0} className="dataSourceDropDownHeaderInvisibleFocusable" />
<EuiFlexItem grow={false}>
<EuiLink
onClick={() =>
Expand Down
16 changes: 2 additions & 14 deletions src/plugins/data_source_management/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { AuthenticationMethodRegistry } from '../auth_registry';
import { DataSourceOption } from './data_source_selector/data_source_selector';
import { DataSourceGroupLabelOption } from './data_source_menu/types';
import { createGetterSetter } from '../../../opensearch_dashboards_utils/public';

export async function getDataSources(savedObjectsClient: SavedObjectsClientContract) {
return savedObjectsClient
Expand Down Expand Up @@ -296,17 +297,4 @@ export const dataSourceOptionGroupLabel = deepFreeze<Readonly<DataSourceOptionGr
// TODO: add other group labels if needed
});

const createApplicationService = () => {
let application: ApplicationStart;

return {
init(applicationStart: ApplicationStart) {
application = applicationStart;
},
getApplication() {
return application;
},
};
};

export const applicationService = createApplicationService();
export const [getApplication, setApplication] = createGetterSetter<ApplicationStart>('Application');
6 changes: 3 additions & 3 deletions src/plugins/data_source_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { ApplicationStart, CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { CoreSetup, CoreStart, Plugin } from '../../../core/public';

import { PLUGIN_NAME } from '../common';
import { createDataSourceSelector } from './components/data_source_selector/create_data_source_selector';
Expand All @@ -21,7 +21,7 @@ import { noAuthCredentialAuthMethod, sigV4AuthMethod, usernamePasswordAuthMethod
import { DataSourceSelectorProps } from './components/data_source_selector/data_source_selector';
import { createDataSourceMenu } from './components/data_source_menu/create_data_source_menu';
import { DataSourceMenuProps } from './components/data_source_menu';
import { applicationService } from './components/utils';
import { setApplication } from './components/utils';

export interface DataSourceManagementSetupDependencies {
management: ManagementSetup;
Expand Down Expand Up @@ -112,7 +112,7 @@ export class DataSourceManagementPlugin

public start(core: CoreStart) {
this.started = true;
applicationService.init(core.application);
setApplication(core.application);
return {
getAuthenticationMethodRegistry: () => this.authMethodsRegistry,
};
Expand Down

0 comments on commit 37b6567

Please sign in to comment.