mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Added new event to open the requested organization [INS-3300] (#6759)
* Added new event to open the requested organization * Check if the organization id exist * Remove line
This commit is contained in:
parent
83df663b45
commit
1238ae4318
@ -281,15 +281,24 @@ export interface FeatureList {
|
||||
|
||||
export const singleOrgLoader: LoaderFunction = async ({ params }) => {
|
||||
const { organizationId } = params as { organizationId: string };
|
||||
|
||||
const organization = organizationsData.organizations.find(o => o.id === organizationId);
|
||||
|
||||
if (!organization) {
|
||||
return redirect('/organization');
|
||||
}
|
||||
|
||||
const fallbackFeatures = {
|
||||
gitSync: { enabled: false, reason: 'Insomnia API unreachable' },
|
||||
orgBasicRbac: { enabled: false, reason: 'Insomnia API unreachable' },
|
||||
};
|
||||
|
||||
if (isScratchpadOrganizationId(organizationId)) {
|
||||
return {
|
||||
features: fallbackFeatures,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await window.main.insomniaFetch<{ features: FeatureList } | undefined>({
|
||||
method: 'GET',
|
||||
|
@ -2,7 +2,7 @@ import '../css/styles.css';
|
||||
|
||||
import { IpcRendererEvent } from 'electron';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { LoaderFunction, Outlet, useFetcher, useParams, useRouteLoaderData } from 'react-router-dom';
|
||||
import { LoaderFunction, Outlet, useFetcher, useNavigate, useParams, useRouteLoaderData } from 'react-router-dom';
|
||||
|
||||
import { isDevelopment } from '../../common/constants';
|
||||
import * as models from '../../models';
|
||||
@ -53,6 +53,7 @@ const Root = () => {
|
||||
|
||||
const [importUri, setImportUri] = useState('');
|
||||
const actionFetcher = useFetcher();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
return window.main.on(
|
||||
@ -201,13 +202,17 @@ const Root = () => {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'insomnia://app/open/organization':
|
||||
navigate(`/organization/${params.organizationId}`);
|
||||
break;
|
||||
|
||||
default: {
|
||||
console.log(`Unknown deep link: ${url}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}, [actionFetcher]);
|
||||
}, [actionFetcher, navigate]);
|
||||
|
||||
return (
|
||||
<AIProvider>
|
||||
|
Loading…
Reference in New Issue
Block a user