Skip to content

Commit

Permalink
[Security Solution] Rename Administration > Hosts subtab to Endpoints (
Browse files Browse the repository at this point in the history
  • Loading branch information
pzl authored Aug 12, 2020
1 parent e476ba1 commit abcb93e
Show file tree
Hide file tree
Showing 39 changed files with 750 additions and 730 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { HostAction } from '../../management/pages/endpoint_hosts/store/action';
import { EndpointAction } from '../../management/pages/endpoint_hosts/store/action';
import { PolicyListAction } from '../../management/pages/policy/store/policy_list';
import { PolicyDetailsAction } from '../../management/pages/policy/store/policy_details';

Expand All @@ -13,4 +13,4 @@ export { dragAndDropActions } from './drag_and_drop';
export { inputsActions } from './inputs';
import { RoutingAction } from './routing';

export type AppAction = HostAction | RoutingAction | PolicyListAction | PolicyDetailsAction;
export type AppAction = EndpointAction | RoutingAction | PolicyListAction | PolicyDetailsAction;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SecurityPageName } from '../../app/types';
// --[ ROUTING ]---------------------------------------------------------------------------
export const MANAGEMENT_APP_ID = `${APP_ID}:${SecurityPageName.administration}`;
export const MANAGEMENT_ROUTING_ROOT_PATH = '';
export const MANAGEMENT_ROUTING_HOSTS_PATH = `${MANAGEMENT_ROUTING_ROOT_PATH}/:tabName(${AdministrationSubTab.hosts})`;
export const MANAGEMENT_ROUTING_ENDPOINTS_PATH = `${MANAGEMENT_ROUTING_ROOT_PATH}/:tabName(${AdministrationSubTab.endpoints})`;
export const MANAGEMENT_ROUTING_POLICIES_PATH = `${MANAGEMENT_ROUTING_ROOT_PATH}/:tabName(${AdministrationSubTab.policies})`;
export const MANAGEMENT_ROUTING_POLICY_DETAILS_PATH = `${MANAGEMENT_ROUTING_ROOT_PATH}/:tabName(${AdministrationSubTab.policies})/:policyId`;

Expand All @@ -21,5 +21,5 @@ export const MANAGEMENT_STORE_GLOBAL_NAMESPACE: ManagementStoreGlobalNamespace =
export const MANAGEMENT_STORE_POLICY_LIST_NAMESPACE = 'policyList';
/** Namespace within the Management state where policy details state is maintained */
export const MANAGEMENT_STORE_POLICY_DETAILS_NAMESPACE = 'policyDetails';
/** Namespace within the Management state where hosts state is maintained */
export const MANAGEMENT_STORE_HOSTS_NAMESPACE = 'hosts';
/** Namespace within the Management state where endpoint-host state is maintained */
export const MANAGEMENT_STORE_ENDPOINTS_NAMESPACE = 'endpoints';
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { generatePath } from 'react-router-dom';
import querystring from 'querystring';

import {
MANAGEMENT_ROUTING_HOSTS_PATH,
MANAGEMENT_ROUTING_ENDPOINTS_PATH,
MANAGEMENT_ROUTING_POLICIES_PATH,
MANAGEMENT_ROUTING_POLICY_DETAILS_PATH,
} from './constants';
import { AdministrationSubTab } from '../types';
import { appendSearch } from '../../common/components/link_to/helpers';
import { HostIndexUIQueryParams } from '../pages/endpoint_hosts/types';
import { EndpointIndexUIQueryParams } from '../pages/endpoint_hosts/types';

// Taken from: https://github.com/microsoft/TypeScript/issues/12936#issuecomment-559034150
type ExactKeys<T1, T2> = Exclude<keyof T1, keyof T2> extends never ? T1 : never;
Expand All @@ -31,42 +31,44 @@ const querystringStringify: <ExpectedType extends object, ArgType>(
params: Exact<ExpectedType, ArgType>
) => string = querystring.stringify;

/** Make `selected_host` required */
type HostDetailsUrlProps = Omit<HostIndexUIQueryParams, 'selected_host'> &
Required<Pick<HostIndexUIQueryParams, 'selected_host'>>;
/** Make `selected_endpoint` required */
type EndpointDetailsUrlProps = Omit<EndpointIndexUIQueryParams, 'selected_endpoint'> &
Required<Pick<EndpointIndexUIQueryParams, 'selected_endpoint'>>;

export const getHostListPath = (
props: { name: 'default' | 'hostList' } & HostIndexUIQueryParams,
export const getEndpointListPath = (
props: { name: 'default' | 'endpointList' } & EndpointIndexUIQueryParams,
search?: string
) => {
const { name, ...queryParams } = props;
const urlQueryParams = querystringStringify<HostIndexUIQueryParams, typeof queryParams>(
const urlQueryParams = querystringStringify<EndpointIndexUIQueryParams, typeof queryParams>(
queryParams
);
const urlSearch = `${urlQueryParams && !isEmpty(search) ? '&' : ''}${search ?? ''}`;

if (name === 'hostList') {
return `${generatePath(MANAGEMENT_ROUTING_HOSTS_PATH, {
tabName: AdministrationSubTab.hosts,
if (name === 'endpointList') {
return `${generatePath(MANAGEMENT_ROUTING_ENDPOINTS_PATH, {
tabName: AdministrationSubTab.endpoints,
})}${appendSearch(`${urlQueryParams ? `${urlQueryParams}${urlSearch}` : urlSearch}`)}`;
}
return `${appendSearch(`${urlQueryParams ? `${urlQueryParams}${urlSearch}` : urlSearch}`)}`;
};

export const getHostDetailsPath = (
props: { name: 'hostDetails' | 'hostPolicyResponse' } & HostIndexUIQueryParams &
HostDetailsUrlProps,
export const getEndpointDetailsPath = (
props: { name: 'endpointDetails' | 'endpointPolicyResponse' } & EndpointIndexUIQueryParams &
EndpointDetailsUrlProps,
search?: string
) => {
const { name, ...queryParams } = props;
queryParams.show = (props.name === 'hostPolicyResponse'
queryParams.show = (props.name === 'endpointPolicyResponse'
? 'policy_response'
: '') as HostIndexUIQueryParams['show'];
const urlQueryParams = querystringStringify<HostDetailsUrlProps, typeof queryParams>(queryParams);
: '') as EndpointIndexUIQueryParams['show'];
const urlQueryParams = querystringStringify<EndpointDetailsUrlProps, typeof queryParams>(
queryParams
);
const urlSearch = `${urlQueryParams && !isEmpty(search) ? '&' : ''}${search ?? ''}`;

return `${generatePath(MANAGEMENT_ROUTING_HOSTS_PATH, {
tabName: AdministrationSubTab.hosts,
return `${generatePath(MANAGEMENT_ROUTING_ENDPOINTS_PATH, {
tabName: AdministrationSubTab.endpoints,
})}${appendSearch(`${urlQueryParams ? `${urlQueryParams}${urlSearch}` : urlSearch}`)}`;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import { i18n } from '@kbn/i18n';

export const HOSTS_TAB = i18n.translate('xpack.securitySolution.hostsTab', {
defaultMessage: 'Hosts',
export const ENDPOINTS_TAB = i18n.translate('xpack.securitySolution.endpointsTab', {
defaultMessage: 'Endpoints',
});

export const POLICIES_TAB = i18n.translate('xpack.securitySolution.policiesTab', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const PolicyEmptyState = React.memo<{
);
});

const HostsEmptyState = React.memo<{
const EndpointsEmptyState = React.memo<{
loading: boolean;
onActionClick: (event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
actionDisabled: boolean;
Expand All @@ -126,14 +126,14 @@ const HostsEmptyState = React.memo<{
const policySteps = useMemo(
() => [
{
title: i18n.translate('xpack.securitySolution.endpoint.hostList.stepOneTitle', {
title: i18n.translate('xpack.securitySolution.endpoint.list.stepOneTitle', {
defaultMessage: 'Select the integration you want to use',
}),
children: (
<>
<EuiText color="subdued" size="m" grow={false}>
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.stepOne"
id="xpack.securitySolution.endpoint.list.stepOne"
defaultMessage="Select from existing integrations. This can be changed later."
/>
</EuiText>
Expand All @@ -151,15 +151,15 @@ const HostsEmptyState = React.memo<{
return loading ? (
<EuiSelectableMessage>
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.loadingPolicies"
id="xpack.securitySolution.endpoint.list.loadingPolicies"
defaultMessage="Loading integrations"
/>
</EuiSelectableMessage>
) : selectionOptions.length ? (
list
) : (
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.noPolicies"
id="xpack.securitySolution.endpoint.list.noPolicies"
defaultMessage="There are no integrations."
/>
);
Expand All @@ -169,7 +169,7 @@ const HostsEmptyState = React.memo<{
),
},
{
title: i18n.translate('xpack.securitySolution.endpoint.hostList.stepTwoTitle', {
title: i18n.translate('xpack.securitySolution.endpoint.list.stepTwoTitle', {
defaultMessage:
'Enroll your agents enabled with Endpoint Security through Ingest Manager',
}),
Expand All @@ -179,7 +179,7 @@ const HostsEmptyState = React.memo<{
<EuiFlexItem>
<EuiText color="subdued" size="m" grow={false}>
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.stepTwo"
id="xpack.securitySolution.endpoint.list.stepTwo"
defaultMessage="You’ll be provided with the necessary commands to get started."
/>
</EuiText>
Expand Down Expand Up @@ -211,13 +211,13 @@ const HostsEmptyState = React.memo<{
steps={policySteps}
headerComponent={
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.noEndpointsPrompt"
id="xpack.securitySolution.endpoint.list.noEndpointsPrompt"
defaultMessage="Next step: Enroll an Agent with Elastic Endpoint Security"
/>
}
bodyComponent={
<FormattedMessage
id="xpack.securitySolution.endpoint.hostList.noEndpointsInstructions"
id="xpack.securitySolution.endpoint.list.noEndpointsInstructions"
defaultMessage="You’ve added the Endpoint Security integration. Now enroll your agents using the steps below."
/>
}
Expand Down Expand Up @@ -265,7 +265,7 @@ const ManagementEmptyState = React.memo<{
});

PolicyEmptyState.displayName = 'PolicyEmptyState';
HostsEmptyState.displayName = 'HostsEmptyState';
EndpointsEmptyState.displayName = 'HostsEmptyState';
ManagementEmptyState.displayName = 'ManagementEmptyState';

export { PolicyEmptyState, HostsEmptyState };
export { PolicyEmptyState, EndpointsEmptyState as HostsEmptyState };
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

import { Switch, Route } from 'react-router-dom';
import React, { memo } from 'react';
import { HostList } from './view';
import { MANAGEMENT_ROUTING_HOSTS_PATH } from '../../common/constants';
import { EndpointList } from './view';
import { MANAGEMENT_ROUTING_ENDPOINTS_PATH } from '../../common/constants';
import { NotFoundPage } from '../../../app/404';

/**
* Provides the routing container for the hosts related views
*/
export const HostsContainer = memo(() => {
export const EndpointsContainer = memo(() => {
return (
<Switch>
<Route path={MANAGEMENT_ROUTING_HOSTS_PATH} exact component={HostList} />
<Route path={MANAGEMENT_ROUTING_ENDPOINTS_PATH} exact component={EndpointList} />
<Route path="*" component={NotFoundPage} />
</Switch>
);
});

HostsContainer.displayName = 'HostsContainer';
EndpointsContainer.displayName = 'EndpointsContainer';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';

import { HostList } from './view';
import { EndpointList } from './view';

export const EndpointHostsRoutes: React.FC = () => (
<Switch>
<Route path="/:pageName(endpoint-hosts)">
<HostList />
<Route path="/:pageName(endpoint-endpoints)">
<EndpointList />
</Route>
</Switch>
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ import {
import { ServerApiError } from '../../../../common/types';
import { GetPolicyListResponse } from '../../policy/types';
import { GetPackagesResponse } from '../../../../../../ingest_manager/common';
import { HostState } from '../types';
import { EndpointState } from '../types';

interface ServerReturnedHostList {
type: 'serverReturnedHostList';
interface ServerReturnedEndpointList {
type: 'serverReturnedEndpointList';
payload: HostResultList;
}

interface ServerFailedToReturnHostList {
type: 'serverFailedToReturnHostList';
interface ServerFailedToReturnEndpointList {
type: 'serverFailedToReturnEndpointList';
payload: ServerApiError;
}

interface ServerReturnedHostDetails {
type: 'serverReturnedHostDetails';
interface ServerReturnedEndpointDetails {
type: 'serverReturnedEndpointDetails';
payload: HostInfo;
}

interface ServerFailedToReturnHostDetails {
type: 'serverFailedToReturnHostDetails';
interface ServerFailedToReturnEndpointDetails {
type: 'serverFailedToReturnEndpointDetails';
payload: ServerApiError;
}

interface ServerReturnedHostPolicyResponse {
type: 'serverReturnedHostPolicyResponse';
interface ServerReturnedEndpointPolicyResponse {
type: 'serverReturnedEndpointPolicyResponse';
payload: GetHostPolicyResponse;
}

interface ServerFailedToReturnHostPolicyResponse {
type: 'serverFailedToReturnHostPolicyResponse';
interface ServerFailedToReturnEndpointPolicyResponse {
type: 'serverFailedToReturnEndpointPolicyResponse';
payload: ServerApiError;
}

Expand All @@ -63,8 +63,8 @@ interface UserSelectedEndpointPolicy {
};
}

interface ServerCancelledHostListLoading {
type: 'serverCancelledHostListLoading';
interface ServerCancelledEndpointListLoading {
type: 'serverCancelledEndpointListLoading';
}

interface ServerCancelledPolicyItemsLoading {
Expand All @@ -76,28 +76,28 @@ interface ServerReturnedEndpointPackageInfo {
payload: GetPackagesResponse['response'][0];
}

interface ServerReturnedHostNonExistingPolicies {
type: 'serverReturnedHostNonExistingPolicies';
payload: HostState['nonExistingPolicies'];
interface ServerReturnedEndpointNonExistingPolicies {
type: 'serverReturnedEndpointNonExistingPolicies';
payload: EndpointState['nonExistingPolicies'];
}

interface ServerReturnedHostExistValue {
type: 'serverReturnedHostExistValue';
interface ServerReturnedEndpointExistValue {
type: 'serverReturnedEndpointExistValue';
payload: boolean;
}

export type HostAction =
| ServerReturnedHostList
| ServerFailedToReturnHostList
| ServerReturnedHostDetails
| ServerFailedToReturnHostDetails
| ServerReturnedHostPolicyResponse
| ServerFailedToReturnHostPolicyResponse
export type EndpointAction =
| ServerReturnedEndpointList
| ServerFailedToReturnEndpointList
| ServerReturnedEndpointDetails
| ServerFailedToReturnEndpointDetails
| ServerReturnedEndpointPolicyResponse
| ServerFailedToReturnEndpointPolicyResponse
| ServerReturnedPoliciesForOnboarding
| ServerFailedToReturnPoliciesForOnboarding
| UserSelectedEndpointPolicy
| ServerCancelledHostListLoading
| ServerReturnedHostExistValue
| ServerCancelledEndpointListLoading
| ServerReturnedEndpointExistValue
| ServerCancelledPolicyItemsLoading
| ServerReturnedEndpointPackageInfo
| ServerReturnedHostNonExistingPolicies;
| ServerReturnedEndpointNonExistingPolicies;
Loading

0 comments on commit abcb93e

Please sign in to comment.