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:
Pavlos Koutoglou 2023-11-15 16:44:07 +01:00 committed by GitHub
parent 83df663b45
commit 1238ae4318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -281,15 +281,24 @@ export interface FeatureList {
export const singleOrgLoader: LoaderFunction = async ({ params }) => { export const singleOrgLoader: LoaderFunction = async ({ params }) => {
const { organizationId } = params as { organizationId: string }; const { organizationId } = params as { organizationId: string };
const organization = organizationsData.organizations.find(o => o.id === organizationId);
if (!organization) {
return redirect('/organization');
}
const fallbackFeatures = { const fallbackFeatures = {
gitSync: { enabled: false, reason: 'Insomnia API unreachable' }, gitSync: { enabled: false, reason: 'Insomnia API unreachable' },
orgBasicRbac: { enabled: false, reason: 'Insomnia API unreachable' }, orgBasicRbac: { enabled: false, reason: 'Insomnia API unreachable' },
}; };
if (isScratchpadOrganizationId(organizationId)) { if (isScratchpadOrganizationId(organizationId)) {
return { return {
features: fallbackFeatures, features: fallbackFeatures,
}; };
} }
try { try {
const response = await window.main.insomniaFetch<{ features: FeatureList } | undefined>({ const response = await window.main.insomniaFetch<{ features: FeatureList } | undefined>({
method: 'GET', method: 'GET',

View File

@ -2,7 +2,7 @@ import '../css/styles.css';
import { IpcRendererEvent } from 'electron'; import { IpcRendererEvent } from 'electron';
import React, { useEffect, useState } from 'react'; 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 { isDevelopment } from '../../common/constants';
import * as models from '../../models'; import * as models from '../../models';
@ -53,6 +53,7 @@ const Root = () => {
const [importUri, setImportUri] = useState(''); const [importUri, setImportUri] = useState('');
const actionFetcher = useFetcher(); const actionFetcher = useFetcher();
const navigate = useNavigate();
useEffect(() => { useEffect(() => {
return window.main.on( return window.main.on(
@ -201,13 +202,17 @@ const Root = () => {
break; break;
} }
case 'insomnia://app/open/organization':
navigate(`/organization/${params.organizationId}`);
break;
default: { default: {
console.log(`Unknown deep link: ${url}`); console.log(`Unknown deep link: ${url}`);
} }
} }
}, },
); );
}, [actionFetcher]); }, [actionFetcher, navigate]);
return ( return (
<AIProvider> <AIProvider>