Skip to content
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

Fix integration flyout successes #1647

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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export const DataConnection = (props: { dataSource: string }) => {
const [dataSourceIntegrations, setDataSourceIntegrations] = useState(
[] as IntegrationInstanceResult[]
);
const [refreshIntegrationsFlag, setRefreshIntegrationsFlag] = useState(false);
const refreshInstances = () => setRefreshIntegrationsFlag((prev) => !prev);

useEffect(() => {
const searchDataSourcePattern = new RegExp(
`flint_${_.escapeRegExp(datasourceDetails.name)}_default_.*_mview`
Expand All @@ -105,7 +108,7 @@ export const DataConnection = (props: { dataSource: string }) => {
}
};
findIntegrations();
}, [http, datasourceDetails.name]);
}, [http, datasourceDetails.name, refreshIntegrationsFlag]);

const [showIntegrationsFlyout, setShowIntegrationsFlyout] = useState(false);
const onclickIntegrationsCard = () => {
Expand Down Expand Up @@ -237,6 +240,7 @@ export const DataConnection = (props: { dataSource: string }) => {
integrations={dataSourceIntegrations}
datasourceType={datasourceDetails.connector}
datasourceName={datasourceDetails.name}
refreshInstances={refreshInstances}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,27 @@
closeFlyout,
datasourceType,
datasourceName,
refreshInstances,
}: {
closeFlyout: () => void;
datasourceType: DatasourceType;
datasourceName: string;
refreshInstances: () => void;
}) => {
const [availableIntegrations, setAvailableIntegrations] = useState({
hits: [],
} as AvailableIntegrationsList);

const [isInstalling, setIsInstalling] = useState(false);

useEffect(() => {
if (!coreRefs.http) {
return;
}
coreRefs.http.get(`${INTEGRATIONS_BASE}/repository`).then((exists) => {
setAvailableIntegrations(exists.data);
});
});
}, []);

const s3FilteredIntegrations = {
hits: availableIntegrations.hits.filter((config) =>
Expand All @@ -152,7 +156,6 @@
};

const [installingIntegration, setInstallingIntegration] = useState<string | null>(null);
const [isInstalling, setIsInstalling] = useState(false);
const maybeCloseFlyout = () => {
if (!isInstalling) {
closeFlyout();
Expand Down Expand Up @@ -181,7 +184,13 @@
}
: undefined
}
setIsInstalling={setIsInstalling}
setIsInstalling={(installing: boolean, success?: boolean) => {
setIsInstalling(installing);

Check warning on line 188 in public/components/datasources/components/manage/integrations/installed_integrations_table.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/integrations/installed_integrations_table.tsx#L187-L188

Added lines #L187 - L188 were not covered by tests
if (success) {
closeFlyout();
refreshInstances();

Check warning on line 191 in public/components/datasources/components/manage/integrations/installed_integrations_table.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/integrations/installed_integrations_table.tsx#L190-L191

Added lines #L190 - L191 were not covered by tests
}
}}
/>
)}
</EuiFlyout>
Expand All @@ -192,10 +201,12 @@
integrations,
datasourceType,
datasourceName,
refreshInstances,
}: {
integrations: IntegrationInstanceResult[];
datasourceType: DatasourceType;
datasourceName: string;
refreshInstances: () => void;
}) => {
const [query, setQuery] = useState('');
const filteredIntegrations = integrations
Expand Down Expand Up @@ -245,6 +256,7 @@
closeFlyout={() => setShowAvailableFlyout(false)}
datasourceType={datasourceType}
datasourceName={datasourceName}
refreshInstances={refreshInstances}
/>
) : null}
</>
Expand Down
25 changes: 14 additions & 11 deletions public/components/integrations/components/setup_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,13 @@
integration,
setLoading,
setCalloutLikeToast,
skipRedirect,
setIsInstalling,
}: {
config: IntegrationSetupInputs;
integration: IntegrationConfig;
setLoading: (loading: boolean) => void;
setCalloutLikeToast: (title: string, color?: Color, text?: string) => void;
skipRedirect?: boolean;
setIsInstalling?: (isInstalling: boolean, success?: boolean) => void;
}) => {
setLoading(true);
let sessionId: string | null = null;
Expand All @@ -473,8 +473,11 @@
config.displayName,
config.connectionDataSource,
undefined,
skipRedirect
setIsInstalling ? true : false
);
if (setIsInstalling) {
setIsInstalling(false, res);

Check warning on line 479 in public/components/integrations/components/setup_integration.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/integrations/components/setup_integration.tsx#L479

Added line #L479 was not covered by tests
}
if (!res) {
setLoading(false);
}
Expand Down Expand Up @@ -513,8 +516,11 @@
config.displayName,
`flint_${config.connectionDataSource}_default_${config.connectionTableName}_mview`,
config.enabledWorkflows,
skipRedirect
setIsInstalling ? true : false
);
if (setIsInstalling) {
setIsInstalling(false, res);

Check warning on line 522 in public/components/integrations/components/setup_integration.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/integrations/components/setup_integration.tsx#L522

Added line #L522 was not covered by tests
}
if (!res) {
setLoading(false);
}
Expand Down Expand Up @@ -546,16 +552,14 @@
setSetupCallout,
unsetIntegration,
setIsInstalling,
skipRedirect,
}: {
config: IntegrationSetupInputs;
integration: IntegrationConfig;
loading: boolean;
setLoading: (loading: boolean) => void;
setSetupCallout: (setupCallout: SetupCallout) => void;
unsetIntegration?: () => void;
setIsInstalling?: (isInstalling: boolean) => void;
skipRedirect?: boolean;
setIsInstalling?: (isInstalling: boolean, success?: boolean) => void;
}) {
// Drop-in replacement for setToast
const setCalloutLikeToast = (title: string, color?: Color, text?: string) =>
Expand Down Expand Up @@ -607,15 +611,15 @@
setIsInstalling(newLoading);
},
setCalloutLikeToast,
skipRedirect,
setIsInstalling,
});
} else {
await addIntegration({
integration,
config,
setLoading,
setCalloutLikeToast,
skipRedirect,
setIsInstalling,
});
}
}}
Expand Down Expand Up @@ -654,7 +658,7 @@
name: string;
type: string;
};
setIsInstalling?: (isInstalling: boolean) => void;
setIsInstalling?: (isInstalling: boolean, success?: boolean) => void;
}) {
const [integConfig, setConfig] = useState({
displayName: `${integration} Integration`,
Expand Down Expand Up @@ -746,7 +750,6 @@
setSetupCallout={setSetupCallout}
unsetIntegration={unsetIntegration}
setIsInstalling={setIsInstalling}
skipRedirect={true}
/>
</EuiFlyoutFooter>
</>
Expand Down
Loading