Skip to content

Commit

Permalink
Adds optional tag, removes log
Browse files Browse the repository at this point in the history
Signed-off-by: Clay Downs <downsrob@amazon.com>
  • Loading branch information
downsrob committed Apr 15, 2022
1 parent 835ba93 commit 3f13faa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface EuiFormCustomLabelProps {
textStyle?: object;
headerStyle?: object;
isInvalid?: boolean;
isOptional?: boolean;
}

// New pattern for label and help text both being above the form row instead of label above and help below.
Expand All @@ -23,10 +24,18 @@ const EuiFormCustomLabel = ({
textStyle = { marginBottom: "5px" },
headerStyle = { marginBottom: "2px" },
isInvalid = false,
isOptional = false,
}: EuiFormCustomLabelProps) => (
<EuiText style={textStyle}>
<h5 style={headerStyle} className={`euiFormLabel ${isInvalid ? "euiFormLabel-isInvalid" : ""}`}>
{title}
{isOptional ? (
<React.Fragment>
<span className="euiTextColor euiTextColor--subdued">
<em>- optional</em>
</span>
</React.Fragment>
) : null}
</h5>
<p>
{" "}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { ChangeEvent } from "react";
import { EuiFormRow, EuiCodeEditor, EuiFieldNumber, EuiFieldText, EuiSpacer, EuiRadioGroup, EuiCallOut } from "@elastic/eui";
import { EuiFormRow, EuiCodeEditor, EuiFieldText, EuiSpacer, EuiRadioGroup, EuiCallOut } from "@elastic/eui";
import { ShrinkAction, UIAction } from "../../../../../models/interfaces";
import { makeId } from "../../../../utils/helpers";
import { ActionType } from "../../utils/constants";
Expand Down Expand Up @@ -177,6 +177,7 @@ export default class ShrinkUIAction implements UIAction<ShrinkAction> {
helpText={`The mustache template to use to form the name of the output shrunken index.
If not provided, a default suffix of "_shrunken" will be appended.`}
isInvalid={!this.isValidIndexNameTemplateJson()}
isOptional={true}
/>
<EuiFormRow fullWidth isInvalid={!this.isValidIndexNameTemplateJson()} error={null} style={{ maxWidth: "100%" }}>
<DarkModeConsumer>
Expand Down Expand Up @@ -230,6 +231,7 @@ export default class ShrinkUIAction implements UIAction<ShrinkAction> {
title="Aliases"
helpText={`The aliases to be applied to the output shrunken index.`}
isInvalid={!this.isValidAliasesJson()}
isOptional={true}
/>
<EuiFormRow fullWidth isInvalid={!this.isValidAliasesJson()} error={null} style={{ maxWidth: "100%" }}>
<DarkModeConsumer>
Expand Down Expand Up @@ -263,16 +265,13 @@ export default class ShrinkUIAction implements UIAction<ShrinkAction> {
const shrink = { ...this.action };
if (shrink.aliases_json != null) {
shrink.shrink.aliases = JSON.parse(shrink.aliases_json as string);
console.log(shrink.aliases_json as string);
console.log((shrink.shrink.aliases as Object[])[0]);
}
if (shrink.target_index_name_template_json != null) {
shrink.shrink.target_index_name_template = JSON.parse(shrink.target_index_name_template_json as string);
}
delete shrink.aliases_json;
delete shrink.force_unsafe_input;
delete shrink.target_index_name_template_json;
console.log(shrink);
return shrink;
};
}

0 comments on commit 3f13faa

Please sign in to comment.