Skip to content

Commit

Permalink
simplified changes
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Dec 18, 2024
1 parent b895ae9 commit 5f387da
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import {
import { RouteComponentProps } from 'react-router-dom';
import { GetStartedStep } from './GetStartedStep';
import { moreLink } from '../../utils/constants';
import { navigateToRoute } from '../../../../utils/helpers';
import { setBreadcrumbs } from '../../../../utils/helpers';
import { getUseUpdatedUx } from '../../../../services/utils/constants';
import { getApplication, getUseUpdatedUx } from '../../../../services/utils/constants';
import { PageHeader } from '../../../../components/PageHeader/PageHeader';

export interface GettingStartedPopupProps {
Expand All @@ -37,6 +36,15 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
if (useUpdatedUx) {
setBreadcrumbs([BREADCRUMBS.GETTING_STARTED]);
}
const onActionClick = (appId: string, route: string) => {
if (useUpdatedUx) {
const url = getApplication().getUrlForApp(appId, { path: `#${route}` });
getApplication().navigateToUrl(url);
} else {
history.push(route);
}
};

const steps: EuiContainedStepProps[] = useMemo(
() => [
{
Expand All @@ -51,7 +59,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'Create detector',
onClick: () => {
onStepClicked();
navigateToRoute(history, DETECTORS_NAV_ID, ROUTES.DETECTORS_CREATE);
onActionClick(DETECTORS_NAV_ID, ROUTES.DETECTORS_CREATE);
},
opts: {
fill: true,
Expand All @@ -73,7 +81,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'Manage threat intelligence sources',
onClick: () => {
onStepClicked();
navigateToRoute(history, THREAT_INTEL_NAV_ID, ROUTES.THREAT_INTEL_OVERVIEW);
onActionClick(THREAT_INTEL_NAV_ID, ROUTES.THREAT_INTEL_OVERVIEW);
},
},
]}
Expand All @@ -92,7 +100,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'View findings',
onClick: () => {
onStepClicked();
navigateToRoute(history, FINDINGS_NAV_ID, ROUTES.FINDINGS);
onActionClick(FINDINGS_NAV_ID, ROUTES.FINDINGS);
},
},
]}
Expand All @@ -109,7 +117,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'View alerts',
onClick: () => {
onStepClicked();
navigateToRoute(history, THREAT_ALERTS_NAV_ID, ROUTES.ALERTS);
onActionClick(THREAT_ALERTS_NAV_ID, ROUTES.ALERTS);
},
},
]}
Expand All @@ -126,7 +134,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'Manage rules',
onClick: () => {
onStepClicked();
navigateToRoute(history, DETECTION_RULE_NAV_ID, ROUTES.RULES);
onActionClick(DETECTION_RULE_NAV_ID, ROUTES.RULES);
},
},
]}
Expand All @@ -143,7 +151,7 @@ export const GettingStartedContent: React.FC<GettingStartedPopupProps> = ({
text: 'Manage correlation rules',
onClick: () => {
onStepClicked();
navigateToRoute(history, CORRELATIONS_RULE_NAV_ID, ROUTES.CORRELATION_RULES);
onActionClick(CORRELATIONS_RULE_NAV_ID, ROUTES.CORRELATION_RULES);
},
},
]}
Expand Down
3 changes: 3 additions & 0 deletions public/pages/Overview/containers/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiPopover,
EuiSuperDatePicker,
EuiTitle,
EuiSpacer,
EuiSmallButton,
EuiCard,
EuiPanel,
Expand Down
8 changes: 8 additions & 0 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import _ from 'lodash';
import { euiPaletteColorBlind, euiPaletteForStatus } from '@elastic/eui';
import { DataSourceOption } from 'src/plugins/data_source_management/public';
import { BehaviorSubject } from 'rxjs';
import { i18n } from '@osd/i18n';

export const DATE_MATH_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
export const MAX_RECENTLY_USED_TIME_RANGES = 5;
Expand Down Expand Up @@ -308,6 +309,13 @@ export const ALERT_SEVERITY_PROPS = {
},
};

const LocalCluster: DataSourceOption = {
label: i18n.translate('dataSource.localCluster', {
defaultMessage: 'Local cluster',
}),
id: '',
};

// We should use empty object for default value as local cluster may be disabled
export const dataSourceObservable = new BehaviorSubject<DataSourceOption>({});

Expand Down
14 changes: 0 additions & 14 deletions public/utils/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -773,20 +773,6 @@ export function initializeServices(coreStart: CoreStart, indexPattern: CoreIndex
DataStore.init(services, coreStart.notifications);
}

export const navigateToRoute = (
history: RouteComponentProps['history'],
appId: string,
route: string
) => {
const useUpdatedUx = getUseUpdatedUx();
if (useUpdatedUx) {
const url = getApplication().getUrlForApp(appId, { path: `#${route}` });
getApplication().navigateToUrl(url);
} else {
history.push(route);
}
};

export const buildRouteUrl = (appId: string, route: string) => {
const useUpdatedUx = getUseUpdatedUx();
if (useUpdatedUx) {
Expand Down

0 comments on commit 5f387da

Please sign in to comment.