Skip to content

Commit 006f6fd

Browse files
gatzjamesihexxa
authored andcommitted
fix(sidebar): improve default size and reset default order (#7309)
* reset default order * set sidebar default size to be smaller * remove unessesary default size * add default size and decrease minSize
1 parent 1210dfd commit 006f6fd

7 files changed

Lines changed: 17 additions & 13 deletions

File tree

packages/insomnia/src/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export const MIN_INTERFACE_FONT_SIZE = 8;
157157
export const MAX_INTERFACE_FONT_SIZE = 24;
158158
export const MIN_EDITOR_FONT_SIZE = 8;
159159
export const MAX_EDITOR_FONT_SIZE = 24;
160+
export const DEFAULT_SIDEBAR_SIZE = 25;
160161

161162
// Activities
162163
export type GlobalActivity =

packages/insomnia/src/ui/routes/debug.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
useSearchParams,
3434
} from 'react-router-dom';
3535

36-
import { SORT_ORDERS, SortOrder, sortOrderName } from '../../common/constants';
36+
import { DEFAULT_SIDEBAR_SIZE, SORT_ORDERS, SortOrder, sortOrderName } from '../../common/constants';
3737
import { ChangeBufferEvent, database as db } from '../../common/database';
3838
import { generateId } from '../../common/misc';
3939
import { PlatformKeyCombinations } from '../../common/settings';
@@ -313,7 +313,7 @@ export const Debug: FC = () => {
313313
if (layout && layout[0] > 0) {
314314
layout[0] = 0;
315315
} else {
316-
layout[0] = 30;
316+
layout[0] = DEFAULT_SIDEBAR_SIZE;
317317
}
318318

319319
sidebarPanelRef.current?.setLayout(layout);
@@ -684,7 +684,7 @@ export const Debug: FC = () => {
684684

685685
return (
686686
<PanelGroup ref={sidebarPanelRef} autoSaveId="insomnia-sidebar" id="wrapper" className='new-sidebar w-full h-full text-[--color-font]' direction='horizontal'>
687-
<Panel id="sidebar" className='sidebar theme--sidebar' maxSize={40} minSize={20} collapsible>
687+
<Panel id="sidebar" className='sidebar theme--sidebar' defaultSize={DEFAULT_SIDEBAR_SIZE} maxSize={40} minSize={10} collapsible>
688688
<div className="flex flex-1 flex-col overflow-hidden divide-solid divide-y divide-[--hl-md]">
689689
<div className="flex flex-col items-start gap-2 justify-between p-[--padding-sm]">
690690
<Breadcrumbs className='flex list-none items-center m-0 p-0 gap-2 pb-[--padding-sm] border-b border-solid border-[--hl-sm] font-bold w-full'>

packages/insomnia/src/ui/routes/design.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import YAML from 'yaml';
4848
import YAMLSourceMap from 'yaml-source-map';
4949

5050
import { parseApiSpec } from '../../common/api-specs';
51-
import { ACTIVITY_SPEC } from '../../common/constants';
51+
import { ACTIVITY_SPEC, DEFAULT_SIDEBAR_SIZE } from '../../common/constants';
5252
import { debounce } from '../../common/misc';
5353
import { ApiSpec } from '../../models/api-spec';
5454
import { Environment } from '../../models/environment';
@@ -368,7 +368,7 @@ const Design: FC = () => {
368368
if (layout && layout[0] > 0) {
369369
layout[0] = 0;
370370
} else {
371-
layout[0] = 30;
371+
layout[0] = DEFAULT_SIDEBAR_SIZE;
372372
}
373373

374374
sidebarPanelRef.current?.setLayout(layout);
@@ -452,7 +452,7 @@ const Design: FC = () => {
452452

453453
return (
454454
<PanelGroup ref={sidebarPanelRef} autoSaveId="insomnia-sidebar" id="wrapper" className='new-sidebar w-full h-full text-[--color-font]' direction='horizontal'>
455-
<Panel id="sidebar" className='sidebar theme--sidebar' maxSize={40} minSize={20} collapsible>
455+
<Panel id="sidebar" className='sidebar theme--sidebar' defaultSize={DEFAULT_SIDEBAR_SIZE} maxSize={40} minSize={10} collapsible>
456456
<div className='flex h-full flex-col divide-y divide-solid divide-[--hl-md] overflow-hidden'>
457457
<div className="flex flex-col items-start gap-2 justify-between p-[--padding-sm]">
458458
<Breadcrumbs className='flex list-none items-center m-0 p-0 gap-2 pb-[--padding-sm] border-b border-solid border-[--hl-sm] font-bold w-full'>

packages/insomnia/src/ui/routes/mock-server.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Breadcrumb, Breadcrumbs, Button, GridList, GridListItem, Menu, MenuTrig
44
import { ImperativePanelGroupHandle, Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
55
import { LoaderFunction, NavLink, Route, Routes, useFetcher, useLoaderData, useNavigate, useParams } from 'react-router-dom';
66

7+
import { DEFAULT_SIDEBAR_SIZE } from '../../common/constants';
78
import * as models from '../../models';
89
import { MockRoute } from '../../models/mock-route';
910
import { invariant } from '../../utils/invariant';
@@ -132,7 +133,7 @@ const MockServerRoute = () => {
132133
if (layout && layout[0] > 0) {
133134
layout[0] = 0;
134135
} else {
135-
layout[0] = 30;
136+
layout[0] = DEFAULT_SIDEBAR_SIZE;
136137
}
137138

138139
sidebarPanelRef.current?.setLayout(layout);
@@ -172,7 +173,7 @@ const MockServerRoute = () => {
172173

173174
return (
174175
<PanelGroup ref={sidebarPanelRef} autoSaveId="insomnia-sidebar" id="wrapper" className='new-sidebar w-full h-full text-[--color-font]' direction='horizontal'>
175-
<Panel id="sidebar" className='sidebar theme--sidebar' maxSize={40} minSize={20} collapsible>
176+
<Panel id="sidebar" className='sidebar theme--sidebar' defaultSize={DEFAULT_SIDEBAR_SIZE} maxSize={40} minSize={10} collapsible>
176177
<div className="flex flex-1 flex-col overflow-hidden divide-solid divide-y divide-[--hl-md]">
177178
<div className="flex flex-col items-start gap-2 justify-between p-[--padding-sm]">
178179
<Breadcrumbs className='flex list-none items-center m-0 p-0 gap-2 font-bold w-full'>

packages/insomnia/src/ui/routes/project.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
DASHBOARD_SORT_ORDERS,
4646
DashboardSortOrder,
4747
dashboardSortOrderName,
48+
DEFAULT_SIDEBAR_SIZE,
4849
getAppWebsiteBaseURL,
4950
} from '../../common/constants';
5051
import { database } from '../../common/database';
@@ -859,7 +860,7 @@ const ProjectRoute: FC = () => {
859860
<ErrorBoundary>
860861
<Fragment>
861862
<PanelGroup autoSaveId="insomnia-sidebar" id="wrapper" className='new-sidebar w-full h-full text-[--color-font]' direction='horizontal'>
862-
<Panel id="sidebar" className='sidebar theme--sidebar' maxSize={40} minSize={20} collapsible>
863+
<Panel id="sidebar" className='sidebar theme--sidebar' defaultSize={DEFAULT_SIDEBAR_SIZE} maxSize={40} minSize={10} collapsible>
863864
<div className="flex flex-1 flex-col overflow-hidden divide-solid divide-y divide-[--hl-md]">
864865
<div className="p-[--padding-sm]">
865866
<Select

packages/insomnia/src/ui/routes/unit-test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
useRouteLoaderData,
3232
} from 'react-router-dom';
3333

34+
import { DEFAULT_SIDEBAR_SIZE } from '../../common/constants';
3435
import { database } from '../../common/database';
3536
import * as models from '../../models';
3637
import { Environment } from '../../models/environment';
@@ -138,7 +139,7 @@ const TestRoute: FC = () => {
138139
if (layout && layout[0] > 0) {
139140
layout[0] = 0;
140141
} else {
141-
layout[0] = 30;
142+
layout[0] = DEFAULT_SIDEBAR_SIZE;
142143
}
143144

144145
sidebarPanelRef.current?.setLayout(layout);
@@ -295,7 +296,7 @@ const TestRoute: FC = () => {
295296

296297
return (
297298
<PanelGroup ref={sidebarPanelRef} autoSaveId="insomnia-sidebar" id="wrapper" className='new-sidebar w-full h-full text-[--color-font]' direction='horizontal'>
298-
<Panel id="sidebar" className='sidebar theme--sidebar' maxSize={40} minSize={20} collapsible>
299+
<Panel id="sidebar" className='sidebar theme--sidebar' defaultSize={DEFAULT_SIDEBAR_SIZE} maxSize={40} minSize={10} collapsible>
299300
<ErrorBoundary showAlert>
300301
<div className="flex flex-1 flex-col overflow-hidden divide-solid divide-y divide-[--hl-md]">
301302
<div className="flex flex-col items-start gap-2 justify-between p-[--padding-sm]">

packages/insomnia/src/ui/routes/workspace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ export const workspaceLoader: LoaderFunction = async ({
123123
const sortOrder = searchParams.get('sortOrder') as SortOrder;
124124
const defaultSort = (a: Request | GrpcRequest | WebSocketRequest | RequestGroup, b: Request | GrpcRequest | WebSocketRequest | RequestGroup) => {
125125
if (a.metaSortKey === b.metaSortKey) {
126-
return a._id > b._id ? 1 : -1;
126+
return a._id > b._id ? -1 : 1;
127127
}
128-
return a.metaSortKey < b.metaSortKey ? 1 : -1;
128+
return a.metaSortKey < b.metaSortKey ? -1 : 1;
129129
};
130130
const sortFunction = sortMethodMap[sortOrder] || defaultSort;
131131

0 commit comments

Comments
 (0)