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

feat: squash commit #3

Open
wants to merge 44 commits into
base: feature/notification-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8fa6b77
feat: update
SuZhou-Joe Mar 13, 2023
c86f9c6
feat: update
SuZhou-Joe Mar 13, 2023
3e27411
feat: update
SuZhou-Joe Mar 13, 2023
72c5503
feat: update
SuZhou-Joe Mar 13, 2023
77322ab
feat: update
SuZhou-Joe Mar 15, 2023
5762b54
feat: update
SuZhou-Joe Mar 15, 2023
76ce5e4
feat: update open index logic
SuZhou-Joe Mar 22, 2023
7cd4254
feat: update
SuZhou-Joe Mar 22, 2023
066a169
feat: optimize logic in callbacks
SuZhou-Joe Mar 27, 2023
f4344fb
feat: update unit test
SuZhou-Joe Mar 28, 2023
f4e89f0
feat: update
SuZhou-Joe Mar 29, 2023
9bc8de1
feat: update split logic
SuZhou-Joe Apr 25, 2023
3916f52
feat: optimize code logic
SuZhou-Joe Apr 25, 2023
84cf37e
feat: update cypress test
SuZhou-Joe Apr 25, 2023
0beb4b7
feat: add unit test for force merge
SuZhou-Joe Apr 26, 2023
8d9cfb9
feat: add unit test for open
SuZhou-Joe Apr 26, 2023
dc5966f
feat: update unit test for reindex
SuZhou-Joe Apr 26, 2023
ca40f75
feat: add unit test for shrink & split
SuZhou-Joe Apr 26, 2023
fb55249
feat: make cypress test run
SuZhou-Joe Apr 26, 2023
91d229d
feat: add cluster info to job meta data
SuZhou-Joe Apr 27, 2023
f2cf589
feat: enhance message with cluster info
SuZhou-Joe Apr 27, 2023
77cd8bb
feat: enhance all with cluster info
SuZhou-Joe Apr 27, 2023
dbcae22
feat: wording change
SuZhou-Joe May 10, 2023
b64209e
feat: make unit test pass
SuZhou-Joe May 10, 2023
40f526a
feat: squash commit
SuZhou-Joe May 10, 2023
692bf09
feat: reduce useless code
SuZhou-Joe May 10, 2023
d360e61
feat: update settings
SuZhou-Joe May 15, 2023
3afe510
feat: add icon
SuZhou-Joe May 15, 2023
98181e0
feat: use accordion
SuZhou-Joe May 15, 2023
878c45f
feat: remove extra spacing when container is closed
SuZhou-Joe May 15, 2023
0848cd6
feat: update title style
SuZhou-Joe May 15, 2023
1a41125
fix: useless call
SuZhou-Joe May 17, 2023
75e5e8d
feat: add default condition
SuZhou-Joe May 17, 2023
2632eb8
feat: add line height
SuZhou-Joe May 18, 2023
295488c
feat: make unit test pass
SuZhou-Joe May 25, 2023
f322078
temp: merge
SuZhou-Joe May 26, 2023
507e534
feat: change wording
SuZhou-Joe May 26, 2023
cd0d00d
feat: update
SuZhou-Joe May 26, 2023
0acf7eb
Side effects after taskable long running operation (#732)
SuZhou-Joe May 26, 2023
df0925e
temp: merge
SuZhou-Joe May 26, 2023
705db4a
feat: remove useless change
SuZhou-Joe May 26, 2023
213a2f9
feat: hide invalid channel
SuZhou-Joe May 26, 2023
fc67b33
feat: update snapshot
SuZhou-Joe May 26, 2023
2912fd5
feat: remove flaky test
SuZhou-Joe May 26, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { IM_PLUGIN_NAME, BASE_PATH, BACKEND_BASE_PATH } from "../../../utils/constants";

const ActionTypeName = {
reindex: "indices:data/write/reindex",
resize: "indices:admin/resize",
forcemerge: "indices:admin/forcemerge",
open: "indices:admin/open",
};

const channel = "test_for_cypress";

const clearLRONConfig = () => {
Object.values(ActionTypeName).forEach((actionTypeName) => {
cy.request({
method: "PUT",
url: `${BACKEND_BASE_PATH}/_plugins/_im/lron/${encodeURIComponent(`LRON:${actionTypeName}`)}`,
body: {
lron_config: {
lron_condition: {
success: false,
failure: false,
},
action_name: actionTypeName,
channels: [],
},
},
});
});
};

const allAction = Object.values(ActionTypeName);

const clearChannel = () => {
cy.request({
method: "DELETE",
url: `${BACKEND_BASE_PATH}/_plugins/_notifications/configs/test_for_cypress`,
failOnStatusCode: false,
});
};

describe("NotificationSettings", () => {
before(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
clearLRONConfig();
clearChannel();
cy.request({
method: "POST",
url: `${BACKEND_BASE_PATH}/_plugins/_notifications/configs/`,
body: {
config_id: "test_for_cypress",
name: channel,
config: {
name: channel,
description: channel,
config_type: "slack",
is_enabled: true,
slack: {
url: "https://sample-slack-webhook",
},
},
},
});
});

beforeEach(() => {
// Visit ISM OSD
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/notifications`);

// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains("Defaults for index operations", { timeout: 60000 });
});

describe("Display all with empty", () => {
it("successfully", () => {
allAction.forEach((item, index) => {
cy.get(`[data-test-subj="dataSource.${index}.channels"]`).should("not.exist");
});
});
});

describe("Set one to notify", () => {
it("successfully", () => {
cy.get(`[data-test-subj="dataSource.0.failure"]`).check({
force: true,
});
cy.get(`[data-test-subj="dataSource.0.channels"] [data-test-subj="comboBoxSearchInput"]`).type(`${channel}{enter}`);
cy.get('[data-test-subj="submitNotifcationSettings"]').click({
force: true,
});
cy.contains("Notifications settings for index operations have been successfully updated.");
cy.reload();
cy.contains(channel);
cy.get(`[data-test-subj="dataSource.0.failure"]`).should("be.checked");
});
});

after(() => {
clearLRONConfig();
clearChannel();
});
});
11 changes: 3 additions & 8 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
"id": "indexManagementDashboards",
"version": "3.0.0.0",
"opensearchDashboardsVersion": "3.0.0",
"configPath": [
"opensearch_index_management"
],
"requiredPlugins": [
"navigation",
"opensearchDashboardsReact"
],
"configPath": ["opensearch_index_management"],
"requiredPlugins": ["navigation", "opensearchDashboardsReact"],
"server": true,
"ui": true
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
"engines": {
"yarn": "^1.21.1"
}
}
}
2 changes: 1 addition & 1 deletion public/JobHandler/callbacks/force_merge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const callbackForForceMergeTimeout: CallbackType = (job: ForceMergeJobMet
) as unknown) as string,
text: ((
<>
The force merge operation has taken more than one hour to complete. To see the latest status, use `GET /.tasks/_doc/
The force merge operation has taken more than one hour to complete. To see the latest status, use `GET /_tasks/
{extras.taskId}`
</>
) as unknown) as string,
Expand Down
2 changes: 1 addition & 1 deletion public/JobHandler/callbacks/open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const callbackForOpenTimeout: CallbackType = (job: OpenJobMetaData, { cor
</>
) as unknown) as string,
text: ((
<>Opening the index has taken more than one hour to complete. To see the latest status, use `GET /.tasks/_doc/{extras.taskId}`</>
<>Opening the index has taken more than one hour to complete. To see the latest status, use `GET /_tasks/{extras.taskId}`</>
) as unknown) as string,
},
{
Expand Down
4 changes: 1 addition & 3 deletions public/JobHandler/callbacks/reindex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ export const callbackForReindexTimeout: CallbackType = (job: ReindexJobMetaData,
</>
) as unknown) as string,
text: ((
<>
The reindex operation has taken more than one hour to complete. To see the latest status, use `GET /.tasks/_doc/{extras.taskId}`
</>
<>The reindex operation has taken more than one hour to complete. To see the latest status, use `GET /_tasks/{extras.taskId}`</>
) as unknown) as string,
},
{
Expand Down
2 changes: 1 addition & 1 deletion public/JobHandler/callbacks/shrink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const callbackForShrinkTimeout: CallbackType = (job: RecoveryJobMetaData,
</>
) as unknown) as string,
text: ((
<>The shrink operation has taken more than one hour to complete. To see the latest status, use `GET /.tasks/_doc/{extras.taskId}`</>
<>The shrink operation has taken more than one hour to complete. To see the latest status, use `GET /_tasks/{extras.taskId}`</>
) as unknown) as string,
},
{
Expand Down
2 changes: 1 addition & 1 deletion public/JobHandler/callbacks/split.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const callbackForSplitTimeout: CallbackType = (job: RecoveryJobMetaData,
</>
) as unknown) as string,
text: ((
<>The split operation has taken more than one hour to complete. To see the latest status, use `GET /.tasks/_doc/{extras.taskId}`</>
<>The split operation has taken more than one hour to complete. To see the latest status, use `GET /_tasks/{extras.taskId}`</>
) as unknown) as string,
},
{
Expand Down
2 changes: 1 addition & 1 deletion public/components/ContentPanel/ContentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
EuiTextColor,
} from "@elastic/eui";

interface ContentPanelProps {
export interface ContentPanelProps {
title?: string | JSX.Element;
titleSize?: "xxxs" | "xxs" | "xs" | "s" | "m" | "l";
subTitleText?: string | JSX.Element;
Expand Down
4 changes: 2 additions & 2 deletions public/components/ContentPanel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import ContentPanel from "./ContentPanel";
import ContentPanel, { ContentPanelProps } from "./ContentPanel";
import ContentPanelActions from "./ContentPanelActions";

export { ContentPanel, ContentPanelActions };
export { ContentPanel, ContentPanelActions, ContentPanelProps };
56 changes: 54 additions & 2 deletions public/components/FormGenerator/built_in_components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import React, { forwardRef, useRef } from "react";
import { EuiFieldNumber, EuiFieldText, EuiSwitch, EuiSelect, EuiText, EuiCheckbox } from "@elastic/eui";
import { EuiFieldNumber, EuiFieldText, EuiSwitch, EuiSelect, EuiText, EuiCheckbox, EuiComboBoxOptionOption } from "@elastic/eui";
import EuiToolTipWrapper, { IEuiToolTipWrapperProps } from "../../EuiToolTipWrapper";
import EuiComboBox from "../../ComboBoxWithoutWarning";

export type ComponentMapEnum = "Input" | "Number" | "Switch" | "Select" | "Text" | "ComboBoxSingle" | "CheckBox";
export type ComponentMapEnum = "Input" | "Number" | "Switch" | "Select" | "Text" | "ComboBoxSingle" | "CheckBox" | "ComboBoxMultiple";

export interface IFieldComponentProps extends IEuiToolTipWrapperProps {
onChange: (val: IFieldComponentProps["value"], ...args: any) => void;
Expand Down Expand Up @@ -102,6 +102,58 @@ const componentMap: Record<ComponentMapEnum, React.ComponentType<IFieldComponent
);
})
) as React.ComponentType<IFieldComponentProps>,
ComboBoxMultiple: EuiToolTipWrapper(
forwardRef(
(
{
onChange,
value,
...others
}: {
value?: string[];
options: EuiComboBoxOptionOption<string>[];
onChange: (val: string[], values: EuiComboBoxOptionOption<string>[], ...args: any) => void;
},
ref: React.Ref<any>
) => {
return (
<EuiComboBox
onCreateOption={(searchValue) => {
const allOptions = others.options.reduce((total, current) => {
if (current.options) {
return [...total, ...current.options];
} else {
return [...total, current];
}
}, [] as EuiComboBoxOptionOption<string>[]);
const findItem = allOptions.find((item: { label: string }) => item.label === searchValue);
if (findItem) {
onChange(
[...(value || []), searchValue],
[
...allOptions.filter((item) => value?.includes(item.label)),
{
label: searchValue,
},
]
);
}
}}
{...others}
ref={ref}
onChange={(selectedOptions) => {
onChange(selectedOptions.map((item) => item.value) as string[], selectedOptions);
}}
selectedOptions={
(value || [])
.map((item: string) => others.options.find((option) => option.value === item) || { label: item, value: item })
.filter((item) => item !== undefined) as EuiComboBoxOptionOption<string>[]
}
/>
);
}
)
) as React.ComponentType<IFieldComponentProps>,
};

export default componentMap;
18 changes: 9 additions & 9 deletions public/components/FormGenerator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export interface IField {
options?: Omit<IInitOption, "name">;
}

export interface IFormGeneratorProps<T> {
export interface IFormGeneratorProps<T extends object = any> {
formFields: IField[];
resetValuesWhenPropsValueChange?: boolean;
hasAdvancedSettings?: boolean;
advancedSettingsProps?: IFormGeneratorAdvancedSettings<T>;
fieldProps?: FieldOption;
fieldProps?: FieldOption<T>;
formProps?: EuiFormProps;
value?: T;
onChange?: (totalValue: IFormGeneratorProps<T>["value"], key?: FieldName, value?: any) => void;
Expand All @@ -48,7 +48,7 @@ export interface IFormGeneratorRef extends FieldInstance {}

export { AllBuiltInComponents };

function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGeneratorRef>) {
function FormGenerator<T extends object = any>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGeneratorRef>) {
const { fieldProps, formFields, advancedSettingsProps } = props;
const { blockedNameList } = advancedSettingsProps || {};
const propsRef = useRef(props);
Expand Down Expand Up @@ -80,9 +80,9 @@ function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGen
useEffect(() => {
if (!isEqual(field.getValues(), props.value)) {
if (propsRef.current.resetValuesWhenPropsValueChange) {
field.resetValues(props.value);
field.resetValues(props.value as T);
} else {
field.setValues(props.value);
field.setValues(props.value as T);
}
}
}, [props.value]);
Expand Down Expand Up @@ -117,7 +117,7 @@ function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGen
});
}, [formFields, field]);

const finalValue: T = useMemo(() => {
const finalValue = useMemo(() => {
const value = field.getValues();
if (!blockedNameList) {
return field.getValues();
Expand Down Expand Up @@ -157,14 +157,14 @@ function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGen
"data-test-subj": "formNameAdvancedSettings",
...props.advancedSettingsProps?.rowProps,
}}
value={finalValue}
value={finalValue as T}
onChange={(val) => {
const totalValue = field.getValues();
const editorValue = omit(val || {}, blockedNameList || []);
const resetValue = {
...editorValue,
...pick(totalValue, blockedNameList || []),
};
} as T;
// update form field value to rerender
field.resetValues(resetValue);

Expand All @@ -184,6 +184,6 @@ function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGen
);
}

export default forwardRef(FormGenerator) as <T>(
export default forwardRef(FormGenerator) as <T extends object = any>(
props: IFormGeneratorProps<T> & { ref?: React.Ref<IFormGeneratorRef> }
) => ReturnType<typeof FormGenerator>;
Loading