mirror of
https://github.com/Kong/insomnia.git
synced 2026-09-17 08:59:33 -04:00
refactor: move shared tab types and context-menu enum into insomnia-tab-context to break tab cycles
This commit is contained in:
7 files changed
+44
-52
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { models } from 'insomnia-data';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import type { BaseTab } from '../../context/app/insomnia-tab-context';
|
||||
import { getRequestDeleteFallbackUrl, isRequestLikeDocType } from './request-delete-fallback';
|
||||
import type { BaseTab } from './tab';
|
||||
|
||||
const makeTab = (overrides: Partial<BaseTab> = {}): BaseTab => ({
|
||||
type: 'request',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { models } from 'insomnia-data';
|
||||
|
||||
import type { BaseTab } from './tab';
|
||||
import type { BaseTab } from '../../context/app/insomnia-tab-context';
|
||||
|
||||
// A doc type is considered "request-like" for tab-close fallback purposes if
|
||||
// it's one of the request flavors that can live directly under a workspace
|
||||
|
||||
@@ -20,27 +20,18 @@ import { useInsomniaTab } from '~/ui/hooks/use-insomnia-tab';
|
||||
|
||||
import { type ChangeBufferEvent, type ChangeType, database } from '../../../common/database';
|
||||
import { debounce } from '../../../common/misc';
|
||||
import { useInsomniaTabContext } from '../../context/app/insomnia-tab-context';
|
||||
import { TAB_CONTEXT_MENU_COMMAND, useInsomniaTabContext } from '../../context/app/insomnia-tab-context';
|
||||
import { type Size, useResizeObserver } from '../../hooks/use-resize-observer';
|
||||
import { Icon } from '../icon';
|
||||
import { useDocBodyKeyboardShortcuts } from '../keydown-binder';
|
||||
import { AddRequestToCollectionModal } from '../modals/add-request-to-collection-modal';
|
||||
import { formatMethodName, getRequestMethodShortHand } from '../tags/method-tag';
|
||||
import { getRequestDeleteFallbackUrl, isRequestLikeDocType } from './request-delete-fallback';
|
||||
import { type BaseTab, InsomniaTab } from './tab';
|
||||
import { InsomniaTab } from './tab';
|
||||
|
||||
const { isRequest } = models.request;
|
||||
const { isRequestGroup } = models.requestGroup;
|
||||
|
||||
export interface OrganizationTabs {
|
||||
tabList: BaseTab[];
|
||||
activeTabId?: string;
|
||||
}
|
||||
|
||||
export const enum TAB_CONTEXT_MENU_COMMAND {
|
||||
CLOSE_ALL = 'Close All',
|
||||
CLOSE_OTHERS = 'Close Other Tabs',
|
||||
}
|
||||
|
||||
export const OrganizationTabList = ({ showActiveStatus = true, currentPage = '' }) => {
|
||||
const [showAddRequestModal, setShowAddRequestModal] = useState(false);
|
||||
|
||||
@@ -8,38 +8,10 @@ import { scopeToBgColorMap, scopeToIconMap, scopeToTextColorMap } from '~/common
|
||||
import type { WorkspaceFileIssue } from '~/main/git-service';
|
||||
import { scrollElementIntoView } from '~/ui/utils';
|
||||
|
||||
import { useInsomniaTabContext } from '../../context/app/insomnia-tab-context';
|
||||
import { type BaseTab, TAB_CONTEXT_MENU_COMMAND, type TabType, useInsomniaTabContext } from '../../context/app/insomnia-tab-context';
|
||||
import { Icon } from '../icon';
|
||||
import { Tooltip } from '../tooltip';
|
||||
import { TAB_CONTEXT_MENU_COMMAND } from './tab-list';
|
||||
|
||||
export type TabType =
|
||||
| 'request'
|
||||
| 'folder'
|
||||
| 'environment'
|
||||
| 'mockServer'
|
||||
| 'mockRoute'
|
||||
| 'document'
|
||||
| 'collection'
|
||||
| 'runner'
|
||||
| 'test'
|
||||
| 'testSuite';
|
||||
export interface BaseTab {
|
||||
type: TabType;
|
||||
name: string;
|
||||
url: string;
|
||||
organizationId: string;
|
||||
projectId: string;
|
||||
workspaceId: string;
|
||||
projectName: string;
|
||||
workspaceName: string;
|
||||
id: string;
|
||||
// tag is used to display the request method in the tab
|
||||
// method is used to display the tag color
|
||||
tag?: string;
|
||||
method?: string;
|
||||
temporary?: boolean;
|
||||
}
|
||||
|
||||
const REQUEST_METHOD_STYLE_MAP: Record<string, string> = {
|
||||
GET: 'text-(--color-font-surprise) bg-[rgba(var(--color-surprise-rgb),0.5)]',
|
||||
|
||||
@@ -3,10 +3,46 @@ import React, { createContext, type FC, type PropsWithChildren, useCallback, use
|
||||
import { useNavigate, useParams } from 'react-router';
|
||||
import * as reactUse from 'react-use';
|
||||
|
||||
import type { BaseTab } from '~/ui/components/tabs/tab';
|
||||
import type { OrganizationTabs } from '~/ui/components/tabs/tab-list';
|
||||
import uiEventBus from '~/ui/event-bus';
|
||||
|
||||
export type TabType =
|
||||
| 'request'
|
||||
| 'folder'
|
||||
| 'environment'
|
||||
| 'mockServer'
|
||||
| 'mockRoute'
|
||||
| 'document'
|
||||
| 'collection'
|
||||
| 'runner'
|
||||
| 'test'
|
||||
| 'testSuite';
|
||||
export interface BaseTab {
|
||||
type: TabType;
|
||||
name: string;
|
||||
url: string;
|
||||
organizationId: string;
|
||||
projectId: string;
|
||||
workspaceId: string;
|
||||
projectName: string;
|
||||
workspaceName: string;
|
||||
id: string;
|
||||
// tag is used to display the request method in the tab
|
||||
// method is used to display the tag color
|
||||
tag?: string;
|
||||
method?: string;
|
||||
temporary?: boolean;
|
||||
}
|
||||
|
||||
export interface OrganizationTabs {
|
||||
tabList: BaseTab[];
|
||||
activeTabId?: string;
|
||||
}
|
||||
|
||||
export const enum TAB_CONTEXT_MENU_COMMAND {
|
||||
CLOSE_ALL = 'Close All',
|
||||
CLOSE_OTHERS = 'Close Other Tabs',
|
||||
}
|
||||
|
||||
interface UpdateInsomniaTabParams {
|
||||
organizationId: string;
|
||||
tabList: OrganizationTabs['tabList'];
|
||||
|
||||
@@ -8,8 +8,7 @@ import { formatMethodName, getRequestMethodShortHand } from '~/ui/components/tag
|
||||
import { showResourceNotFoundToast } from '~/ui/components/toast-notification';
|
||||
|
||||
import { useDocBodyKeyboardShortcuts } from '../components/keydown-binder';
|
||||
import type { BaseTab, TabType } from '../components/tabs/tab';
|
||||
import { useInsomniaTabContext } from '../context/app/insomnia-tab-context';
|
||||
import { type BaseTab, type TabType, useInsomniaTabContext } from '../context/app/insomnia-tab-context';
|
||||
import {
|
||||
buildResourceUrl,
|
||||
type InsomniaNavigationRouteInfo,
|
||||
|
||||
@@ -22,12 +22,6 @@
|
||||
"packages/insomnia/src/sync/git/providers/gitlab.ts -> packages/insomnia/src/sync/git/utils.ts -> packages/insomnia/src/sync/git/providers/index.ts",
|
||||
"packages/insomnia/src/ui/components/modals/export-requests-modal.tsx -> packages/insomnia/src/ui/components/settings/import-export.tsx",
|
||||
"packages/insomnia/src/ui/components/modals/input-vault-key-modal.tsx -> packages/insomnia/src/ui/components/settings/vault-key-panel.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/request-delete-fallback.ts -> packages/insomnia/src/ui/components/tabs/tab.tsx -> packages/insomnia/src/ui/components/tabs/tab-list.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/tab-list.tsx -> packages/insomnia/src/ui/components/tabs/tab.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/tab-list.tsx -> packages/insomnia/src/ui/context/app/insomnia-tab-context.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/tab-list.tsx -> packages/insomnia/src/ui/hooks/use-insomnia-tab.ts -> packages/insomnia/src/ui/components/tabs/tab.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/tab-list.tsx -> packages/insomnia/src/ui/hooks/use-insomnia-tab.ts -> packages/insomnia/src/ui/context/app/insomnia-tab-context.tsx",
|
||||
"packages/insomnia/src/ui/components/tabs/tab.tsx -> packages/insomnia/src/ui/context/app/insomnia-tab-context.tsx",
|
||||
"packages/insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx -> packages/insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx",
|
||||
"packages/insomnia/src/ui/components/viewers/response-multipart-viewer.tsx -> packages/insomnia/src/ui/components/viewers/response-viewer.tsx"
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user