Lowercase slack channels automatically (#2254)

* Improve slack channel selection

* Lowercasing slack channels
This commit is contained in:
Chris Weaver
2024-08-27 20:07:26 -07:00
committed by GitHub
parent e4e67c61ef
commit 57491ceaae
2 changed files with 26 additions and 2 deletions

View File

@@ -167,6 +167,28 @@ export default function AddConnector({
} = formValues; } = formValues;
const { pruneFreq, indexingStart, refreshFreq } = advancedSettings; const { pruneFreq, indexingStart, refreshFreq } = advancedSettings;
// Apply transforms from connectors.ts configuration
const transformedConnectorSpecificConfig = Object.entries(
connector_specific_config
).reduce(
(acc, [key, value]) => {
const matchingConfigValue = configuration.values.find(
(configValue) => configValue.name === key
);
if (
matchingConfigValue &&
"transform" in matchingConfigValue &&
matchingConfigValue.transform
) {
acc[key] = matchingConfigValue.transform(value as string[]);
} else {
acc[key] = value;
}
return acc;
},
{} as Record<string, any>
);
const AdvancedConfig: AdvancedConfigFinal = { const AdvancedConfig: AdvancedConfigFinal = {
pruneFreq: advancedSettings.pruneFreq * 60 * 60 * 24, pruneFreq: advancedSettings.pruneFreq * 60 * 60 * 24,
indexingStart: convertStringToDateTime(indexingStart), indexingStart: convertStringToDateTime(indexingStart),
@@ -211,7 +233,7 @@ export default function AddConnector({
const { message, isSuccess, response } = await submitConnector<any>( const { message, isSuccess, response } = await submitConnector<any>(
{ {
connector_specific_config: connector_specific_config, connector_specific_config: transformedConnectorSpecificConfig,
input_type: connector == "web" ? "load_state" : "poll", // single case input_type: connector == "web" ? "load_state" : "poll", // single case
name: name, name: name,
source: connector, source: connector,
@@ -468,7 +490,6 @@ export default function AddConnector({
> >
{(formikProps) => { {(formikProps) => {
setFormValues(formikProps.values); setFormValues(formikProps.values);
console.log(formikProps.values);
handleFormStatusChange( handleFormStatusChange(
formikProps.isValid && isFormSubmittable(formikProps.values) formikProps.isValid && isFormSubmittable(formikProps.values)
); );

View File

@@ -33,6 +33,7 @@ export interface SelectOption extends Option {
export interface ListOption extends Option { export interface ListOption extends Option {
type: "list"; type: "list";
default?: string[]; default?: string[];
transform?: (values: string[]) => string[];
} }
export interface TextOption extends Option { export interface TextOption extends Option {
@@ -363,6 +364,8 @@ Hint: Use the singular form of the object name (e.g., 'Opportunity' instead of '
name: "channels", name: "channels",
description: `Specify 0 or more channels to index. For example, specifying the channel "support" will cause us to only index all content within the "#support" channel. If no channels are specified, all channels in your workspace will be indexed.`, description: `Specify 0 or more channels to index. For example, specifying the channel "support" will cause us to only index all content within the "#support" channel. If no channels are specified, all channels in your workspace will be indexed.`,
optional: true, optional: true,
// Slack channels can only be lowercase
transform: (values) => values.map((value) => value.toLowerCase()),
}, },
{ {
type: "checkbox", type: "checkbox",