Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update newHeader for component template pages #1122

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public/components/FilterGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ export interface IFilterGroupProps {
options: { label: string }[];
value?: string[];
filterButtonProps?: EuiFilterButtonProps;
useNewUx?: boolean;
onChange?: (val: IFilterGroupProps["value"]) => void;
}

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

const onButtonClick = () => {
Expand All @@ -30,6 +31,7 @@ export default function FilterGroup({ options, value, filterButtonProps, onChang
numFilters={options?.length}
hasActiveFilters={!!value?.length}
numActiveFilters={value?.length}
size={useNewUx ? "s" : undefined}
{...filterButtonProps}
/>
}
Expand Down
10 changes: 8 additions & 2 deletions public/components/IndexMapping/IndexMapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export * from "./helper";
export * from "./interfaces";

const IndexMapping = (
{ value: propsValue, onChange: propsOnChange, isEdit, oldValue, readonly, docVersion }: IndexMappingProps,
{ value: propsValue, onChange: propsOnChange, isEdit, oldValue, readonly, docVersion, useNewUx }: IndexMappingProps,
ref: Ref<IIndexMappingsRef>
) => {
const value = propsValue?.properties || [];
Expand Down Expand Up @@ -194,10 +194,16 @@ const IndexMapping = (
{readonly ? null : (
<>
<EuiSpacer />
<EuiButton style={{ marginRight: 8 }} data-test-subj="createIndexAddFieldButton" onClick={() => addField("")}>
<EuiButton
size={useNewUx ? "s" : undefined}
style={{ marginRight: 8 }}
data-test-subj="createIndexAddFieldButton"
onClick={() => addField("")}
>
Add new field
</EuiButton>
<EuiButton
size={useNewUx ? "s" : undefined}
data-test-subj="createIndexAddObjectFieldButton"
onClick={() =>
addField("", {
Expand Down
1 change: 1 addition & 0 deletions public/components/IndexMapping/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface IndexMappingProps {
oldMappingsEditable?: boolean; // in template edit case, existing mappings is editable
readonly?: boolean;
docVersion: string;
useNewUx?: boolean;
}

export enum EDITOR_MODE {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { useEffect, useState } from "react";
import { EuiFieldSearch, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import { EuiButton, EuiFieldSearch, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import FilterGroup from "../../../../components/FilterGroup";
import { IndicesUpdateMode } from "../../../../utils/constants";

Expand All @@ -13,6 +13,7 @@ export interface SearchControlsProps {
search: string;
selectedTypes: string[];
};
useNewUX?: boolean;
onSearchChange: (args: SearchControlsProps["value"]) => void;
}

Expand All @@ -32,7 +33,13 @@ export default function SearchControls(props: SearchControlsProps) {
return (
<EuiFlexGroup style={{ padding: "0px 5px" }} alignItems="center">
<EuiFlexItem>
<EuiFieldSearch fullWidth placeholder="Search..." value={state.search} onChange={(e) => onChange("search", e.target.value)} />
<EuiFieldSearch
compressed={props.useNewUX}
fullWidth
placeholder="Search..."
value={state.search}
onChange={(e) => onChange("search", e.target.value)}
/>
</EuiFlexItem>
<EuiFlexItem style={{ flexBasis: "100px" }} grow={false}>
<FilterGroup
Expand All @@ -41,6 +48,7 @@ export default function SearchControls(props: SearchControlsProps) {
}}
onChange={(val) => onChange("selectedTypes", val || [])}
value={state.selectedTypes}
useNewUx={props.useNewUX}
options={[
{
label: IndicesUpdateMode.alias,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ import { ROUTES } from "../../../../utils/constants";
import { CoreServicesContext } from "../../../../components/core_services";
import userEvent from "@testing-library/user-event";
import { ICatComposableTemplate } from "../../interface";
import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services";

jest.mock("../../../../services/Services", () => ({
...jest.requireActual("../../../../services/Services"),
getUISettings: jest.fn(),
getApplication: jest.fn(),
getNavigationUI: jest.fn(),
}));

beforeEach(() => {
(getUISettings as jest.Mock).mockReturnValue({
get: jest.fn().mockReturnValue(false), // or false, depending on your test case
});
(getApplication as jest.Mock).mockReturnValue({});

(getNavigationUI as jest.Mock).mockReturnValue({});
});

function renderWithRouter() {
return {
Expand Down
Loading
Loading