BugFix: Link based Apps installation - Opens 2 tabs instead of 1 (#5859)
Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/5865/head^2
parent
c37cddd0b7
commit
0930cf50b6
|
@ -42,7 +42,7 @@ const Component = ({
|
|||
|
||||
const mutation = useAddAppMutation(null, {
|
||||
onSuccess: (data) => {
|
||||
if (data.setupPending) return;
|
||||
if (data?.setupPending) return;
|
||||
showToast(t("app_successfully_installed"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function OmniInstallAppButton({ appId, className }: { appId: stri
|
|||
//TODO: viewer.appById might be replaced with viewer.apps so that a single query needs to be invalidated.
|
||||
utils.viewer.appById.invalidate({ appId });
|
||||
utils.viewer.apps.invalidate({ extendsFeature: "EventType" });
|
||||
if (data.setupPending) return;
|
||||
if (data?.setupPending) return;
|
||||
showToast(t("app_successfully_installed"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
|
|
|
@ -18,13 +18,14 @@ type CustomUseMutationOptions =
|
|||
| Omit<UseMutationOptions<unknown, unknown, unknown, unknown>, "mutationKey" | "mutationFn" | "onSuccess">
|
||||
| undefined;
|
||||
|
||||
type AddAppMutationData = { setupPending: boolean } | void;
|
||||
type UseAddAppMutationOptions = CustomUseMutationOptions & {
|
||||
onSuccess: (data: { setupPending: boolean }) => void;
|
||||
onSuccess: (data: AddAppMutationData) => void;
|
||||
};
|
||||
|
||||
function useAddAppMutation(_type: App["type"] | null, options?: UseAddAppMutationOptions) {
|
||||
const mutation = useMutation<
|
||||
{ setupPending: boolean },
|
||||
AddAppMutationData,
|
||||
Error,
|
||||
{ type?: App["type"]; variant?: string; slug?: string; isOmniInstall?: boolean } | ""
|
||||
>(async (variables) => {
|
||||
|
@ -62,6 +63,7 @@ function useAddAppMutation(_type: App["type"] | null, options?: UseAddAppMutatio
|
|||
|
||||
if (!isOmniInstall) {
|
||||
gotoUrl(json.url, json.newTab);
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip redirection only if it is an OmniInstall and redirect URL isn't of some other origin
|
||||
|
@ -71,6 +73,7 @@ function useAddAppMutation(_type: App["type"] | null, options?: UseAddAppMutatio
|
|||
if (externalUrl) {
|
||||
// TODO: For Omni installation to authenticate and come back to the page where installation was initiated, some changes need to be done in all apps' add callbacks
|
||||
gotoUrl(json.url, json.newTab);
|
||||
return;
|
||||
}
|
||||
|
||||
return { setupPending: externalUrl || json.url.endsWith("/setup") };
|
||||
|
|
|
@ -23,7 +23,7 @@ export default function AppCard({ app, credentials, searchText }: AppCardProps)
|
|||
onSuccess: (data) => {
|
||||
// Refresh SSR page content without actual reload
|
||||
router.replace(router.asPath);
|
||||
if (data.setupPending) return;
|
||||
if (data?.setupPending) return;
|
||||
showToast(t("app_successfully_installed"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
|
|
Loading…
Reference in New Issue