Skip to content

Commit 7cf4b84

Browse files
authored
Update new header for Alias, Index Templates, Policy Managed Indices, Indexes and Transform Jobs (#1124) (#1137)
* wip: changes for new ui * New UI changes * Header Changes * New UI changes * UTs handel * Header UI changes cr: https://code.amazon.com/reviews/CR-143602949 * Updated Change Policy Page * Fixed bug in alias for new UI * Fixing a few bugs and addressing comments * Fixing a few bugs in old UI --------- Signed-off-by: Kshitij Tandon <[email protected]>
1 parent a3d20e9 commit 7cf4b84

File tree

59 files changed

+3012
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3012
-516
lines changed

public/components/ContentPanel/ContentPanelActions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ interface ContentPanelActionsProps {
1717
onClickModal: (onShow: (component: any, props: object) => void) => () => void;
1818
};
1919
}[];
20+
size?: "s" | "m";
2021
}
2122

22-
const ContentPanelActions: React.SFC<ContentPanelActionsProps> = ({ actions }) => (
23+
const ContentPanelActions: React.SFC<ContentPanelActionsProps> = ({ actions, size }) => (
2324
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
2425
{actions.map(({ text, buttonProps = {}, flexItemProps = {}, modal = null, children }, index) => {
2526
let button = children ? (
2627
children
2728
) : (
28-
<EuiButton {...buttonProps} data-test-subj={`${text}Button`}>
29+
<EuiButton {...buttonProps} data-test-subj={`${text}Button`} size={size ? size : "m"}>
2930
{text}
3031
</EuiButton>
3132
);

public/components/FilterGroup/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export interface IFilterGroupProps {
55
options: { label: string }[];
66
value?: string[];
77
filterButtonProps?: EuiFilterButtonProps;
8-
useNewUx?: boolean;
8+
useNewUX?: boolean;
99
onChange?: (val: IFilterGroupProps["value"]) => void;
1010
}
1111

12-
export default function FilterGroup({ options, value, filterButtonProps, useNewUx, onChange }: IFilterGroupProps) {
12+
export default function FilterGroup({ options, value, filterButtonProps, onChange, useNewUX }: IFilterGroupProps) {
1313
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
1414

1515
const onButtonClick = () => {
@@ -31,7 +31,7 @@ export default function FilterGroup({ options, value, filterButtonProps, useNewU
3131
numFilters={options?.length}
3232
hasActiveFilters={!!value?.length}
3333
numActiveFilters={value?.length}
34-
size={useNewUx ? "s" : undefined}
34+
size={useNewUX ? "s" : undefined}
3535
{...filterButtonProps}
3636
/>
3737
}

public/containers/IndexDetail/IndexDetail.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ import { browserServicesMock, coreServicesMock } from "../../../test/mocks";
1010
import { ServicesContext } from "../../services";
1111
import { CoreServicesContext } from "../../components/core_services";
1212
import { CatIndex } from "../../../server/models/interfaces";
13+
import { getApplication, getNavigationUI, getUISettings } from "../../services/Services";
14+
15+
jest.mock("../../services/Services", () => ({
16+
...jest.requireActual("../../services/Services"),
17+
getUISettings: jest.fn(),
18+
getApplication: jest.fn(),
19+
getNavigationUI: jest.fn(),
20+
}));
21+
22+
beforeEach(() => {
23+
(getUISettings as jest.Mock).mockReturnValue({
24+
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
25+
});
26+
(getApplication as jest.Mock).mockReturnValue({});
27+
28+
(getNavigationUI as jest.Mock).mockReturnValue({});
29+
});
1330

1431
browserServicesMock.commonService.apiCaller = jest.fn(
1532
async (payload): Promise<any> => {

public/pages/Aliases/components/IndexControls/IndexControls.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ import { render, waitFor } from "@testing-library/react";
99
// @ts-ignore
1010
import userEvent from "@testing-library/user-event";
1111
import IndexControls from "./IndexControls";
12+
import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services";
13+
14+
jest.mock("../../../../services/Services", () => ({
15+
...jest.requireActual("../../../../services/Services"),
16+
getUISettings: jest.fn(),
17+
getApplication: jest.fn(),
18+
getNavigationUI: jest.fn(),
19+
}));
20+
21+
beforeEach(() => {
22+
(getUISettings as jest.Mock).mockReturnValue({
23+
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
24+
});
25+
(getApplication as jest.Mock).mockReturnValue({});
26+
27+
(getNavigationUI as jest.Mock).mockReturnValue({});
28+
});
1229

1330
describe("<IndexControls /> spec", () => {
1431
it("renders the component", async () => {

public/pages/Aliases/components/IndexControls/IndexControls.tsx

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55

66
import React, { useEffect, useState } from "react";
77
import { EuiComboBox, EuiFieldSearch, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
8-
import { ALIAS_STATUS_OPTIONS } from "../../../../utils/constants";
8+
import { ALIAS_STATUS_OPTIONS, IndicesUpdateMode } from "../../../../utils/constants";
9+
import { getUISettings } from "../../../../services/Services";
10+
import AliasesActions from "../../containers/AliasActions";
11+
import { IAlias } from "../../interface";
12+
import { RouteComponentProps } from "react-router-dom";
13+
import FilterGroup from "../../../../components/FilterGroup";
914

1015
export interface SearchControlsProps {
1116
value: {
1217
search: string;
1318
status: string;
19+
selectedItems: IAlias[];
1420
};
1521
onSearchChange: (args: SearchControlsProps["value"]) => void;
22+
onDelete: () => Promise<void>;
23+
history: RouteComponentProps["history"];
24+
onUpdateAlias: () => void;
1625
}
1726

1827
export default function SearchControls(props: SearchControlsProps) {
@@ -28,7 +37,42 @@ export default function SearchControls(props: SearchControlsProps) {
2837
useEffect(() => {
2938
setState(props.value);
3039
}, [props.value]);
31-
return (
40+
41+
const uiSettings = getUISettings();
42+
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
43+
44+
return useUpdatedUX ? (
45+
<EuiFlexGroup style={{ padding: "0px 5px" }} alignItems="center">
46+
<EuiFlexItem>
47+
<EuiFieldSearch
48+
compressed
49+
fullWidth
50+
placeholder="Search"
51+
value={state.search}
52+
onChange={(e) => onChange("search", e.target.value)}
53+
/>
54+
</EuiFlexItem>
55+
<EuiFlexItem style={{ flexBasis: "100px" }} grow={false}>
56+
<FilterGroup
57+
filterButtonProps={{
58+
children: "Status",
59+
}}
60+
onChange={(val) => onChange("status", (val || []).map((item) => item).join(","))}
61+
value={state.status ? state.status.split(",").map((label) => label) : []}
62+
options={ALIAS_STATUS_OPTIONS}
63+
useNewUX={useUpdatedUX}
64+
/>
65+
</EuiFlexItem>
66+
<EuiFlexItem grow={false}>
67+
<AliasesActions
68+
onUpdateAlias={props.onUpdateAlias}
69+
selectedItems={props.value.selectedItems}
70+
onDelete={props.onDelete}
71+
history={props.history}
72+
/>
73+
</EuiFlexItem>
74+
</EuiFlexGroup>
75+
) : (
3276
<EuiFlexGroup style={{ padding: "0px 5px" }} alignItems="center">
3377
<EuiFlexItem>
3478
<EuiFieldSearch fullWidth placeholder="Search..." value={state.search} onChange={(e) => onChange("search", e.target.value)} />

public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ import { ServicesContext } from "../../../../services";
1414
import { CoreServicesContext } from "../../../../components/core_services";
1515
import { buildMockApiCallerForFlush, selectedAliases } from "../../../../containers/FlushIndexModal/FlushIndexModalTestHelper";
1616
import { IAlias } from "../../interface";
17+
import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services";
18+
19+
jest.mock("../../../../services/Services", () => ({
20+
...jest.requireActual("../../../../services/Services"),
21+
getUISettings: jest.fn(),
22+
getApplication: jest.fn(),
23+
getNavigationUI: jest.fn(),
24+
}));
25+
26+
beforeEach(() => {
27+
(getUISettings as jest.Mock).mockReturnValue({
28+
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
29+
});
30+
(getApplication as jest.Mock).mockReturnValue({});
31+
32+
(getNavigationUI as jest.Mock).mockReturnValue({});
33+
});
1734

1835
function renderWithRouter(props: Omit<AliasesActionsProps, "history">) {
1936
return {

public/pages/Aliases/containers/AliasActions/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import FlushIndexModal from "../../../../containers/FlushIndexModal";
1212
import RefreshActionModal from "../../../../containers/RefreshAction";
1313
import { IAlias } from "../../interface";
1414
import { ROUTES, INDEX_OP_TARGET_TYPE } from "../../../../utils/constants";
15+
import { getUISettings } from "../../../../services/Services";
1516

1617
export interface AliasesActionsProps {
1718
selectedItems: IAlias[];
@@ -44,14 +45,18 @@ export default function AliasesActions(props: AliasesActionsProps) {
4445
};
4546

4647
const renderKey = useMemo(() => Date.now(), [selectedItems]);
48+
const uiSettings = getUISettings();
49+
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
50+
51+
const size = useUpdatedUX ? "s" : undefined;
4752

4853
return (
4954
<>
5055
<SimplePopover
5156
data-test-subj="moreAction"
5257
panelPaddingSize="none"
5358
button={
54-
<EuiButton iconType="arrowDown" iconSide="right">
59+
<EuiButton iconType="arrowDown" iconSide="right" size={size}>
5560
Actions
5661
</EuiButton>
5762
}

public/pages/Aliases/containers/Aliases/Aliases.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ import { ROUTES } from "../../../../utils/constants";
1515
import { CoreServicesContext } from "../../../../components/core_services";
1616
import userEvent from "@testing-library/user-event";
1717
import { IAlias } from "../../interface";
18+
import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services";
19+
20+
jest.mock("../../../../services/Services", () => ({
21+
...jest.requireActual("../../../../services/Services"),
22+
getUISettings: jest.fn(),
23+
getApplication: jest.fn(),
24+
getNavigationUI: jest.fn(),
25+
}));
26+
27+
beforeEach(() => {
28+
(getUISettings as jest.Mock).mockReturnValue({
29+
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
30+
});
31+
(getApplication as jest.Mock).mockReturnValue({});
32+
33+
(getNavigationUI as jest.Mock).mockReturnValue({});
34+
});
1835

1936
function renderWithRouter() {
2037
return {

0 commit comments

Comments
 (0)