Skip to content

Commit

Permalink
[Enterprise Search] Clean up rich configurable fields UI (#155282)
Browse files Browse the repository at this point in the history
- Add spacing between `EuiRow` and `EuiPanel` for
`ConnectorConfigurationField`.
- Hide fields that have any `ui_restrictions`
- Fix labelling for sensitive textareas
- Other misc cleanup tasks
  • Loading branch information
navarone-feekery authored Apr 24, 2023
1 parent 67927e1 commit 03464e7
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
user: {
Expand All @@ -44,6 +45,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
password: {
Expand All @@ -61,6 +63,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: true,
tooltip: '',
ui_restrictions: [],
value: '',
},
database: {
Expand All @@ -78,6 +81,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
collection: {
Expand All @@ -95,6 +99,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
direct_connection: {
Expand All @@ -112,6 +117,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: true,
},
},
Expand Down Expand Up @@ -145,6 +151,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
port: {
Expand All @@ -162,6 +169,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
user: {
Expand All @@ -179,6 +187,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: false,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
password: {
Expand All @@ -196,6 +205,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: false,
sensitive: true,
tooltip: '',
ui_restrictions: [],
value: '',
},
database: {
Expand All @@ -213,6 +223,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
tables: {
Expand All @@ -230,6 +241,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
ssl_enabled: {
Expand All @@ -247,6 +259,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: false,
},
ssl_ca: {
Expand All @@ -264,6 +277,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
required: true,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: '',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export enum DisplayType {
NUMERIC = 'numeric',
TOGGLE = 'toggle',
DROPDOWN = 'dropdown',
CHECKBOX = 'checkbox',
}

export interface ConnectorConfigProperties {
Expand All @@ -36,6 +35,7 @@ export interface ConnectorConfigProperties {
required: boolean;
sensitive: boolean;
tooltip: string;
ui_restrictions: string[];
value: string | number | boolean | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
required: false,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: 'barbar',
},
},
Expand Down Expand Up @@ -155,6 +156,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
required: false,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: 'barbar',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const connectorIndex: ConnectorViewIndex = {
required: false,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: 'barbar',
},
},
Expand Down Expand Up @@ -169,6 +170,7 @@ export const crawlerIndex: CrawlerViewIndex = {
required: false,
sensitive: false,
tooltip: '',
ui_restrictions: [],
value: 'barbar',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ export const ConnectorConfigurationField: React.FC<ConnectorConfigurationFieldPr
);

return sensitive ? (
<EuiAccordion id={key + '-accordion'} buttonContent={label}>
<EuiAccordion
id={key + '-accordion'}
buttonContent={
<EuiToolTip content={tooltip}>
<p>{label}</p>
</EuiToolTip>
}
>
{textarea}
</EuiAccordion>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiForm,
EuiFormRow,
EuiPanel,
EuiSpacer,
EuiToolTip,
} from '@elastic/eui';

Expand Down Expand Up @@ -48,6 +49,12 @@ export const ConnectorConfigurationForm = () => {
{}
);

const filteredConfigView = localConfigView.filter(
(configEntry) =>
configEntry.ui_restrictions.length <= 0 &&
dependenciesSatisfied(configEntry.depends_on, dependencyLookup)
);

return (
<EuiForm
onSubmit={(event) => {
Expand All @@ -56,17 +63,16 @@ export const ConnectorConfigurationForm = () => {
}}
component="form"
>
{localConfigView.map((configEntry) => {
{filteredConfigView.map((configEntry, index) => {
const {
default_value: defaultValue,
depends_on: dependencies,
key,
display,
label,
sensitive,
tooltip,
} = configEntry;
// toggle label goes next to the element, not in the row
const hasDependencies = dependencies.length > 0;
const helpText = defaultValue
? i18n.translate(
'xpack.enterpriseSearch.content.indices.configurationConnector.config.defaultValue',
Expand All @@ -76,26 +82,41 @@ export const ConnectorConfigurationForm = () => {
}
)
: '';
// toggle and sensitive textarea labels go next to the element, not in the row
const rowLabel =
display !== DisplayType.TOGGLE ? (
display === DisplayType.TOGGLE || (display === DisplayType.TEXTAREA && sensitive) ? (
<></>
) : (
<EuiToolTip content={tooltip}>
<p>{label}</p>
</EuiToolTip>
) : (
<></>
);

return hasDependencies ? (
dependenciesSatisfied(dependencies, dependencyLookup) ? (
<EuiPanel color="subdued" borderRadius="none">
<EuiFormRow label={rowLabel} key={key} helpText={helpText}>
<ConnectorConfigurationField configEntry={configEntry} />
</EuiFormRow>
</EuiPanel>
) : (
<></>
)
) : (
if (dependencies.length > 0) {
// dynamic spacing without CSS
const previousField = filteredConfigView[index - 1];
const nextField = filteredConfigView[index + 1];

const topSpacing =
!previousField || previousField.depends_on.length <= 0 ? <EuiSpacer size="m" /> : <></>;

const bottomSpacing =
!nextField || nextField.depends_on.length <= 0 ? <EuiSpacer size="m" /> : <></>;

return (
<>
{topSpacing}
<EuiPanel color="subdued" borderRadius="none">
<EuiFormRow label={rowLabel} key={key} helpText={helpText}>
<ConnectorConfigurationField configEntry={configEntry} />
</EuiFormRow>
</EuiPanel>
{bottomSpacing}
</>
);
}

return (
<EuiFormRow label={rowLabel} key={key} helpText={helpText}>
<ConnectorConfigurationField configEntry={configEntry} />
</EuiFormRow>
Expand Down
Loading

0 comments on commit 03464e7

Please sign in to comment.