Skip to content

Commit

Permalink
[Enterprise Search] Implement new feature toggle structure (#149033)
Browse files Browse the repository at this point in the history
## Summary

This updates our feature toggle structure to match the new contract.
  • Loading branch information
sphilipse authored Jan 18, 2023
1 parent aa66f9a commit 193636e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
features: {
[FeatureName.FILTERING_ADVANCED_CONFIG]: true,
[FeatureName.FILTERING_RULES]: true,
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
},
name: i18n.translate('xpack.enterpriseSearch.nativeConnectors.mongodb.name', {
defaultMessage: 'MongoDB',
Expand Down Expand Up @@ -124,7 +128,12 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
value: '',
},
},
features: {},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
},
name: i18n.translate('xpack.enterpriseSearch.nativeConnectors.mysql.name', {
defaultMessage: 'MySQL',
}),
Expand Down
18 changes: 16 additions & 2 deletions x-pack/plugins/enterprise_search/common/types/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,28 @@ export enum TriggerMethod {
export enum FeatureName {
FILTERING_ADVANCED_CONFIG = 'filtering_advanced_config',
FILTERING_RULES = 'filtering_rules',
}
SYNC_RULES = 'sync_rules',
}

export type ConnectorFeatures = Partial<{
[FeatureName.FILTERING_ADVANCED_CONFIG]: boolean;
[FeatureName.FILTERING_RULES]: boolean;
[FeatureName.SYNC_RULES]: {
advanced?: {
enabled: boolean;
};
basic?: {
enabled: boolean;
};
};
}> | null;

export interface Connector {
api_key_id: string | null;
configuration: ConnectorConfiguration;
description: string | null;
error: string | null;
features: Partial<Record<FeatureName, boolean>> | null;
features: ConnectorFeatures;
filtering: FilteringConfig[];
id: string;
index_name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,18 @@ export const IndexViewLogic = kea<MakeLogicType<IndexViewValues, IndexViewAction
hasAdvancedFilteringFeature: [
() => [selectors.connector],
(connector?: Connector) =>
connector?.features ? connector.features[FeatureName.FILTERING_ADVANCED_CONFIG] : false,
connector?.features
? connector.features[FeatureName.SYNC_RULES]?.advanced?.enabled ??
connector.features[FeatureName.FILTERING_ADVANCED_CONFIG]
: false,
],
hasBasicFilteringFeature: [
() => [selectors.connector],
(connector?: Connector) =>
connector?.features ? connector.features[FeatureName.FILTERING_RULES] : false,
connector?.features
? connector.features[FeatureName.SYNC_RULES]?.basic?.enabled ??
connector.features[FeatureName.FILTERING_RULES]
: false,
],
hasFilteringFeature: [
() => [selectors.hasAdvancedFilteringFeature, selectors.hasBasicFilteringFeature],
Expand Down

0 comments on commit 193636e

Please sign in to comment.