From cf2dec5e9e7f2ef57fae51d4d192bd3ddc9601ee Mon Sep 17 00:00:00 2001 From: yaoweiprc <6896642+yaoweiprc@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:51:00 +0800 Subject: [PATCH] fix code review problems --- .../src/ui/components/dropdowns/project-dropdown.tsx | 4 ++-- .../ui/components/modals/mock-server-settings-modal.tsx | 4 ++-- packages/insomnia/src/ui/index.tsx | 3 --- packages/insomnia/src/ui/routes/organization.tsx | 9 +++------ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/insomnia/src/ui/components/dropdowns/project-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/project-dropdown.tsx index b9aa5e272f6..f469c31fe35 100644 --- a/packages/insomnia/src/ui/components/dropdowns/project-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/project-dropdown.tsx @@ -24,7 +24,7 @@ import { isRemoteProject, type Project, } from '../../../models/project'; -import { ORG_STORAGE_RULE, type OrgStorageRuleType } from '../../routes/organization'; +import { ORG_STORAGE_RULE } from '../../routes/organization'; import { Icon } from '../icon'; import { showAlert, showModal } from '../modals'; import { AskModal } from '../modals/ask-modal'; @@ -32,7 +32,7 @@ import { AskModal } from '../modals/ask-modal'; interface Props { project: Project & { hasUncommittedOrUnpushedChanges?: boolean }; organizationId: string; - storage: OrgStorageRuleType; + storage: ORG_STORAGE_RULE; } interface ProjectActionItem { diff --git a/packages/insomnia/src/ui/components/modals/mock-server-settings-modal.tsx b/packages/insomnia/src/ui/components/modals/mock-server-settings-modal.tsx index fae6ea78b5c..c01b99ea331 100644 --- a/packages/insomnia/src/ui/components/modals/mock-server-settings-modal.tsx +++ b/packages/insomnia/src/ui/components/modals/mock-server-settings-modal.tsx @@ -3,7 +3,7 @@ import { Button, Dialog, Heading, Input, Label, Link, Modal, ModalOverlay, Radio import { useFetcher, useParams, useRouteLoaderData } from 'react-router-dom'; import { invariant } from '../../../utils/invariant'; -import { fetchAndCacheOrganizationStorageRule, ORG_STORAGE_RULE, type OrganizationLoaderData, type OrgStorageRuleType } from '../../routes/organization'; +import { fetchAndCacheOrganizationStorageRule, ORG_STORAGE_RULE, type OrganizationLoaderData } from '../../routes/organization'; import type { ProjectIdLoaderData } from '../../routes/project'; import { Icon } from '../icon'; import { showModal } from '.'; @@ -12,7 +12,7 @@ import { AlertModal } from './alert-modal'; export function useAvailableMockServerType(isLocalProject: boolean) { const { organizationId, projectId } = useParams<{ organizationId: string; projectId: string }>(); const { currentPlan } = useRouteLoaderData('/organization') as OrganizationLoaderData; - const [orgStorageRule, setOrgStorageRule] = useState(ORG_STORAGE_RULE.CLOUD_PLUS_LOCAL); + const [orgStorageRule, setOrgStorageRule] = useState(ORG_STORAGE_RULE.CLOUD_PLUS_LOCAL); useEffect(() => { fetchAndCacheOrganizationStorageRule(organizationId as string).then(setOrgStorageRule); }, [organizationId]); diff --git a/packages/insomnia/src/ui/index.tsx b/packages/insomnia/src/ui/index.tsx index 0897625239f..b96b315313e 100644 --- a/packages/insomnia/src/ui/index.tsx +++ b/packages/insomnia/src/ui/index.tsx @@ -1146,9 +1146,6 @@ async function renderApp() { // Store the last location in local storage router.subscribe(({ location, navigation }) => { - if (location.pathname && navigation.location?.pathname) { - console.log('navigating', location.pathname, navigation.location?.pathname); - } const match = matchPath( { path: '/organization/:organizationId', diff --git a/packages/insomnia/src/ui/routes/organization.tsx b/packages/insomnia/src/ui/routes/organization.tsx index 2cac5d3fd87..342232d53fc 100644 --- a/packages/insomnia/src/ui/routes/organization.tsx +++ b/packages/insomnia/src/ui/routes/organization.tsx @@ -342,11 +342,8 @@ export enum ORG_STORAGE_RULE { LOCAL_ONLY = 'local_only', }; -// https://stackoverflow.com/a/59496175/5714454 -export type OrgStorageRuleType = `${ORG_STORAGE_RULE}`; - export interface StorageRule { - storage: OrgStorageRuleType; + storage: ORG_STORAGE_RULE; isOverridden: boolean; } @@ -355,7 +352,7 @@ export interface OrganizationFeatureLoaderData { billingPromise: Promise; } export interface OrganizationStorageLoaderData { - storagePromise: Promise; + storagePromise: Promise; } // Create an in-memory storage to store the storage rules @@ -377,7 +374,7 @@ export const syncOrganizationStorageRuleAction: ActionFunction = async ({ params export async function fetchAndCacheOrganizationStorageRule( organizationId: string | undefined, forceFetch: boolean = false, -): Promise { +): Promise { invariant(organizationId, 'Organization ID is required'); if (isScratchpadOrganizationId(organizationId)) {