Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/modules/integration-picker/IntegrationPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ export const IntegrationPicker: React.FC<IntegrationPickerProps> = ({
hasOnlyOneIntegration
}
connectorData={connectorData?.config ?? null}
profiles={profiles}
selectedProfileId={selectedIntegration?.integration_id}
onProfileChange={selectProfile}
/>
)
}
Expand All @@ -173,13 +170,15 @@ export const IntegrationPicker: React.FC<IntegrationPickerProps> = ({
connectorData={connectorData?.config ?? null}
hubData={hubData ?? null}
fields={fields}
profiles={profiles}
notices={notices}
loadError={loadError}
onRetryLoad={retryLoad}
onSelect={setSelectedIntegration}
onChange={setFormData}
onValidationChange={handleValidationChange}
onCancelOAuth={handleCancelOAuth}
onProfileChange={selectProfile}
selectedCategory={selectedCategory}
search={search}
editingSecrets={editingSecrets}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {

Copy link
Copy Markdown
Contributor

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 Flex already does (direction={FlexDirection.Vertical} with fullHeight), which is how the rest of the integration picker lays things out (IntegrationFields.tsx, cardTitle.tsx). Switching to Flex drops both style constants.

Copy link
Copy Markdown
Author

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 Flex can set flex: 1 (grow) and min-width: 0 (shrink) but never min-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 inline flex: 1; min-height: 0 there 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.

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;
Expand All @@ -31,6 +43,7 @@ interface IntegrationPickerContentProps {
connectorData: ConnectorConfig | null;
hubData: HubData | null;
fields: ConnectorConfigField[];
profiles?: ConnectorProfile[];
notices?: AuthenticationNotice[];
selectedCategory: string | null;
search: string;
Expand All @@ -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;
}
Expand All @@ -56,6 +70,7 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> =
connectorData,
hubData,
fields,
profiles,
notices,
selectedCategory,
search,
Expand All @@ -65,6 +80,7 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> =
onChange,
onValidationChange,
onCancelOAuth,
onProfileChange,
editingSecrets,
setEditingSecrets,
}) => {
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout shift when profiles resolve after the form. profiles comes from a separate query (connectorProfiles, with its own retry config) that can settle after connectorData. Until then ProfilePicker renders null, so the form draws first and then gets pushed down by the ~70px picker row once the list arrives. A user who has already clicked into the first field sees it jump mid-typing. In the header this pop-in never moved the fields. Consider reserving the row (or showing a loading/disabled dropdown) while the profiles query is pending for a provider.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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 (isLoadingProfiles && profilesFailureCount === 0 in useIntegrationPicker.ts), so the picker and the fields render in the same frame. It does not wait for retries, and 083ec0a gives the profiles request a 10s timeout (an AbortController timer in httpClient.ts) so a call that never answers fails and the form opens without the picker.

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>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Flex, FlexAlign, FlexDirection, FlexJustify } from '@stackone/malachite';
import { ConnectorConfig, ConnectorProfile, HubData } from '../types';
import { profileOptions } from '../utils/profileOptions';
import { ConnectorConfig, HubData } from '../types';
import CardTitle from './cardTitle';
import { HeaderCloseButton } from './headerCloseButton';
import { IntegrationListHeader } from './views/IntegrationListView';
Expand All @@ -18,9 +17,6 @@ interface IntegrationPickerTitleProps {
onCategoryChange: (category: string | null) => void;
onSearchChange: (search: string) => void;
hideBackButton?: boolean;
profiles?: ConnectorProfile[];
selectedProfileId?: string;
onProfileChange?: (integrationId: string) => void;
}

export const IntegrationPickerTitle: React.FC<IntegrationPickerTitleProps> = ({
Expand All @@ -36,9 +32,6 @@ export const IntegrationPickerTitle: React.FC<IntegrationPickerTitleProps> = ({
onCategoryChange,
onSearchChange,
hideBackButton,
profiles,
selectedProfileId,
onProfileChange,
}) => {
const loneClose = onClose ? (
<Flex
Expand All @@ -61,9 +54,6 @@ export const IntegrationPickerTitle: React.FC<IntegrationPickerTitleProps> = ({
onBack={accountData || hideBackButton ? undefined : onBack}
onClose={onClose}
guide={guide}
profileOptions={profileOptions(profiles)}
selectedProfileId={selectedProfileId}
onProfileChange={onProfileChange}
/>
);
}
Expand Down
46 changes: 46 additions & 0 deletions src/modules/integration-picker/components/ProfilePicker.tsx
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' };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse: 28px 14px are exactly malachite Padded's large and medium values, the ones the form below uses (<Padded vertical="large" horizontal="medium">). Hardcoding them means the picker drifts from the form's gutter if the tokens change. Prefer Padded (or a shared constant) so the picker and the fields stay aligned.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the inline padding, with a comment. Padded applies one value to top and bottom (padding: ${vertical} ${horizontal}), and the picker needs the form's 28px top gutter with no bottom; vertical="large" would add 28px under the picker on top of the form's own 28px, doubling the gap to the first field. If malachite gets per-side padding I'm happy to switch.


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}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank required field if the selected id is not in the list. value={selectedProfileId} is selectedIntegration.integration_id, but the items come from the profiles endpoint. If the two disagree (for example account edit mode where selectedIntegration falls back to the provider match in useIntegrationPicker, or an inactive profile filtered out of the list), the controlled Dropdown matches no item and shows an empty trigger on a field labelled required. In the header this was a small chip; now it is the first form field. Worth falling back to the default profile or hiding the picker when the selection is not among the options.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 950eb18: ProfilePicker returns null when the selected id is not among the options, so the form never shows an empty trigger. I chose hiding over falling back to the default profile because switching profile changes the connection method; picking one silently in edit mode would change what the user is editing.

onItemSelected={selectProfile}
/>
</div>
);
};
68 changes: 10 additions & 58 deletions src/modules/integration-picker/components/cardTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
Avatar,
Button,
Dropdown,
DropdownItem,
Flex,
FlexAlign,
FlexDirection,
Expand All @@ -14,47 +12,21 @@ import {
import { ConnectorConfig } from '../types';
import { HeaderCloseButton } from './headerCloseButton';

const TITLE_CONTAINER_CLASS = 'stackone-hub-card-title';
const CONNECTOR_NAME_CLASS = 'stackone-hub-card-title-name';
const NAME_HIDDEN_BELOW_PX = 420;

// The hub renders inside malachite's shadow root, which page-level stylesheets cannot reach.
const TITLE_STYLES = `
.${TITLE_CONTAINER_CLASS} { container-type: inline-size; }
.${CONNECTOR_NAME_CLASS} { display: contents; }
@container (max-width: ${NAME_HIDDEN_BELOW_PX}px) {
.${CONNECTOR_NAME_CLASS} { display: none; }
}
`;

interface CardTitleProps {
connectorData: ConnectorConfig;
onBack?: () => void;
onClose?: () => void;
guide?: { supportLink?: string | null; description?: string | null };
profileOptions?: DropdownItem[];
selectedProfileId?: string;
onProfileChange?: (integrationId: string) => void;
}

const CardTitle: React.FC<CardTitleProps> = ({
connectorData,
onBack,
onClose,
guide,
profileOptions,
selectedProfileId,
onProfileChange,
}) => {
const CardTitle: React.FC<CardTitleProps> = ({ connectorData, onBack, onClose, guide }) => {
return (
<Flex
direction={FlexDirection.Horizontal}
align={FlexAlign.Center}
gapSize={FlexGapSize.Small}
justify={FlexJustify.SpaceBetween}
className={TITLE_CONTAINER_CLASS}
>
<style>{TITLE_STYLES}</style>
<Flex
direction={FlexDirection.Horizontal}
align={FlexAlign.Center}
Expand All @@ -69,42 +41,22 @@ const CardTitle: React.FC<CardTitleProps> = ({
size={16}
fallback="placeholder"
/>
<div className={CONNECTOR_NAME_CLASS}>
<Typography.EllipsisText
fontWeight="semi-bold"
size="medium"
tooltip={connectorData.name}
tooltipPlacement="bottom"
tooltipWhenTruncated
>
{connectorData.name}
</Typography.EllipsisText>
</div>
<Typography.EllipsisText
fontWeight="semi-bold"
size="medium"
tooltip={connectorData.name}
tooltipPlacement="bottom"
tooltipWhenTruncated
>
{connectorData.name}
</Typography.EllipsisText>
</Flex>
<Flex
direction={FlexDirection.Horizontal}
align={FlexAlign.Center}
gapSize={FlexGapSize.Small}
justify={FlexJustify.Right}
shrink
>
{profileOptions && profileOptions.length > 0 && (
<>
<Typography.SecondaryText>Profile</Typography.SecondaryText>
<div style={{ minWidth: 96 }}>
<Dropdown
name="connector-profile"
aria-label="Profile"
size="small"
minWidth={400}
menuAlign="end"
items={profileOptions}
value={selectedProfileId}
onItemSelected={(id) => id && onProfileChange?.(id)}
/>
</div>
</>
)}
{guide?.supportLink ? (
<Button
variant="ghost"
Expand Down
13 changes: 11 additions & 2 deletions src/modules/integration-picker/hooks/useIntegrationPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ export const useIntegrationPicker = ({
});

// Keyed on provider so switching between its profiles reuses the list instead of refetching it.
const { data: profilesData } = useQuery({
const {
data: profilesData,
isLoading: isLoadingProfiles,
failureCount: profilesFailureCount,
} = useQuery({
queryKey: ['connectorProfiles', selectedIntegration?.provider],
queryFn: () =>
selectedIntegration
Expand Down Expand Up @@ -749,7 +753,12 @@ export const useIntegrationPicker = ({
}
}, [baseUrl, token, closeOAuthPopup]);

const isLoading = isLoadingHubData || isLoadingConnectorData || isLoadingAccountData;
// The form waits for the first profiles answer so the picker never pushes the fields down, but not for retries.
const isLoading =
isLoadingHubData ||
isLoadingConnectorData ||
isLoadingAccountData ||
(isLoadingProfiles && profilesFailureCount === 0);
const hasError = !!(errorHubData || errorConnectorData || errorAccountData);
const loadError = errorAccountData ?? errorHubData ?? errorConnectorData ?? null;

Expand Down
4 changes: 4 additions & 0 deletions src/modules/integration-picker/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const getConnectorConfig = async (baseUrl: string, token: string, integra
});
};

// The form waits for the first profiles answer, so a stalled request has to fail rather than hang.
const PROFILES_TIMEOUT_MS = 10_000;

export const getConnectorProfiles = async (
baseUrl: string,
token: string,
Expand All @@ -47,6 +50,7 @@ export const getConnectorProfiles = async (
'Content-Type': 'application/json',
'x-hub-session-token': token,
},
timeoutMs: PROFILES_TIMEOUT_MS,
});
};

Expand Down
Loading
Loading