Skip to content
Merged
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
2 changes: 2 additions & 0 deletions dev/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const HubWrapper: React.FC = () => {
const [error, setError] = useState<string>();
const [token, setToken] = useState<string>();
const apiUrl = import.meta.env.VITE_API_URL ?? 'https://api.stackone.com';
const appUrl = import.meta.env.VITE_APP_URL ?? 'https://app.stackone.com';
const [theme, setTheme] = useState<'light' | 'dark'>('light');
const [accountId, setAccountId] = useState<string>();

Expand Down Expand Up @@ -81,6 +82,7 @@ const HubWrapper: React.FC = () => {
setMode(undefined);
}}
accountId={accountId}
appUrl={appUrl}
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion dev/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface ImportMetaEnv {
readonly VITE_ORIGIN_OWNER_NAME: string;
readonly VITE_ORIGIN_USERNAME: string;
readonly VITE_API_URL: string;
readonly VITE_DASHBOARD_URL: string;
readonly VITE_APP_URL: string;
}

export interface ImportMeta {
Expand Down
5 changes: 5 additions & 0 deletions src/StackOneHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface StackOneHubProps {
mode?: HubModes;
token?: string;
baseUrl?: string;
appUrl?: string;
height?: string;
theme?: 'light' | 'dark' | PartialMalachiteTheme;
accountId?: string;
Expand All @@ -35,6 +36,7 @@ export const StackOneHub: React.FC<StackOneHubProps> = ({
mode,
token,
baseUrl,
appUrl,
height = '500px',
theme = 'light',
accountId,
Expand All @@ -44,6 +46,8 @@ export const StackOneHub: React.FC<StackOneHubProps> = ({
}) => {
const defaultBaseUrl = 'https://api.stackone.com';
const apiUrl = baseUrl ?? defaultBaseUrl;
const defaultDashboardUrl = 'https://app.stackone.com';
const dashboardUrl = appUrl ?? defaultDashboardUrl;
useEffect(() => {
if (theme === 'dark') {
applyDarkTheme();
Expand Down Expand Up @@ -119,6 +123,7 @@ export const StackOneHub: React.FC<StackOneHubProps> = ({
<IntegrationPicker
token={token}
baseUrl={apiUrl}
dashboardUrl={dashboardUrl}
height={height}
onSuccess={onSuccess}
onClose={onClose}
Expand Down
5 changes: 4 additions & 1 deletion src/modules/integration-picker/IntegrationPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface IntegrationPickerProps {
baseUrl: string;
height: string;
accountId?: string;
dashboardUrl?: string;
onSuccess?: () => void;
onClose?: () => void;
onCancel?: () => void;
Expand All @@ -20,6 +21,7 @@ export const IntegrationPicker: React.FC<IntegrationPickerProps> = ({
height,
accountId,
onSuccess,
dashboardUrl,
}) => {
const {
// Data
Expand Down Expand Up @@ -48,6 +50,7 @@ export const IntegrationPicker: React.FC<IntegrationPickerProps> = ({
baseUrl,
accountId,
onSuccess,
dashboardUrl,
});

return (
Expand Down Expand Up @@ -75,7 +78,7 @@ export const IntegrationPicker: React.FC<IntegrationPickerProps> = ({
hasError={hasError}
connectionState={connectionState}
selectedIntegration={selectedIntegration}
connectorData={connectorData ?? null}
connectorData={connectorData?.config ?? null}
hubData={hubData ?? null}
fields={fields}
guide={guide}
Expand Down
31 changes: 13 additions & 18 deletions src/modules/integration-picker/components/IntegrationFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ export const IntegrationForm: React.FC<IntegrationFieldsProps> = ({
{error && <Typography.CodeText>{error.provider_response}</Typography.CodeText>}
<Spacer direction="vertical" size={20} fullWidth>
{fields.map((field) => {
const key =
typeof field.key === 'object'
? JSON.stringify(field.key)
: String(field.key);
Comment thread
adefreitas marked this conversation as resolved.
return (
<div key={field.key} style={{ width: '100%' }}>
<div key={key} style={{ width: '100%' }}>
{(field.type === 'text' ||
field.type === 'number' ||
field.type === 'password') && (
<Input
key={field.key}
name={field.key}
name={key}
required={field.required}
placeholder={field.placeholder}
defaultValue={field.value?.toString()}
onChange={(value: string) =>
handleFieldChange(field.key, value)
}
onChange={(value: string) => handleFieldChange(key, value)}
disabled={field.readOnly}
label={field.label}
tooltip={field.guide?.tooltip}
Expand All @@ -92,34 +93,28 @@ export const IntegrationForm: React.FC<IntegrationFieldsProps> = ({

{field.type === 'text_area' && (
<TextArea
key={field.key}
name={field.key}
name={key}
required={field.required}
defaultValue={formData[field.key] || ''}
defaultValue={formData[key] || ''}
placeholder={field.placeholder}
onChange={(value: string) =>
handleFieldChange(field.key, value)
}
onChange={(value: string) => handleFieldChange(key, value)}
disabled={field.readOnly}
label={field.label}
tooltip={field.guide?.tooltip}
/>
)}
{field.type === 'select' && (
<Dropdown
key={field.key}
defaultValue={formData[field.key] || ''}
defaultValue={formData[key] || ''}
disabled={field.readOnly}
items={
field.options?.map((option) => ({
id: option.value,
label: option.label,
})) ?? []
}
onItemSelected={(value) =>
handleFieldChange(field.key, value ?? '')
}
name={field.key}
onItemSelected={(value) => handleFieldChange(key, value ?? '')}
name={key}
label={field.label}
tooltip={field.guide?.tooltip}
description={field.guide?.description}
Expand Down
Loading