Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Dec 20, 2023
1 parent e3eb263 commit aaa775e
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 37 deletions.
3 changes: 0 additions & 3 deletions src/plugins/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import { schema, TypeOf } from '@osd/config-schema';

export const configSchema = schema.object({
language_selector_next: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
autocomplete: schema.object({
querySuggestions: schema.object({
enabled: schema.boolean({ defaultValue: true }),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { IndexPatternsContract } from './index_patterns';
import { IndexPatternSelectProps, StatefulSearchBarProps } from './ui';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { DataSourceStart } from './data_sources/datasource_services/types';
import { ObservabilitySetup } from '../../../../plugins/dashboards-observability/public/types';

export interface DataPublicPluginEnhancements {
search: SearchEnhancements;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,31 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';
import React, { useState } from 'react';
import { Observable } from 'rxjs';
import { useObservable } from 'react-use';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { IDataPluginServices } from '../../types';

interface Props {
language: string;
onSelectLanguage: (newLanguage: string) => void;
anchorPosition?: PopoverAnchorPosition;
currentApp$?: Observable<string | undefined>;
useNewQuerySelector?: boolean;
}

export function QueryLanguageSwitcher(props: Props) {
const opensearchDashboards = useOpenSearchDashboards<IDataPluginServices>();
const { application } = opensearchDashboards.services;
const currentApp$ = application?.currentAppId$;

let useNewQuerySelector;
application?.applications$.subscribe((applications) => {
applications.forEach((applicationEntry) => {
if (applicationEntry.id === 'observability-dashboards') {
useNewQuerySelector = true;
return;

Check warning on line 66 in src/plugins/data/public/ui/query_string_input/language_switcher.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/query_string_input/language_switcher.tsx#L65-L66

Added lines #L65 - L66 were not covered by tests
}
});
});

const dataExplorerOptions = [
{
label: 'DQL',
Expand Down Expand Up @@ -102,7 +114,7 @@ export function QueryLanguageSwitcher(props: Props) {
setSelectedLanguage(newLanguage);

Check warning on line 114 in src/plugins/data/public/ui/query_string_input/language_switcher.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/query_string_input/language_switcher.tsx#L113-L114

Added lines #L113 - L114 were not covered by tests
};

if (useObservable(props.currentApp$!, '') === 'data-explorer' && props.useNewQuerySelector) {
if (useObservable(currentApp$!, '') === 'data-explorer' && useNewQuerySelector) {
return (

Check warning on line 118 in src/plugins/data/public/ui/query_string_input/language_switcher.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/query_string_input/language_switcher.tsx#L118

Added line #L118 was not covered by tests
<EuiComboBox
className="languageSwitcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export interface QueryBarTopRowProps {
isDirty: boolean;
timeHistory?: TimeHistoryContract;
indicateNoData?: boolean;
useNewQuerySelector?: boolean;
}

// Needed for React.lazy
Expand All @@ -93,16 +92,8 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) {
const [isQueryInputFocused, setIsQueryInputFocused] = useState(false);

const opensearchDashboards = useOpenSearchDashboards<IDataPluginServices>();
const {
application,
uiSettings,
notifications,
storage,
appName,
docLinks,
} = opensearchDashboards.services;

const currentApp = application?.currentAppId$;
const { uiSettings, notifications, storage, appName, docLinks } = opensearchDashboards.services;

const osdDQLDocs: string = docLinks!.links.opensearchDashboards.dql.base;

const queryLanguage = props.query && props.query.language;
Expand Down Expand Up @@ -220,8 +211,6 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) {
onSubmit={onInputSubmit}
persistedLog={persistedLog}
dataTestSubj={props.dataTestSubj}
currentApp$={currentApp}
useNewQuerySelector={props.useNewQuerySelector}
/>
</EuiFlexItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
import { FormattedMessage } from '@osd/i18n/react';
import { debounce, compact, isEqual, isFunction } from 'lodash';
import { Toast } from 'src/core/public';
import { Observable } from 'rxjs';
import { IDataPluginServices, IIndexPattern, Query } from '../..';
import { QuerySuggestion, QuerySuggestionTypes } from '../../autocomplete';

Expand Down Expand Up @@ -79,8 +78,6 @@ export interface QueryStringInputProps {
size?: SuggestionsListSize;
className?: string;
isInvalid?: boolean;
currentApp$?: Observable<string | undefined>;
useNewQuerySelector?: boolean;
}

interface Props extends QueryStringInputProps {
Expand Down Expand Up @@ -709,8 +706,6 @@ export default class QueryStringInputUI extends Component<Props, State> {
language={this.props.query.language}
anchorPosition={this.props.languageSwitcherPopoverAnchorPosition}
onSelectLanguage={this.onSelectLanguage}
currentApp$={this.props.currentApp$}
useNewQuerySelector={this.props.useNewQuerySelector}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export function createSearchBar({ core, storage, data }: StatefulSearchBarDeps)
showAutoRefreshOnly={props.showAutoRefreshOnly}
showDatePicker={props.showDatePicker}
showFilterBar={props.showFilterBar}
useNewQuerySelector={props.useNewQuerySelector}
showQueryBar={props.showQueryBar}
showQueryInput={props.showQueryInput}
showSaveQuery={props.showSaveQuery}
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/data/public/ui/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { TimeRange, Query, Filter, IIndexPattern } from '../../../common';
import { FilterBar } from '../filter_bar/filter_bar';
import { SavedQueryMeta, SaveQueryForm } from '../saved_query_form';
import { SavedQueryManagementComponent } from '../saved_query_management';
import { services } from '../../../../../../test/api_integration/services/index';

interface SearchBarInjectedDeps {
opensearchDashboards: OpenSearchDashboardsReactContextValue<IDataPluginServices>;
Expand Down Expand Up @@ -93,7 +92,6 @@ export interface SearchBarOwnProps {

onRefresh?: (payload: { dateRange: TimeRange }) => void;
indicateNoData?: boolean;
useNewQuerySelector?: boolean;
}

export type SearchBarProps = SearchBarOwnProps & SearchBarInjectedDeps;
Expand Down Expand Up @@ -420,7 +418,6 @@ class SearchBarUI extends Component<SearchBarProps, State> {
}
dataTestSubj={this.props.dataTestSubj}
indicateNoData={this.props.indicateNoData}
useNewQuerySelector={this.props.useNewQuerySelector}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"uiActions",
"visualizations"
],
"optionalPlugins": ["home", "share", "observabilityDashboards"],
"optionalPlugins": ["home", "share"],
"requiredBundles": [
"home",
"opensearchDashboardsUtils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const TopNav = ({ opts }: TopNavProps) => {
data,
chrome,
osdUrlStateStorage,
useNewQuerySelector,
} = services;

const topNavLinks = savedSearch ? getTopNavLinks(services, inspectorAdapters, savedSearch) : [];
Expand Down Expand Up @@ -91,7 +90,6 @@ export const TopNav = ({ opts }: TopNavProps) => {
setMenuMountPoint={opts.setHeaderActionMenu}
indexPatterns={indexPattern ? [indexPattern] : indexPatterns}
onQuerySubmit={opts.onQuerySubmit}
useNewQuerySelector={useNewQuerySelector}
/>
);
};
2 changes: 0 additions & 2 deletions src/plugins/discover/public/build_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export interface DiscoverServices {
getSavedSearchUrlById: (id: string) => Promise<string>;
uiSettings: IUiSettingsClient;
visualizations: VisualizationsStart;
useNewQuerySelector: boolean;
}

export function buildServices(
Expand Down Expand Up @@ -124,7 +123,6 @@ export function buildServices(
toastNotifications: core.notifications.toasts,
uiSettings: core.uiSettings,
visualizations: plugins.visualizations,
useNewQuerySelector: !!plugins.observabilityDashboards,
};
}

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/discover/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { Start as InspectorPublicPluginStart } from 'src/plugins/inspector/publi
import { stringify } from 'query-string';
import rison from 'rison-node';
import { lazy } from 'react';
import { ObservabilityStart } from 'plugins/dashboards-observability/public/types';
import { DataPublicPluginStart, DataPublicPluginSetup, opensearchFilters } from '../../data/public';
import { SavedObjectLoader } from '../../saved_objects/public';
import { url } from '../../opensearch_dashboards_utils/public';
Expand Down Expand Up @@ -145,7 +144,6 @@ export interface DiscoverStartPlugins {
urlForwarding: UrlForwardingStart;
inspector: InspectorPublicPluginStart;
visualizations: VisualizationsStart;
observabilityDashboards?: ObservabilityStart;
}

/**
Expand Down

0 comments on commit aaa775e

Please sign in to comment.