Skip to content

Commit

Permalink
changed
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Medhini Reddy Maryada <[email protected]>
  • Loading branch information
Sai Medhini Reddy Maryada authored and Sai Medhini Reddy Maryada committed Aug 12, 2024
1 parent 7e2f3a8 commit cf5491a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 34 deletions.
2 changes: 1 addition & 1 deletion common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type Index = {
********** WORKFLOW TYPES/INTERFACES **********
*/
export type MDSQueryParams = {
dataSourceId: string;
dataSourceId?: string;
};

export type ConfigFieldType =
Expand Down
28 changes: 14 additions & 14 deletions public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
*/

import React from 'react';
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
import {
Route,
RouteComponentProps,
Switch,
useLocation,
} from 'react-router-dom';
import {
EuiPageSideBar,
EuiSideNav,
Expand All @@ -20,7 +25,10 @@ import {
} from './pages';
import { MountPoint } from '../../../src/core/public';
import queryString from 'query-string';
import { constructHrefWithDataSourceId } from './utils/utils';
import {
constructHrefWithDataSourceId,
getDataSourceFromURL,
} from './utils/utils';

// styling
import './global-styles.scss';
Expand All @@ -31,9 +39,8 @@ interface Props extends RouteComponentProps {

export const FlowFrameworkDashboardsApp = (props: Props) => {
const { setHeaderActionMenu } = props;
const queryParams = queryString.parse(location.search) as {
[key: string]: string;
};
const location = useLocation();
const queryParams = getDataSourceFromURL(location);
const dataSourceId = queryParams.dataSourceId;
const sidebar = (
<EuiPageSideBar style={{ minWidth: 190 }} hidden={false} paddingSize="l">
Expand All @@ -49,8 +56,7 @@ export const FlowFrameworkDashboardsApp = (props: Props) => {
id: 1,
href: constructHrefWithDataSourceId(
APP_PATH.WORKFLOWS,
dataSourceId,
true
dataSourceId
),
isSelected: props.location.pathname === APP_PATH.WORKFLOWS,
},
Expand Down Expand Up @@ -78,19 +84,14 @@ export const FlowFrameworkDashboardsApp = (props: Props) => {
) => (
<WorkflowDetail
setActionMenu={setHeaderActionMenu}
landingDataSourceId={dataSourceId}
{...routeProps}
/>
)}
/>
<Route
path={APP_PATH.WORKFLOWS}
render={(routeProps: RouteComponentProps<WorkflowsRouterProps>) => (
<Workflows
setActionMenu={setHeaderActionMenu}
landingDataSourceId={dataSourceId}
{...routeProps}
/>
<Workflows setActionMenu={setHeaderActionMenu} {...routeProps} />
)}
/>
{/*
Expand All @@ -109,7 +110,6 @@ export const FlowFrameworkDashboardsApp = (props: Props) => {
return (
<Workflows
setActionMenu={setHeaderActionMenu}
landingDataSourceId={dataSourceId}
{...routeProps}
/>
);
Expand Down
1 change: 0 additions & 1 deletion public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface WorkflowDetailRouterProps {
interface WorkflowDetailProps
extends RouteComponentProps<WorkflowDetailRouterProps> {
setActionMenu: (menuMount?: MountPoint) => void;
landingDataSourceId?: string;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions public/pages/workflows/workflow_list/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
Workflow,
toFormattedDate,
} from '../../../../common';
import { constructHrefWithDataSourceId, getDataSourceId } from '../../../utils/utils';

import {
constructHrefWithDataSourceId,
getDataSourceId,
} from '../../../utils/utils';

export const columns = (actions: any[]) => {
const dataSourceId = getDataSourceId();
Expand All @@ -26,8 +28,7 @@ export const columns = (actions: any[]) => {
<EuiLink
href={constructHrefWithDataSourceId(
`/workflows/${workflow.id}`,
dataSourceId,
true
dataSourceId
)}
>
{name}
Expand Down
7 changes: 3 additions & 4 deletions public/pages/workflows/workflows.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ const renderWithRouter = () => ({
<Router>
<Switch>
<Route
render={(props: RouteComponentProps) => <Workflows
setActionMenu={jest.fn()}
landingDataSourceId={undefined}
{...props} />}
render={(props: RouteComponentProps) => (
<Workflows setActionMenu={jest.fn()} {...props} />
)}
/>
</Switch>
</Router>
Expand Down
6 changes: 1 addition & 5 deletions public/pages/workflows/workflows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface WorkflowsRouterProps {}

interface WorkflowsProps extends RouteComponentProps<WorkflowsRouterProps> {
setActionMenu: (menuMount: MountPoint | undefined) => void;
landingDataSourceId?: string;
}

export enum WORKFLOWS_TAB {
Expand Down Expand Up @@ -187,10 +186,7 @@ export function Workflows(props: WorkflowsProps) {
componentConfig={{
fullWidth: false,
activeOption:
props.landingDataSourceId === undefined ||
dataSourceId === undefined
? undefined
: [{ id: dataSourceId }],
dataSourceId === undefined ? undefined : [{ id: dataSourceId }],
savedObjects: getSavedObjectsClient(),
notifications: getNotifications(),
onSelectedDataSources: (dataSources) =>
Expand Down
2 changes: 1 addition & 1 deletion public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export const BREADCRUMBS = Object.freeze({
FLOW_FRAMEWORK: { text: 'Flow Framework' },
WORKFLOWS: (dataSourceId?: string) => ({
text: 'Workflows',
href: constructHrefWithDataSourceId(APP_PATH.WORKFLOWS, dataSourceId, true),
href: constructHrefWithDataSourceId(APP_PATH.WORKFLOWS, dataSourceId),
}),
});
7 changes: 3 additions & 4 deletions public/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,12 @@ export const getDataSourceFromURL = (location: {
}): MDSQueryParams => {
const queryParams = queryString.parse(location.search);
const dataSourceId = queryParams.dataSourceId;
return { dataSourceId: typeof dataSourceId === 'string' ? dataSourceId : '' };
return { dataSourceId: typeof dataSourceId === 'string' ? dataSourceId : undefined };
};

export const constructHrefWithDataSourceId = (
basePath: string,
dataSourceId: string = '',
withHash: boolean
dataSourceId: string = ''
): string => {
const dataSourceEnabled = getDataSourceEnabled().enabled;
const url = new URLSearchParams();
Expand All @@ -253,7 +252,7 @@ export const constructHrefWithDataSourceId = (
// we share this helper function to construct the href with dataSourceId
// some places we need to return the url with hash, some places we don't need to
// so adding this flag to indicate if we want to return the url with hash
return `${withHash ? '#' : ''}${basePath}?${url.toString()}`;
return `#${basePath}?${url.toString()}`;
};

export const getDataSourceId = () => {
Expand Down

0 comments on commit cf5491a

Please sign in to comment.