Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlog committed Jun 25, 2020
1 parent 3529c1c commit f364e74
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ export const IntraAppStateProvider = memo<{
children: React.ReactNode;
}>(({ kibanaScopedHistory, children }) => {
const internalAppToAppState = useMemo<IntraAppState>(() => {
const intraAppState = kibanaScopedHistory.location.state as AnyIntraAppRouteState;
return {
forRoute: kibanaScopedHistory.location.state.baseRoute
? kibanaScopedHistory.location.state.baseRoute.substr(1)
: kibanaScopedHistory.location.hash.substr(1),
routeState: kibanaScopedHistory.location.state as AnyIntraAppRouteState,
forRoute: intraAppState.baseRoute ? intraAppState.baseRoute : '',
routeState: intraAppState,
};
}, [kibanaScopedHistory.location.hash, kibanaScopedHistory.location.state]);
}, [kibanaScopedHistory.location.state]);
return (
<IntraAppStateContext.Provider value={internalAppToAppState}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from '@elastic/eui';
import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab';
import styled from 'styled-components';
import queryString from 'query-string';
import { AgentConfig, AgentConfigDetailsDeployAgentAction } from '../../../types';
import { PAGE_ROUTING_PATHS } from '../../../constants';
import { useGetOneAgentConfig, useLink, useBreadcrumbs, useCore } from '../../../hooks';
Expand Down Expand Up @@ -55,8 +54,8 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => {
} = useCore();
const routeState = useIntraAppState<AgentConfigDetailsDeployAgentAction>();
const agentStatus = agentStatusRequest.data?.results;
const openEnrollmentFlyoutOpenByDefault =
queryString.parse(useLocation().search).openEnrollmentFlyout === 'true';
const queryParams = new URLSearchParams(useLocation().search);
const openEnrollmentFlyoutOpenByDefault = queryParams.get('openEnrollmentFlyout') === 'true';

const headerLeftContent = useMemo(
() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface CreateDatasourceRouteState {
onCancelNavigateTo?: Parameters<ApplicationStart['navigateToApp']>;
/** Url to be used on cancel links */
onCancelUrl?: string;
/** The base route */
baseRoute?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface ManagementStep {
const PolicyEmptyState = React.memo<{
loading: boolean;
onActionClick: (event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
actionDisabled: boolean;
actionDisabled?: boolean;
}>(({ loading, onActionClick, actionDisabled }) => {
const policySteps = useMemo(
() => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ describe('HostList store concerns', () => {
policyResponseError: undefined,
location: undefined,
policyItems: [],
selectedPolicyId: undefined,
policyItemsLoading: false,
endpointPackageInfo: undefined,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const initialHostListState: Immutable<HostState> = {
policyItems: [],
selectedPolicyId: undefined,
policyItemsLoading: false,
endpointPackageInfo: undefined,
};

/* eslint-disable-next-line complexity */
Expand Down Expand Up @@ -110,6 +111,11 @@ export const hostListReducer: ImmutableReducer<HostState, AppAction> = (
...state,
policyItemsLoading: false,
};
} else if (action.type === 'serverReturnedEndpointPackageInfo') {
return {
...state,
endpointPackageInfo: action.payload,
};
} else if (action.type === 'userChangedUrl') {
const newState: Immutable<HostState> = {
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
PolicyData,
} from '../../../../common/endpoint/types';
import { ServerApiError } from '../../../common/types';
import { GetPackagesResponse } from '../../../../../ingest_manager/common';

export interface HostState {
/** list of host **/
Expand Down Expand Up @@ -47,7 +48,8 @@ export interface HostState {
policyItemsLoading: boolean;
/** the selected policy ID in the onboarding flow */
selectedPolicyId?: string;
endpointPackageInfo?: sring;
/** Endpoint package info */
endpointPackageInfo?: GetPackagesResponse['response'][0];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export const HostList = () => {
'securitySolution:management',
{ path: getEndpointListPath({ name: 'endpointList' }) },
],
baseRoute: `/integrations${
endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-datasource` : ''
}`,
},
}
);
Expand All @@ -147,7 +150,7 @@ export const HostList = () => {
'securitySolution:management',
{ path: getEndpointListPath({ name: 'endpointList' }) },
],
baseRoute: `#/configs/${selectedPolicyId}`,
baseRoute: `/configs/${selectedPolicyId}`,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export const PolicyList = React.memo(() => {
onCancelNavigateTo: ['securitySolution:management', { path: getPoliciesPath() }],
onCancelUrl: formatUrl(getPoliciesPath()),
onSaveNavigateTo: ['securitySolution:management', { path: getPoliciesPath() }],
baseRoute: `/integrations${
endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-datasource` : ''
}`,
},
}
);
Expand Down Expand Up @@ -431,12 +434,7 @@ export const PolicyList = React.memo(() => {
hasActions={false}
/>
) : (
<PolicyEmptyState
loading={loading}
onActionClick={handleCreatePolicyClick}
actionDisabled={false}
dataTestSubj="emptyPolicyTable"
/>
<PolicyEmptyState loading={loading} onActionClick={handleCreatePolicyClick} />
)}
</>
);
Expand Down

0 comments on commit f364e74

Please sign in to comment.