mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Enterprise Search] Show advanced ui configs for managed connectors (#167770)
## Summary ### Release note Self managed Search connectors now show advanced configuration in UI. <img width="1072" alt="Screenshot 2023-10-02 at 13 07 57" src="ddaa5d25
-3159-4bc0-8b0b-83daa2b408c1"> <img width="1062" alt="Screenshot 2023-10-02 at 13 08 12" src="f3c70c20
-5a70-42e8-9e7c-de90b77b0c3c"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
934a19b678
commit
d2dbd938a3
2 changed files with 59 additions and 9 deletions
|
@ -602,6 +602,24 @@ describe('ConnectorConfigurationLogic', () => {
|
|||
validation_errors: [],
|
||||
value: 'fourthBar',
|
||||
},
|
||||
{
|
||||
default_value: '',
|
||||
depends_on: [],
|
||||
display: DisplayType.TEXTBOX,
|
||||
is_valid: true,
|
||||
key: 'restricted',
|
||||
label: 'Restricted',
|
||||
options: [],
|
||||
order: 3,
|
||||
required: false,
|
||||
sensitive: true,
|
||||
tooltip: '',
|
||||
type: FieldType.STRING,
|
||||
ui_restrictions: ['advanced'],
|
||||
validations: [],
|
||||
validation_errors: [],
|
||||
value: 'I am restricted',
|
||||
},
|
||||
{
|
||||
default_value: '',
|
||||
depends_on: [{ field: 'bar', value: 'foofoo' }],
|
||||
|
@ -811,6 +829,25 @@ describe('ConnectorConfigurationLogic', () => {
|
|||
validation_errors: [],
|
||||
value: 'fourthBar',
|
||||
},
|
||||
{
|
||||
default_value: '',
|
||||
depends_on: [],
|
||||
display: DisplayType.TEXTBOX,
|
||||
is_valid: true,
|
||||
key: 'restricted',
|
||||
label: 'Restricted',
|
||||
options: [],
|
||||
order: 3,
|
||||
required: false,
|
||||
sensitive: true,
|
||||
tooltip: '',
|
||||
type: FieldType.STRING,
|
||||
ui_restrictions: ['advanced'],
|
||||
validations: [],
|
||||
validation_errors: [],
|
||||
value: 'I am restricted',
|
||||
},
|
||||
|
||||
{
|
||||
default_value: '',
|
||||
depends_on: [{ field: 'bar', value: 'fafa' }],
|
||||
|
|
|
@ -90,7 +90,10 @@ export interface ConfigView {
|
|||
* or that have not had their dependencies met
|
||||
*
|
||||
*/
|
||||
function sortAndFilterConnectorConfiguration(config: ConnectorConfiguration): ConfigView {
|
||||
function sortAndFilterConnectorConfiguration(
|
||||
config: ConnectorConfiguration,
|
||||
isNative: boolean
|
||||
): ConfigView {
|
||||
// This casting is ugly but makes all of the iteration below work for TypeScript
|
||||
// extract_full_html is only defined for crawlers, who don't use this config screen
|
||||
// we explicitly filter it out as well
|
||||
|
@ -120,11 +123,12 @@ function sortAndFilterConnectorConfiguration(config: ConnectorConfiguration): Co
|
|||
entry && !isCategoryEntry(entry) && !entry.category ? { key, ...entry } : null
|
||||
)
|
||||
.filter(isNotNullish),
|
||||
config
|
||||
config,
|
||||
isNative
|
||||
);
|
||||
const categories = groupedConfigView
|
||||
.map((category) => {
|
||||
const configEntries = filterSortValidateEntries(category.configEntries, config);
|
||||
const configEntries = filterSortValidateEntries(category.configEntries, config, isNative);
|
||||
|
||||
return configEntries.length > 0 ? { ...category, configEntries } : null;
|
||||
})
|
||||
|
@ -135,12 +139,13 @@ function sortAndFilterConnectorConfiguration(config: ConnectorConfiguration): Co
|
|||
|
||||
function filterSortValidateEntries(
|
||||
configEntries: Array<ConnectorConfigProperties & { key: string }>,
|
||||
config: ConnectorConfiguration
|
||||
config: ConnectorConfiguration,
|
||||
isNative: boolean
|
||||
): ConfigEntryView[] {
|
||||
return configEntries
|
||||
.filter(
|
||||
(configEntry) =>
|
||||
(configEntry.ui_restrictions ?? []).length <= 0 &&
|
||||
((configEntry.ui_restrictions ?? []).length <= 0 || !isNative) &&
|
||||
dependenciesSatisfied(configEntry.depends_on, config)
|
||||
)
|
||||
.sort((a, b) => {
|
||||
|
@ -373,12 +378,20 @@ export const ConnectorConfigurationLogic = kea<
|
|||
}),
|
||||
selectors: ({ selectors }) => ({
|
||||
configView: [
|
||||
() => [selectors.configState],
|
||||
(configState: ConnectorConfiguration) => sortAndFilterConnectorConfiguration(configState),
|
||||
() => [selectors.configState, selectors.index],
|
||||
(configState: ConnectorConfiguration, index: FetchIndexApiResponse) =>
|
||||
sortAndFilterConnectorConfiguration(
|
||||
configState,
|
||||
isConnectorIndex(index) ? index.connector.is_native : false
|
||||
),
|
||||
],
|
||||
localConfigView: [
|
||||
() => [selectors.localConfigState],
|
||||
(configState) => sortAndFilterConnectorConfiguration(configState),
|
||||
() => [selectors.localConfigState, selectors.index],
|
||||
(configState: ConnectorConfiguration, index: FetchIndexApiResponse) =>
|
||||
sortAndFilterConnectorConfiguration(
|
||||
configState,
|
||||
isConnectorIndex(index) ? index.connector.is_native : false
|
||||
),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue