Skip to content

Commit

Permalink
extract project-edit-modal, add storageType field to project model
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweiprc committed Dec 18, 2024
1 parent 30931e5 commit 237ff25
Show file tree
Hide file tree
Showing 3 changed files with 503 additions and 408 deletions.
24 changes: 18 additions & 6 deletions packages/insomnia/src/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,31 @@ export const isLocalProject = (project: Pick<Project, 'remoteId'>): project is L
export const isRemoteProject = (project: Pick<Project, 'remoteId'>): project is RemoteProject => !isLocalProject(project);
export const projectHasSettings = (project: Pick<Project, '_id'>) => !isScratchpadProject(project);

interface CommonProject {
name: string;
export enum PROJECT_STORAGE_TYPE {
LOCAL = 'local',
CLOUD = 'cloud',
GIT = 'git',
};

export interface RemoteProject extends BaseModel {
storageType: PROJECT_STORAGE_TYPE.CLOUD;
remoteId: string;
gitRepositoryId: null;
}

export interface RemoteProject extends BaseModel, CommonProject {
remoteId: string;
export interface GitProject extends BaseModel {
storageType: PROJECT_STORAGE_TYPE.GIT;
remoteId: null;
gitRepositoryId: string;
}

export interface LocalProject extends BaseModel, CommonProject {
export interface LocalProject extends BaseModel {
storageType: PROJECT_STORAGE_TYPE.LOCAL;
remoteId: null;
gitRepositoryId: null;
}

export type Project = LocalProject | RemoteProject;
export type Project = LocalProject | RemoteProject | GitProject;

export const isProject = (model: Pick<BaseModel, 'type'>): model is Project => (
model.type === type
Expand Down
Loading

0 comments on commit 237ff25

Please sign in to comment.