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 }) => {
|
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',
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user