Repository navigation
feat(ENG-3987): move the connector profile picker into the hub form #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
959fe39
457bc2d
950eb18
083ec0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,28 @@ import { | |
| AuthenticationNotice, | ||
| ConnectorConfig, | ||
| ConnectorConfigField, | ||
| ConnectorProfile, | ||
| HubData, | ||
| Integration, | ||
| } from '../types'; | ||
| import { describeLoadError } from '../utils/requestErrors'; | ||
| import { ProfilePicker } from './ProfilePicker'; | ||
| import { ErrorView } from './views/ErrorView'; | ||
| import { IntegrationFormView } from './views/IntegrationFormView'; | ||
| import { IntegrationListView } from './views/IntegrationListView'; | ||
| import { LoadingView } from './views/LoadingView'; | ||
| import { SuccessView } from './views/SuccessView'; | ||
|
|
||
| // The picker sits outside the keyed form so a profile switch does not remount it and drop its focus. | ||
| const FORM_LAYOUT_STYLE: React.CSSProperties = { | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| height: '100%', | ||
| }; | ||
|
|
||
| // A tall form scrolls inside its own region, above the footer, only while this can shrink below its content. | ||
| const FORM_REGION_STYLE: React.CSSProperties = { flex: 1, minHeight: 0 }; | ||
|
|
||
| interface IntegrationPickerContentProps { | ||
| // State flags | ||
| isLoading: boolean; | ||
|
|
@@ -31,6 +43,7 @@ interface IntegrationPickerContentProps { | |
| connectorData: ConnectorConfig | null; | ||
| hubData: HubData | null; | ||
| fields: ConnectorConfigField[]; | ||
| profiles?: ConnectorProfile[]; | ||
| notices?: AuthenticationNotice[]; | ||
| selectedCategory: string | null; | ||
| search: string; | ||
|
|
@@ -44,6 +57,7 @@ interface IntegrationPickerContentProps { | |
| onChange: (data: Record<string, string>) => void; | ||
| onValidationChange?: (isValid: boolean) => void; | ||
| onCancelOAuth?: () => void; | ||
| onProfileChange: (integrationId: string) => void; | ||
| editingSecrets?: Set<string>; | ||
| setEditingSecrets?: (updater: (prev: Set<string>) => Set<string>) => void; | ||
| } | ||
|
|
@@ -56,6 +70,7 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> = | |
| connectorData, | ||
| hubData, | ||
| fields, | ||
| profiles, | ||
| notices, | ||
| selectedCategory, | ||
| search, | ||
|
|
@@ -65,6 +80,7 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> = | |
| onChange, | ||
| onValidationChange, | ||
| onCancelOAuth, | ||
| onProfileChange, | ||
| editingSecrets, | ||
| setEditingSecrets, | ||
| }) => { | ||
|
|
@@ -123,18 +139,27 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> = | |
| // Form view (when integration is selected and connector data is available) | ||
| if (connectorData) { | ||
| return ( | ||
| <IntegrationFormView | ||
| key={selectedIntegration?.integration_id} | ||
| fields={fields} | ||
| notices={notices} | ||
| error={connectionState.error} | ||
| onChange={onChange} | ||
| onValidationChange={onValidationChange} | ||
| integrationName={connectorData.name} | ||
| connectorKey={connectorData.key} | ||
| editingSecrets={editingSecrets} | ||
| setEditingSecrets={setEditingSecrets} | ||
| /> | ||
| <div style={FORM_LAYOUT_STYLE}> | ||
| <ProfilePicker | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout shift when profiles resolve after the form.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 950eb18 and 083ec0a. The form now waits for the first profiles answer ( Checked in a local harness: with profiles delayed 1.5s the hub shows the loading state, then the picker and fields together at about 1550ms, with no shift. With profiles stalled for 60s the form opens at 10s. |
||
| profiles={profiles} | ||
| selectedProfileId={selectedIntegration.integration_id} | ||
| onProfileChange={onProfileChange} | ||
| /> | ||
| <div style={FORM_REGION_STYLE}> | ||
| <IntegrationFormView | ||
| key={selectedIntegration.integration_id} | ||
| fields={fields} | ||
| notices={notices} | ||
| error={connectionState.error} | ||
| onChange={onChange} | ||
| onValidationChange={onValidationChange} | ||
| integrationName={connectorData.name} | ||
| connectorKey={connectorData.key} | ||
| editingSecrets={editingSecrets} | ||
| setEditingSecrets={setEditingSecrets} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { Dropdown } from '@stackone/malachite'; | ||
| import { useCallback, useMemo } from 'react'; | ||
| import { ConnectorProfile } from '../types'; | ||
| import { profileOptions } from '../utils/profileOptions'; | ||
|
|
||
| // Padded applies one value to top and bottom; the picker needs the form's large top gutter and no bottom. | ||
| const PICKER_STYLE: React.CSSProperties = { padding: '28px 14px 0' }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kept the inline padding, with a comment. |
||
|
|
||
| interface ProfilePickerProps { | ||
| profiles?: ConnectorProfile[]; | ||
| selectedProfileId?: string; | ||
| onProfileChange: (integrationId: string) => void; | ||
| } | ||
|
|
||
| export const ProfilePicker: React.FC<ProfilePickerProps> = ({ | ||
| profiles, | ||
| selectedProfileId, | ||
| onProfileChange, | ||
| }) => { | ||
| const items = useMemo(() => profileOptions(profiles), [profiles]); | ||
| const selectProfile = useCallback( | ||
| (id?: string) => id && onProfileChange(id), | ||
| [onProfileChange], | ||
| ); | ||
|
|
||
| if (!items.some((item) => item.id === selectedProfileId)) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div style={PICKER_STYLE}> | ||
| <Dropdown | ||
| name="connector-profile" | ||
| label="Connection profile" | ||
| requiredIndicator="none" | ||
| size="large" | ||
| fullWidth | ||
| subtitleLayout="stacked" | ||
| showSubtitleInTrigger | ||
| items={items} | ||
| value={selectedProfileId} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blank required field if the selected id is not in the list.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 950eb18: |
||
| onItemSelected={selectProfile} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse: these inline style objects rebuild what malachite's
Flexalready does (direction={FlexDirection.Vertical}withfullHeight), which is how the rest of the integration picker lays things out (IntegrationFields.tsx,cardTitle.tsx). Switching toFlexdrops both style constants.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this and reverted it. malachite
Flexcan setflex: 1(grow) andmin-width: 0(shrink) but nevermin-height, so the form region grows to its content instead of shrinking below it. With a tall form (I added 8 optional fields in the harness) the outer container scrolls and the last field ends up under the footer. With the inlineflex: 1; min-height: 0there is one scroller inside the form region and the last input sits above Connect (measured: last input bottom 527px, Connect top 583px). I added a comment on the region style saying why it stays.