mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 09:08:32 +02:00
Try fix folder variable pane layout
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type { Environment } from '@yaakapp-internal/models';
|
import type { Environment } from '@yaakapp-internal/models';
|
||||||
import { patchModel } from '@yaakapp-internal/models';
|
import { patchModel } from '@yaakapp-internal/models';
|
||||||
import type { GenericCompletionOption } from '@yaakapp-internal/plugins';
|
import type { GenericCompletionOption } from '@yaakapp-internal/plugins';
|
||||||
|
import classNames from 'classnames';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import { useEnvironmentsBreakdown } from '../hooks/useEnvironmentsBreakdown';
|
import { useEnvironmentsBreakdown } from '../hooks/useEnvironmentsBreakdown';
|
||||||
import { useIsEncryptionEnabled } from '../hooks/useIsEncryptionEnabled';
|
import { useIsEncryptionEnabled } from '../hooks/useIsEncryptionEnabled';
|
||||||
@@ -19,7 +20,6 @@ import { Heading } from './core/Heading';
|
|||||||
import type { PairWithId } from './core/PairEditor';
|
import type { PairWithId } from './core/PairEditor';
|
||||||
import { ensurePairId } from './core/PairEditor.util';
|
import { ensurePairId } from './core/PairEditor.util';
|
||||||
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
|
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
|
||||||
import { VStack } from './core/Stacks';
|
|
||||||
import { EnvironmentColorIndicator } from './EnvironmentColorIndicator';
|
import { EnvironmentColorIndicator } from './EnvironmentColorIndicator';
|
||||||
import { EnvironmentSharableTooltip } from './EnvironmentSharableTooltip';
|
import { EnvironmentSharableTooltip } from './EnvironmentSharableTooltip';
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ export function EnvironmentEditor({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VStack space={4} className={className}>
|
<div className={classNames(className, 'h-full grid grid-rows-[auto_auto_minmax(0,1fr)] gap-2')}>
|
||||||
<Heading className="w-full flex items-center gap-0.5">
|
<Heading className="w-full flex items-center gap-0.5">
|
||||||
<EnvironmentColorIndicator clickToEdit environment={environment ?? null} />
|
<EnvironmentColorIndicator clickToEdit environment={environment ?? null} />
|
||||||
{!hideName && <div className="mr-2">{environment?.name}</div>}
|
{!hideName && <div className="mr-2">{environment?.name}</div>}
|
||||||
@@ -127,7 +127,7 @@ export function EnvironmentEditor({
|
|||||||
{environment.public ? 'Sharable' : 'Private'}
|
{environment.public ? 'Sharable' : 'Private'}
|
||||||
</BadgeButton>
|
</BadgeButton>
|
||||||
</Heading>
|
</Heading>
|
||||||
{environment.public && (!isEncryptionEnabled || !allVariableAreEncrypted) && (
|
{environment.public && (!isEncryptionEnabled || !allVariableAreEncrypted) ? (
|
||||||
<DismissibleBanner
|
<DismissibleBanner
|
||||||
id={`warn-unencrypted-${environment.id}`}
|
id={`warn-unencrypted-${environment.id}`}
|
||||||
color="notice"
|
color="notice"
|
||||||
@@ -142,24 +142,25 @@ export function EnvironmentEditor({
|
|||||||
>
|
>
|
||||||
This sharable environment contains plain-text secrets
|
This sharable environment contains plain-text secrets
|
||||||
</DismissibleBanner>
|
</DismissibleBanner>
|
||||||
|
) : (
|
||||||
|
<span />
|
||||||
)}
|
)}
|
||||||
<div className="h-full pr-2 pb-2 grid grid-rows-[minmax(0,1fr)] overflow-auto">
|
<PairOrBulkEditor
|
||||||
<PairOrBulkEditor
|
className="h-full"
|
||||||
allowMultilineValues
|
allowMultilineValues
|
||||||
preferenceName="environment"
|
preferenceName="environment"
|
||||||
nameAutocomplete={nameAutocomplete}
|
nameAutocomplete={nameAutocomplete}
|
||||||
namePlaceholder="VAR_NAME"
|
namePlaceholder="VAR_NAME"
|
||||||
nameValidate={validateName}
|
nameValidate={validateName}
|
||||||
valueType={valueType}
|
valueType={valueType}
|
||||||
valueAutocompleteVariables='environment'
|
valueAutocompleteVariables="environment"
|
||||||
valueAutocompleteFunctions
|
valueAutocompleteFunctions
|
||||||
forceUpdateKey={`${environment.id}::${forceUpdateKey}`}
|
forceUpdateKey={`${environment.id}::${forceUpdateKey}`}
|
||||||
pairs={environment.variables}
|
pairs={environment.variables}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
stateKey={`environment.${environment.id}`}
|
stateKey={`environment.${environment.id}`}
|
||||||
forcedEnvironmentId={environment.id}
|
forcedEnvironmentId={environment.id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</VStack>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { useDndMonitor, useDraggable, useDroppable } from '@dnd-kit/core';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { selectAtom } from 'jotai/utils';
|
import { selectAtom } from 'jotai/utils';
|
||||||
import type { MouseEvent, PointerEvent, ReactElement, RefAttributes } from 'react';
|
import type { MouseEvent, PointerEvent } from 'react';
|
||||||
import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { computeSideForDragMove } from '../../../lib/dnd';
|
import { computeSideForDragMove } from '../../../lib/dnd';
|
||||||
import { jotaiStore } from '../../../lib/jotai';
|
import { jotaiStore } from '../../../lib/jotai';
|
||||||
import type { ContextMenuProps, DropdownItem } from '../Dropdown';
|
import type { ContextMenuProps, DropdownItem } from '../Dropdown';
|
||||||
@@ -40,7 +40,7 @@ export interface TreeItemHandle {
|
|||||||
|
|
||||||
const HOVER_CLOSED_FOLDER_DELAY = 800;
|
const HOVER_CLOSED_FOLDER_DELAY = 800;
|
||||||
|
|
||||||
function TreeItemInner<T extends { id: string }>({
|
function TreeItem_<T extends { id: string }>({
|
||||||
treeId,
|
treeId,
|
||||||
node,
|
node,
|
||||||
ItemInner,
|
ItemInner,
|
||||||
@@ -325,11 +325,6 @@ function TreeItemInner<T extends { id: string }>({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1) Preserve generics through forwardRef:
|
|
||||||
const TreeItem_ = forwardRef(TreeItemInner) as <T extends { id: string }>(
|
|
||||||
props: TreeItemProps<T> & RefAttributes<TreeItemHandle>,
|
|
||||||
) => ReactElement | null;
|
|
||||||
|
|
||||||
export const TreeItem = memo(
|
export const TreeItem = memo(
|
||||||
TreeItem_,
|
TreeItem_,
|
||||||
({ node: prevNode, ...prevProps }, { node: nextNode, ...nextProps }) => {
|
({ node: prevNode, ...prevProps }, { node: nextNode, ...nextProps }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user