Skip to content

Commit

Permalink
fix code review problems
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweiprc committed Nov 13, 2024
1 parent ef0921d commit cf2dec5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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';

interface Props {
project: Project & { hasUncommittedOrUnpushedChanges?: boolean };
organizationId: string;
storage: OrgStorageRuleType;
storage: ORG_STORAGE_RULE;
}

interface ProjectActionItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.';
Expand All @@ -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<OrgStorageRuleType>(ORG_STORAGE_RULE.CLOUD_PLUS_LOCAL);
const [orgStorageRule, setOrgStorageRule] = useState<ORG_STORAGE_RULE>(ORG_STORAGE_RULE.CLOUD_PLUS_LOCAL);
useEffect(() => {
fetchAndCacheOrganizationStorageRule(organizationId as string).then(setOrgStorageRule);
}, [organizationId]);
Expand Down
3 changes: 0 additions & 3 deletions packages/insomnia/src/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 3 additions & 6 deletions packages/insomnia/src/ui/routes/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -355,7 +352,7 @@ export interface OrganizationFeatureLoaderData {
billingPromise: Promise<Billing>;
}
export interface OrganizationStorageLoaderData {
storagePromise: Promise<OrgStorageRuleType>;
storagePromise: Promise<ORG_STORAGE_RULE>;
}

// Create an in-memory storage to store the storage rules
Expand All @@ -377,7 +374,7 @@ export const syncOrganizationStorageRuleAction: ActionFunction = async ({ params
export async function fetchAndCacheOrganizationStorageRule(
organizationId: string | undefined,
forceFetch: boolean = false,
): Promise<OrgStorageRuleType> {
): Promise<ORG_STORAGE_RULE> {
invariant(organizationId, 'Organization ID is required');

if (isScratchpadOrganizationId(organizationId)) {
Expand Down

0 comments on commit cf2dec5

Please sign in to comment.