mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-19 01:50:51 -05:00
feat(connectors): skip Connector Content when there is nothing to configure (#15996)
This commit is contained in:
1 parent
b2cc914ac6
commit
cba9ddb9bd
2 files changed
+70
-42
No files matched your search
+42
-29
@@ -94,6 +94,7 @@ import {
|
||||
import { FederatedConnectorForm } from "@/components/admin/federated/FederatedConnectorForm";
|
||||
import AuthenticationAccountSection from "@/views/admin/connectors/AddConnectorPage/sections/AuthenticationAccountSection";
|
||||
import ConnectorContentSection from "@/views/admin/connectors/AddConnectorPage/sections/ConnectorContentSection";
|
||||
import { visibleConnectorFields } from "@/views/admin/connectors/AddConnectorPage/form/ConnectorConfigFields";
|
||||
import ConnectorSettingsSection from "@/views/admin/connectors/AddConnectorPage/sections/ConnectorSettingsSection";
|
||||
import ScheduleSection from "@/views/admin/connectors/AddConnectorPage/sections/ScheduleSection";
|
||||
import EditFileLocations from "@/views/admin/connectors/AddConnectorPage/form/EditFileLocations";
|
||||
@@ -960,36 +961,48 @@ export function AddConnectorForm({ connector, edit }: AddConnectorFormProps) {
|
||||
data-testid="connector-form"
|
||||
>
|
||||
<Section gap={6} alignItems="stretch" width="full">
|
||||
<ConnectorContentSection
|
||||
config={contentConfiguration}
|
||||
values={formikProps.values}
|
||||
connector={connector}
|
||||
currentCredential={formCredential}
|
||||
reportScope={
|
||||
formCredentialId === null
|
||||
? null
|
||||
: {
|
||||
credentialId: formCredentialId,
|
||||
connectorId:
|
||||
edit?.ccPair.connector.id ?? null,
|
||||
}
|
||||
}
|
||||
disabled={!formUnlocked}
|
||||
>
|
||||
{edit && editsFileList && (
|
||||
<EditFileLocations
|
||||
ccPairId={edit.ccPair.id}
|
||||
// Review waits for the upload: a plan
|
||||
// made earlier would miss its files.
|
||||
onUploadingChange={setUploading}
|
||||
/>
|
||||
)}
|
||||
</ConnectorContentSection>
|
||||
{/* A source with nothing to configure (Gmail) skips the
|
||||
section. */}
|
||||
{(visibleConnectorFields(
|
||||
contentConfiguration,
|
||||
formikProps.values,
|
||||
formCredential
|
||||
).length > 0 ||
|
||||
contentConfiguration.subtext !== undefined ||
|
||||
editsFileList) && (
|
||||
<>
|
||||
<ConnectorContentSection
|
||||
config={contentConfiguration}
|
||||
values={formikProps.values}
|
||||
connector={connector}
|
||||
currentCredential={formCredential}
|
||||
reportScope={
|
||||
formCredentialId === null
|
||||
? null
|
||||
: {
|
||||
credentialId: formCredentialId,
|
||||
connectorId:
|
||||
edit?.ccPair.connector.id ?? null,
|
||||
}
|
||||
}
|
||||
disabled={!formUnlocked}
|
||||
>
|
||||
{edit && editsFileList && (
|
||||
<EditFileLocations
|
||||
ccPairId={edit.ccPair.id}
|
||||
// Review waits for the upload: a plan
|
||||
// made earlier would miss its files.
|
||||
onUploadingChange={setUploading}
|
||||
/>
|
||||
)}
|
||||
</ConnectorContentSection>
|
||||
|
||||
<Divider
|
||||
paddingParallel={0}
|
||||
paddingPerpendicular={0}
|
||||
/>
|
||||
<Divider
|
||||
paddingParallel={0}
|
||||
paddingPerpendicular={0}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<ConnectorSettingsSection
|
||||
connector={connector}
|
||||
currentCredential={formCredential}
|
||||
|
||||
@@ -18,6 +18,30 @@ export interface ConnectorConfigFieldsProps {
|
||||
reportScope: StoredReportScope | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The config fields the form shows for these values. Advanced fields are all
|
||||
* optional, so they sit in the same flat list instead of behind a toggle; a
|
||||
* field's own visibleCondition still applies.
|
||||
*/
|
||||
export function visibleConnectorFields(
|
||||
config: ConnectionConfiguration,
|
||||
values: Record<string, unknown>,
|
||||
currentCredential: CredentialValues | null
|
||||
): ConnectorField[] {
|
||||
const showAdvanced: boolean =
|
||||
!config.advancedValuesVisibleCondition ||
|
||||
config.advancedValuesVisibleCondition(values, currentCredential);
|
||||
return [
|
||||
...config.values,
|
||||
...(showAdvanced ? config.advanced_values : []),
|
||||
].filter(
|
||||
(field) =>
|
||||
!field.hidden &&
|
||||
(!field.visibleCondition ||
|
||||
field.visibleCondition(values, currentCredential))
|
||||
);
|
||||
}
|
||||
|
||||
export default function ConnectorConfigFields({
|
||||
config,
|
||||
values,
|
||||
@@ -44,19 +68,10 @@ export default function ConnectorConfigFields({
|
||||
}
|
||||
}, [initialConnectorName, setFieldValue, values]);
|
||||
|
||||
// Advanced fields are all optional, so they sit in the same flat list
|
||||
// instead of behind a toggle. A field's own visibleCondition still applies.
|
||||
const showAdvanced: boolean =
|
||||
!config.advancedValuesVisibleCondition ||
|
||||
config.advancedValuesVisibleCondition(values, currentCredential);
|
||||
const visibleFields: ConnectorField[] = [
|
||||
...config.values,
|
||||
...(showAdvanced ? config.advanced_values : []),
|
||||
].filter(
|
||||
(field) =>
|
||||
!field.hidden &&
|
||||
(!field.visibleCondition ||
|
||||
field.visibleCondition(values, currentCredential))
|
||||
const visibleFields: ConnectorField[] = visibleConnectorFields(
|
||||
config,
|
||||
values,
|
||||
currentCredential
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user