Skip to content

Commit 8557d88

Browse files
committed
display the workspace name on global environments
1 parent 8b9f09e commit 8557d88

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

packages/insomnia/src/ui/components/environment-picker.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const EnvironmentPicker = ({
4646
const activeBaseEnvironment = baseEnvironment;
4747
const activeSubEnvironment = subEnvironments.find(e => e._id === activeEnvironment._id);
4848

49-
const selectedEnvironments = [activeGlobalBaseEnvironment, activeGlobalSubEnvironment, activeBaseEnvironment, activeSubEnvironment].filter(isNotNullOrUndefined).map((environment, index) => ({ ...environment, id: environment._id, level: index + 1 }));
49+
const selectedEnvironments = [activeGlobalBaseEnvironment, activeGlobalSubEnvironment ? { ...activeGlobalSubEnvironment, workspaceName: activeGlobalBaseEnvironment?.workspaceName } : undefined, activeBaseEnvironment, activeSubEnvironment].filter(isNotNullOrUndefined).map((environment, index) => ({ ...environment, id: environment._id, level: index + 1 }));
5050

5151
const navigate = useNavigate();
5252

@@ -59,7 +59,7 @@ export const EnvironmentPicker = ({
5959
<span className='truncate'>{activeGlobalEnvironment?._id || activeEnvironment._id ? 'Manage' : 'Add'} Environments</span>
6060
</Button>
6161
<Popover className="min-w-max max-h-[90vh] flex flex-col !z-10" placement='bottom start' offset={8}>
62-
<Dialog className="border h-full w-full grid grid-flow-col auto-cols-[min(250px,calc(45vw))] overflow-hidden divide-x divide-solid divide-[--hl-md] select-none text-sm border-solid border-[--hl-sm] bg-[--color-bg] shadow-lg rounded-md focus:outline-none">
62+
<Dialog className="border h-full w-full grid grid-flow-col [grid-auto-columns:min(260px,calc(40vw))_min(340px,calc(50vw))] overflow-hidden divide-x divide-solid divide-[--hl-md] select-none text-sm border-solid border-[--hl-sm] bg-[--color-bg] shadow-lg rounded-md focus:outline-none">
6363
<div className='relative w-full h-full flex flex-col overflow-hidden flex-1'>
6464
<div className='relative w-full h-full flex flex-col overflow-hidden flex-1'>
6565
<Heading className='text-sm flex-shrink-0 h-[--line-height-sm] font-bold text-[--hl] px-3 py-1 flex items-center gap-2 justify-between'>
@@ -165,16 +165,16 @@ export const EnvironmentPicker = ({
165165

166166
globalEnvironmentListBox.current?.focus();
167167
}}
168-
defaultInputValue={selectedGlobalBaseEnvironment?.workspaceName || selectedGlobalBaseEnvironment?.name || ''}
168+
defaultInputValue={selectedGlobalBaseEnvironment?.workspaceName || selectedGlobalBaseEnvironment?.name || 'No Global Environment'}
169169
selectedKey={selectedGlobalBaseEnvironmentId}
170-
defaultItems={[...globalBaseEnvironments.map(baseEnv => {
170+
defaultItems={[{ id: '', icon: 'cancel', name: 'No Global Environment', textValue: 'No Global Environment' }, ...globalBaseEnvironments.map(baseEnv => {
171171
return {
172172
id: baseEnv._id,
173173
icon: 'code',
174174
name: baseEnv.workspaceName || baseEnv.name,
175175
textValue: baseEnv.workspaceName || baseEnv.name,
176176
};
177-
}), { id: '', icon: 'cancel', name: 'No Global Environment', textValue: 'No Global Environment' }]}
177+
})]}
178178
>
179179
<div className='px-2 mx-2 my-2 flex items-center gap-2 group rounded-sm border border-solid border-[--hl-sm] bg-[--color-bg] text-[--color-font] focus:outline-none focus:ring-1 focus:ring-[--hl-md] transition-colors'>
180180
<Input aria-label='Global Environment' placeholder='Choose a global environment' className="py-1 placeholder:italic w-full pl-2 pr-7 " />
@@ -256,7 +256,7 @@ export const EnvironmentPicker = ({
256256
<span>Current selections ({selectedEnvironments.length})</span>
257257
</Heading>
258258
<ListBox
259-
aria-label='Select a Global Environment'
259+
aria-label='Current selection of environments'
260260
selectionMode='none'
261261
disallowEmptySelection
262262
key={activeGlobalEnvironment?._id}
@@ -308,18 +308,19 @@ export const EnvironmentPicker = ({
308308
}
309309

310310
}}
311-
className="select-none empty:p-0 text-sm min-w-max p-2 flex flex-col overflow-y-auto focus:outline-none"
311+
className="select-none w-full empty:p-0 text-sm p-2 flex flex-col overflow-y-auto overflow-x-hidden focus:outline-none"
312312
>
313313
{item => (
314314
<ListBoxItem
315-
className={'flex gap-2 pr-1 aria-selected:font-bold items-center text-[--color-font] h-[--line-height-xs] w-full text-md whitespace-nowrap bg-transparent hover:bg-[--hl-sm] rounded focus:bg-[--hl-xs] focus:outline-none transition-colors'}
315+
className={'flex gap-2 pr-1 overflow-hidden aria-selected:font-bold items-center text-[--color-font] h-[--line-height-xs] w-full text-md whitespace-nowrap bg-transparent hover:bg-[--hl-sm] rounded focus:bg-[--hl-xs] focus:outline-none transition-colors'}
316316
style={{
317317
paddingLeft: `${item.level * 8}px`,
318318
}}
319319
>
320320
{({ isDisabled }) => (
321321
<Fragment>
322322
<span
323+
className='flex-shrink-0'
323324
style={{
324325
borderColor: item.color ?? 'var(--color-font)',
325326
}}
@@ -332,9 +333,12 @@ export const EnvironmentPicker = ({
332333
}}
333334
/>
334335
</span>
335-
<span className='flex-1 truncate'>
336+
<span title={item.name} className='flex-grow truncate'>
336337
{item.name}
337338
</span>
339+
{'workspaceName' in item && item.workspaceName && <span title={item.workspaceName} className='flex-shrink truncate text-xs text-[--hl]'>
340+
{item.workspaceName}
341+
</span>}
338342
{!isDisabled && <div className="flex flex-shrink-0 items-center justify-center aspect-square h-6 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] outline-none hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-sm">
339343
<Icon icon="minus-circle" />
340344
</div>}

0 commit comments

Comments
 (0)