Skip to content

Commit

Permalink
Fixing a few bugs and addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
  • Loading branch information
tandonks authored and SuZhou-Joe committed Aug 19, 2024
1 parent 5f3cacd commit b7606e0
Show file tree
Hide file tree
Showing 39 changed files with 227 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ HTMLCollection [
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
data-test-subj="test"
placeholder="test"
type="button"
Expand Down Expand Up @@ -63,7 +63,7 @@ HTMLCollection [
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-isSelected euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-isSelected euiFilterButton-hasNotification euiFilterButton--hasIcon"
data-test-subj="test"
placeholder="test"
type="button"
Expand Down Expand Up @@ -181,7 +181,7 @@ HTMLCollection [
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-isSelected euiFilterButton-hasActiveFilters euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-isSelected euiFilterButton-hasActiveFilters euiFilterButton-hasNotification euiFilterButton--hasIcon"
data-test-subj="test"
placeholder="test"
type="button"
Expand Down Expand Up @@ -299,7 +299,7 @@ HTMLCollection [
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-isSelected euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-isSelected euiFilterButton-hasNotification euiFilterButton--hasIcon"
data-test-subj="test"
placeholder="test"
type="button"
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Aliases/containers/AliasActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function AliasesActions(props: AliasesActionsProps) {
const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");

const size = useUpdatedUX ? "s" : "m";
const size = useUpdatedUX ? "s" : undefined;

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions public/pages/Aliases/containers/Aliases/Aliases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Aliases extends MDSEnabledComponent<AliasesProps, AliasesState> {
}

componentDidMount() {
const breadCrumbs = this.state.useUpdatedUX ? [BREADCRUMBS.ALIASES] : [BREADCRUMBS.INDEX_MANAGEMENT, BREADCRUMBS.ALIASES];
const breadCrumbs = this.state.useUpdatedUX ? [BREADCRUMBS.NEW_ALIASES] : [BREADCRUMBS.INDEX_MANAGEMENT, BREADCRUMBS.ALIASES];
this.context.chrome.setBreadcrumbs(breadCrumbs);
this.getAliases();
}
Expand Down Expand Up @@ -310,7 +310,7 @@ class Aliases extends MDSEnabledComponent<AliasesProps, AliasesState> {
<EuiFormRow
fullWidth
helpText={
<div style={{ width: "50%" }}>
<div style={{ width: "51%" }}>
An alias is a virtual index name that can point to one or more indexes. If your data is spread across multiple indexes, you
can create and query an alias instead of keeping track of which indexes to query.{" "}
<EuiLink target="_blank" external href={(this.context as CoreStart).docLinks.links.opensearch.indexAlias.base}>
Expand All @@ -325,7 +325,7 @@ class Aliases extends MDSEnabledComponent<AliasesProps, AliasesState> {
},
];

const Buttonsize = this.state.useUpdatedUX ? "s" : "m";
const Buttonsize = this.state.useUpdatedUX ? "s" : undefined;

const commonRender = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ChangeManagedIndicesProps {
onChangeManagedIndices: (selectedManagedIndices: { label: string; value?: ManagedIndexItem }[]) => void;
onChangeStateFilters: (stateFilter: { label: string }[]) => void;
managedIndicesError: string;
useUpdatedUX?: boolean;
}

interface ChangeManagedIndicesState {
Expand Down Expand Up @@ -71,8 +72,7 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices

render() {
const { managedIndices, managedIndicesIsLoading, stateFilterSearchValue } = this.state;
const { selectedManagedIndices, selectedStateFilters, managedIndicesError } = this.props;

const { selectedManagedIndices, selectedStateFilters, managedIndicesError, useUpdatedUX } = this.props;
const uniqueStates = selectedManagedIndices.reduce(
(accu: Set<any>, selectedManagedIndex: { label: string; value?: ManagedIndexItem }) => {
if (!selectedManagedIndex.value) return accu;
Expand Down Expand Up @@ -109,6 +109,7 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices
// @ts-ignore
onChange={this.props.onChangeManagedIndices}
onSearchChange={this.onManagedIndexSearchChange}
compressed={useUpdatedUX ? true : false}
/>
</EuiFormRow>

Expand All @@ -121,6 +122,7 @@ export default class ChangeManagedIndices extends Component<ChangeManagedIndices
// @ts-ignore
onChange={this.props.onChangeStateFilters}
onSearchChange={this.onStateFilterSearchChange}
compressed={useUpdatedUX ? true : false}
/>
</EuiFormRow>
</div>
Expand Down
5 changes: 4 additions & 1 deletion public/pages/ChangePolicy/components/NewPolicy/NewPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface NewPolicyProps {
onChangePolicy: (selectedPolicies: PolicyOption[]) => void;
onChangeStateRadio: (optionId: string) => void;
onStateSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
useUpdatedUX?: boolean;
}

interface NewPolicyState {
Expand Down Expand Up @@ -70,7 +71,7 @@ export default class NewPolicy extends React.Component<NewPolicyProps, NewPolicy
};

render() {
const { selectedPolicies, stateRadioIdSelected, stateSelected, selectedPoliciesError } = this.props;
const { selectedPolicies, stateRadioIdSelected, stateSelected, selectedPoliciesError, useUpdatedUX } = this.props;
const { policies, policiesIsLoading } = this.state;

const hasSelectedPolicy = !!selectedPolicies.length;
Expand Down Expand Up @@ -113,6 +114,7 @@ export default class NewPolicy extends React.Component<NewPolicyProps, NewPolicy
// @ts-ignore
onChange={this.props.onChangePolicy}
onSearchChange={this.onPolicySearchChange}
compressed={useUpdatedUX ? true : false}
/>
</EuiFormRow>

Expand All @@ -129,6 +131,7 @@ export default class NewPolicy extends React.Component<NewPolicyProps, NewPolicy
value={stateSelected}
onChange={this.props.onStateSelectChange}
aria-label="Start state for new policy"
compressed={useUpdatedUX ? true : false}
/>
</EuiFormRow>
</div>
Expand Down
20 changes: 10 additions & 10 deletions public/pages/ChangePolicy/containers/ChangePolicy/ChangePolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getUISettings } from "../../../../services/Services";
interface ChangePolicyProps extends RouteComponentProps, DataSourceMenuProperties {
managedIndexService: ManagedIndexService;
indexService: IndexService;
useUpdatedUX?: boolean;
}

interface ChangePolicyState {
Expand Down Expand Up @@ -54,9 +55,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
state: ChangePolicyState = ChangePolicy.emptyState;

async componentDidMount(): Promise<void> {
const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
const breadCrumbs = useUpdatedUX
const breadCrumbs = this.props.useUpdatedUX
? [BREADCRUMBS.MANAGED_INDICES, BREADCRUMBS.CHANGE_POLICY]
: [BREADCRUMBS.INDEX_MANAGEMENT, BREADCRUMBS.MANAGED_INDICES, BREADCRUMBS.CHANGE_POLICY];
this.context.chrome.setBreadcrumbs(breadCrumbs);
Expand Down Expand Up @@ -148,7 +147,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
};

render() {
const { indexService, managedIndexService } = this.props;
const { indexService, managedIndexService, useUpdatedUX } = this.props;
const {
selectedPolicies,
selectedManagedIndices,
Expand All @@ -160,9 +159,6 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
hasSubmitted,
} = this.state;

const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");

const Title = !useUpdatedUX
? () => {
return (
Expand All @@ -189,6 +185,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
onChangeManagedIndices={this.onChangeManagedIndices}
onChangeStateFilters={this.onChangeStateFilters}
managedIndicesError={hasSubmitted ? managedIndicesError : ""}
useUpdatedUX={useUpdatedUX}
/>

<EuiSpacer />
Expand All @@ -204,18 +201,19 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
onChangeStateRadio={this.onChangeStateRadio}
onStateSelectChange={this.onStateSelectChange}
selectedPoliciesError={hasSubmitted ? selectedPoliciesError : ""}
useUpdatedUX={useUpdatedUX}
/>

<EuiSpacer />

<EuiFlexGroup alignItems="center" justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty size={useUpdatedUX ? "s" : "l"} onClick={this.onCancel} data-test-subj="changePolicyCancelButton">
<EuiButtonEmpty size={useUpdatedUX ? "s" : undefined} onClick={this.onCancel} data-test-subj="changePolicyCancelButton">
Cancel
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton size={useUpdatedUX ? "s" : "m"} fill onClick={this.onSubmit} data-test-subj="changePolicyChangeButton">
<EuiButton size={useUpdatedUX ? "s" : undefined} fill onClick={this.onSubmit} data-test-subj="changePolicyChangeButton">
Change
</EuiButton>
</EuiFlexItem>
Expand All @@ -228,5 +226,7 @@ export class ChangePolicy extends Component<ChangePolicyProps, ChangePolicyState
export default function (props: Omit<ChangePolicyProps, keyof DataSourceMenuProperties>) {
const dataSourceMenuProperties = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <ChangePolicy {...props} {...dataSourceMenuProperties} />;
const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
return <ChangePolicy {...props} {...dataSourceMenuProperties} useUpdatedUX={useUpdatedUX} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
<div
style="padding: 0px 0px;"
>
<div
class="euiFlexItem"
>
<h1
class="euiTitle euiTitle--large"
>
Change Policy
</h1>
<div
class="euiSpacer euiSpacer--l"
/>
</div>
<div
class="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow"
style="padding-left: 0px; padding-right: 0px;"
Expand Down Expand Up @@ -424,7 +436,7 @@ exports[`<ChangePolicy /> spec renders the component 1`] = `
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<button
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--large"
class="euiButtonEmpty euiButtonEmpty--primary"
data-test-subj="changePolicyCancelButton"
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports[`<IndexControls /> spec renders the component 1`] = `
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ exports[`<ComposableTemplates /> spec renders the component 1`] = `
class="euiPopover__anchor"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--large euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
class="euiButtonEmpty euiButtonEmpty--text euiFilterButton euiFilterButton-hasNotification euiFilterButton--hasIcon"
type="button"
>
<span
Expand Down
16 changes: 8 additions & 8 deletions public/pages/CreateIndex/containers/CreateIndex/CreateIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getUISettings } from "../../../../services/Services";

interface CreateIndexPropsBase extends RouteComponentProps<{ index?: string; mode?: IndicesUpdateMode }> {
isEdit?: boolean;
useUpdatedUX?: boolean;
}

interface CreateIndexProps extends CreateIndexPropsBase, DataSourceMenuProperties {}
Expand All @@ -32,9 +33,7 @@ export class CreateIndex extends Component<CreateIndexProps> {

componentDidMount = async (): Promise<void> => {
const isEdit = this.isEdit;
const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
const breadCrumbs = useUpdatedUX
const breadCrumbs = this.props.useUpdatedUX
? [BREADCRUMBS.INDICES, isEdit ? BREADCRUMBS.EDIT_INDEX : BREADCRUMBS.CREATE_INDEX]
: [BREADCRUMBS.INDEX_MANAGEMENT, BREADCRUMBS.INDICES, isEdit ? BREADCRUMBS.EDIT_INDEX : BREADCRUMBS.CREATE_INDEX];
this.context.chrome.setBreadcrumbs(breadCrumbs);
Expand All @@ -47,17 +46,15 @@ export class CreateIndex extends Component<CreateIndexProps> {
render() {
const isEdit = this.isEdit;

const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");

return useUpdatedUX ? (
return this.props.useUpdatedUX ? (
<div style={{ padding: "0px 0px" }}>
<IndexForm
index={this.index}
mode={this.props.match.params.mode}
onCancel={this.onCancel}
onSubmitSuccess={() => this.props.history.push(ROUTES.INDICES)}
dataSourceId={this.props.dataSourceId}
useUpdatedUX={this.props.useUpdatedUX}
/>
</div>
) : (
Expand All @@ -72,6 +69,7 @@ export class CreateIndex extends Component<CreateIndexProps> {
onCancel={this.onCancel}
onSubmitSuccess={() => this.props.history.push(ROUTES.INDICES)}
dataSourceId={this.props.dataSourceId}
useUpdatedUX={this.props.useUpdatedUX}
/>
</div>
);
Expand All @@ -81,5 +79,7 @@ export class CreateIndex extends Component<CreateIndexProps> {
export default function (props: CreateIndexPropsBase) {
const dataSourceMenuProperties = useContext(DataSourceMenuContext);
useUpdateUrlWithDataSourceProperties();
return <CreateIndex {...props} {...dataSourceMenuProperties} />;
const uiSettings = getUISettings();
const useUpdatedUX = uiSettings.get("home:useNewHomePage");
return <CreateIndex {...props} {...dataSourceMenuProperties} useUpdatedUX={useUpdatedUX} />;
}
13 changes: 10 additions & 3 deletions public/pages/CreateIndex/containers/IndexForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface IndexFormProps
onCancel?: () => void;
onSubmitSuccess?: (indexName: string) => void;
hideButtons?: boolean;
useUpdatedUX?: boolean;
}

interface CreateIndexState {
Expand Down Expand Up @@ -423,7 +424,7 @@ export class IndexForm extends Component<IndexFormProps & { services: BrowserSer

render() {
const isEdit = this.isEdit;
const { hideButtons, readonly } = this.props;
const { hideButtons, readonly, useUpdatedUX } = this.props;
const { indexDetail, isSubmitting, oldIndexDetail, loading } = this.state;

if (loading) {
Expand Down Expand Up @@ -466,12 +467,18 @@ export class IndexForm extends Component<IndexFormProps & { services: BrowserSer
<EuiSpacer />
<EuiFlexGroup alignItems="center" justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty onClick={this.onCancel} data-test-subj="createIndexCancelButton">
<EuiButtonEmpty size={useUpdatedUX ? "s" : undefined} onClick={this.onCancel} data-test-subj="createIndexCancelButton">
Cancel
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton fill onClick={this.onSubmit} isLoading={isSubmitting} data-test-subj="createIndexCreateButton">
<EuiButton
fill
size={useUpdatedUX ? "s" : undefined}
onClick={this.onSubmit}
isLoading={isSubmitting}
data-test-subj="createIndexCreateButton"
>
{isEdit ? "Update" : "Create"}
</EuiButton>
</EuiFlexItem>
Expand Down
Loading

0 comments on commit b7606e0

Please sign in to comment.