Skip to content

Commit

Permalink
Reduce code conflicts (#589) (#590)
Browse files Browse the repository at this point in the history
* Item count in Content panel

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

* Constants

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

* Datastream security message

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

* Unify the refresh

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

* Update test snapshot

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

* Update cypress test

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
(cherry picked from commit 74c0da1)

Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com>
  • Loading branch information
1 parent 8061fca commit 307c986
Show file tree
Hide file tree
Showing 44 changed files with 366 additions and 613 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/managed_indices_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe("Managed indices", () => {
cy.contains("Changed policy on 1 indices");

// Click back to Managed Indices page by clicking "Managed indices" breadcrumb
cy.contains("Managed indices").click();
cy.contains("Policy managed indices").click();

// Speed up execution of managed index
cy.updateManagedIndexConfigStartTime(SAMPLE_INDEX);
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/policies_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Policies", () => {
cy.contains("Continue").click({ force: true });

// Wait for input to load and then type in the policy ID
cy.get(`input[placeholder="hot_cold_workflow"]`).type(POLICY_ID, { force: true });
cy.get(`input[placeholder="example_policy"]`).type(POLICY_ID, { force: true });

// Wait for default policy JSON to load
cy.contains("A simple default policy");
Expand Down Expand Up @@ -188,5 +188,5 @@ describe("Policies", () => {
cy.get(`[data-test-subj="viewButton"]`).click({ force: true });
cy.contains(`View JSON of ${POLICY_ID}`);
});
})
});
});
7 changes: 6 additions & 1 deletion public/components/ContentPanel/ContentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ContentPanelProps {
horizontalRuleClassName?: string;
actions?: React.ReactNode | React.ReactNode[];
children: React.ReactNode | React.ReactNode[];
itemCount?: number;
}

const renderSubTitleText = (subTitleText: string | JSX.Element): JSX.Element | null => {
Expand All @@ -38,13 +39,17 @@ const ContentPanel: React.SFC<ContentPanelProps> = ({
horizontalRuleClassName = "",
actions,
children,
itemCount = 0,
}) => (
<EuiPanel style={{ paddingLeft: "0px", paddingRight: "0px", ...panelStyles }}>
<EuiFlexGroup style={{ padding: "0px 10px" }} justifyContent="spaceBetween" alignItems="flexStart">
<EuiFlexItem>
{typeof title === "string" ? (
<EuiTitle size={titleSize}>
<h3>{title}</h3>
<h3>
{title}
<span className="panel-header-count"> {itemCount > 0 ? `(${itemCount})` : null} </span>
</h3>
</EuiTitle>
) : (
title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ContentPanel /> spec renders the component 1`] = `
class="euiTitle euiTitle--large"
>
Testing
<span
class="panel-header-count"
>
</span>
</h3>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ exports[`<IndexDetail /> spec render the component 1`] = `
class="euiTitle euiTitle--small"
>
Source index details
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ChangeManagedIndices /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose managed indices
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<NewPolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose new policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose managed indices
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -221,6 +227,12 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Choose new policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<IndexDetail /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Define index
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ exports[`<CreateIndexTemplate /> spec it goes to templates page when click cance
class="euiTitle euiTitle--small"
>
Template details
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -273,6 +279,12 @@ exports[`<CreateIndexTemplate /> spec it goes to templates page when click cance
class="euiTitle euiTitle--small"
>
Index settings
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ exports[`<TemplateDetail /> spec render component 1`] = `
class="euiTitle euiTitle--small"
>
Define template
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -464,6 +470,12 @@ exports[`<TemplateDetail /> spec render component 1`] = `
class="euiTitle euiTitle--small"
>
Index settings
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ConfigurePolicy = ({ isEdit, policyId, policyIdError, onChange }: Configur
isInvalid={!!policyIdError}
error={policyIdError}
>
<EuiFieldText isInvalid={!!policyIdError} placeholder="hot_cold_workflow" readOnly={isEdit} value={policyId} onChange={onChange} />
<EuiFieldText isInvalid={!!policyIdError} placeholder="example_policy" readOnly={isEdit} value={policyId} onChange={onChange} />
</EuiFormRow>
</div>
</ContentPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<ConfigurePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Name policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
</div>
Expand Down Expand Up @@ -66,7 +72,7 @@ exports[`<ConfigurePolicy /> spec renders the component 1`] = `
aria-describedby="some_html_id-help-0"
class="euiFieldText"
id="some_html_id"
placeholder="hot_cold_workflow"
placeholder="example_policy"
type="text"
value="some_id"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports[`<DefinePolicy /> spec renders the component 1`] = `
class="euiTitle euiTitle--small"
>
Define policy
<span
class="panel-header-count"
>
</span>
</h3>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("<CreatePolicy /> spec", () => {

await waitFor(() => getByDisplayValue("some_id"));

expect(getByPlaceholderText("hot_cold_workflow")).toHaveAttribute("readonly");
expect(getByPlaceholderText("example_policy")).toHaveAttribute("readonly");
});

it("shows error for policyId input when clicking create", async () => {
Expand All @@ -127,9 +127,9 @@ describe("<CreatePolicy /> spec", () => {

expect(queryByText("Required")).not.toBeNull();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

expect(queryByText("Required")).toBeNull();
});
Expand All @@ -138,9 +138,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockResolvedValue({ ok: true, response: { _id: "some_policy_id" } });
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand All @@ -152,9 +152,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockResolvedValue({ ok: false, error: "bad policy" });
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand All @@ -165,9 +165,9 @@ describe("<CreatePolicy /> spec", () => {
browserServicesMock.policyService.putPolicy = jest.fn().mockRejectedValue(new Error("this is an error"));
const { getByText, getByTestId, getByPlaceholderText } = renderCreatePolicyWithRouter();

fireEvent.focus(getByPlaceholderText("hot_cold_workflow"));
userEvent.type(getByPlaceholderText("hot_cold_workflow"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("hot_cold_workflow"));
fireEvent.focus(getByPlaceholderText("example_policy"));
userEvent.type(getByPlaceholderText("example_policy"), `some_policy_id`);
fireEvent.blur(getByPlaceholderText("example_policy"));

userEvent.click(getByTestId("createPolicyCreateButton"));

Expand Down
Loading

0 comments on commit 307c986

Please sign in to comment.