mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:48:28 +02:00
Explicitly set the request layout (#257)
This commit is contained in:
@@ -7,6 +7,7 @@ import { useActiveRequest } from '../hooks/useActiveRequest';
|
|||||||
import { useGrpc } from '../hooks/useGrpc';
|
import { useGrpc } from '../hooks/useGrpc';
|
||||||
import { useGrpcProtoFiles } from '../hooks/useGrpcProtoFiles';
|
import { useGrpcProtoFiles } from '../hooks/useGrpcProtoFiles';
|
||||||
import { activeGrpcConnectionAtom, useGrpcEvents } from '../hooks/usePinnedGrpcConnection';
|
import { activeGrpcConnectionAtom, useGrpcEvents } from '../hooks/usePinnedGrpcConnection';
|
||||||
|
import { workspaceLayoutAtom } from '../lib/atoms';
|
||||||
import { Banner } from './core/Banner';
|
import { Banner } from './core/Banner';
|
||||||
import { HotKeyList } from './core/HotKeyList';
|
import { HotKeyList } from './core/HotKeyList';
|
||||||
import { SplitLayout } from './core/SplitLayout';
|
import { SplitLayout } from './core/SplitLayout';
|
||||||
@@ -20,6 +21,7 @@ interface Props {
|
|||||||
const emptyArray: string[] = [];
|
const emptyArray: string[] = [];
|
||||||
|
|
||||||
export function GrpcConnectionLayout({ style }: Props) {
|
export function GrpcConnectionLayout({ style }: Props) {
|
||||||
|
const workspaceLayout = useAtomValue(workspaceLayoutAtom);
|
||||||
const activeRequest = useActiveRequest('grpc_request');
|
const activeRequest = useActiveRequest('grpc_request');
|
||||||
const activeConnection = useAtomValue(activeGrpcConnectionAtom);
|
const activeConnection = useAtomValue(activeGrpcConnectionAtom);
|
||||||
const grpcEvents = useGrpcEvents(activeConnection?.id ?? null);
|
const grpcEvents = useGrpcEvents(activeConnection?.id ?? null);
|
||||||
@@ -80,6 +82,7 @@ export function GrpcConnectionLayout({ style }: Props) {
|
|||||||
name="grpc_layout"
|
name="grpc_layout"
|
||||||
className="p-3 gap-1.5"
|
className="p-3 gap-1.5"
|
||||||
style={style}
|
style={style}
|
||||||
|
layout={workspaceLayout}
|
||||||
firstSlot={({ style }) => (
|
firstSlot={({ style }) => (
|
||||||
<GrpcRequestPane
|
<GrpcRequestPane
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useAtomValue } from 'jotai';
|
|||||||
import type { CSSProperties } from 'react';
|
import type { CSSProperties } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useCurrentGraphQLSchema } from '../hooks/useIntrospectGraphQL';
|
import { useCurrentGraphQLSchema } from '../hooks/useIntrospectGraphQL';
|
||||||
|
import { workspaceLayoutAtom } from '../lib/atoms';
|
||||||
import type { SlotProps } from './core/SplitLayout';
|
import type { SlotProps } from './core/SplitLayout';
|
||||||
import { SplitLayout } from './core/SplitLayout';
|
import { SplitLayout } from './core/SplitLayout';
|
||||||
import { GraphQLDocsExplorer } from './graphql/GraphQLDocsExplorer';
|
import { GraphQLDocsExplorer } from './graphql/GraphQLDocsExplorer';
|
||||||
@@ -16,15 +17,18 @@ interface Props {
|
|||||||
style: CSSProperties;
|
style: CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function HttpRequestLayout({ activeRequest, style }: Props) {
|
export function HttpRequestLayout({ activeRequest, style }: Props) {
|
||||||
const showGraphQLDocExplorer = useAtomValue(showGraphQLDocExplorerAtom);
|
const showGraphQLDocExplorer = useAtomValue(showGraphQLDocExplorerAtom);
|
||||||
const graphQLSchema = useCurrentGraphQLSchema(activeRequest);
|
const graphQLSchema = useCurrentGraphQLSchema(activeRequest);
|
||||||
|
const workspaceLayout = useAtomValue(workspaceLayoutAtom);
|
||||||
|
|
||||||
const requestResponseSplit = ({ style }: Pick<SlotProps, 'style'>) => (
|
const requestResponseSplit = ({ style }: Pick<SlotProps, 'style'>) => (
|
||||||
<SplitLayout
|
<SplitLayout
|
||||||
name="http_layout"
|
name="http_layout"
|
||||||
className="p-3 gap-1.5"
|
className="p-3 gap-1.5"
|
||||||
style={style}
|
style={style}
|
||||||
|
layout={workspaceLayout}
|
||||||
firstSlot={({ orientation, style }) => (
|
firstSlot={({ orientation, style }) => (
|
||||||
<HttpRequestPane
|
<HttpRequestPane
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import type { LicenseCheckStatus } from '@yaakapp-internal/license';
|
|||||||
import { useLicense } from '@yaakapp-internal/license';
|
import { useLicense } from '@yaakapp-internal/license';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { openSettings } from '../commands/openSettings';
|
import { openSettings } from '../commands/openSettings';
|
||||||
import { appInfo } from '../lib/appInfo';
|
|
||||||
import { useLicenseConfirmation } from '../hooks/useLicenseConfirmation';
|
import { useLicenseConfirmation } from '../hooks/useLicenseConfirmation';
|
||||||
|
import { appInfo } from '../lib/appInfo';
|
||||||
import { BadgeButton } from './core/BadgeButton';
|
import { BadgeButton } from './core/BadgeButton';
|
||||||
import type { ButtonProps } from './core/Button';
|
import type { ButtonProps } from './core/Button';
|
||||||
|
|
||||||
@@ -26,11 +26,9 @@ export function LicenseBadge() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (check.error) {
|
if (check.error) {
|
||||||
return (
|
// Failed to check for license. Probably a network or server error so just don't
|
||||||
<BadgeButton color="danger" onClick={() => openSettings.mutate('license')}>
|
// show anything.
|
||||||
License Error
|
return null;
|
||||||
</BadgeButton>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hasn't loaded yet
|
// Hasn't loaded yet
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import type { WebsocketRequest } from '@yaakapp-internal/models';
|
import type { WebsocketRequest } from '@yaakapp-internal/models';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { useAtomValue } from 'jotai';
|
||||||
import type { CSSProperties } from 'react';
|
import type { CSSProperties } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { workspaceLayoutAtom } from '../lib/atoms';
|
||||||
import { SplitLayout } from './core/SplitLayout';
|
import { SplitLayout } from './core/SplitLayout';
|
||||||
import { WebsocketRequestPane } from './WebsocketRequestPane';
|
import { WebsocketRequestPane } from './WebsocketRequestPane';
|
||||||
import { WebsocketResponsePane } from './WebsocketResponsePane';
|
import { WebsocketResponsePane } from './WebsocketResponsePane';
|
||||||
@@ -12,10 +14,12 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function WebsocketRequestLayout({ activeRequest, style }: Props) {
|
export function WebsocketRequestLayout({ activeRequest, style }: Props) {
|
||||||
|
const workspaceLayout = useAtomValue(workspaceLayoutAtom);
|
||||||
return (
|
return (
|
||||||
<SplitLayout
|
<SplitLayout
|
||||||
name="websocket_layout"
|
name="websocket_layout"
|
||||||
className="p-3 gap-1.5"
|
className="p-3 gap-1.5"
|
||||||
|
layout={workspaceLayout}
|
||||||
style={style}
|
style={style}
|
||||||
firstSlot={({ orientation, style }) => (
|
firstSlot={({ orientation, style }) => (
|
||||||
<WebsocketRequestPane
|
<WebsocketRequestPane
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ function KeyRevealer({
|
|||||||
<VStack space={0.5}>
|
<VStack space={0.5}>
|
||||||
{!disableLabel && (
|
{!disableLabel && (
|
||||||
<span className="text-sm text-primary flex items-center gap-1">
|
<span className="text-sm text-primary flex items-center gap-1">
|
||||||
workspace encryption key{' '}
|
Workspace encryption key{' '}
|
||||||
<IconTooltip iconSize="sm" size="lg" content={helpAfterEncryption} />
|
<IconTooltip iconSize="sm" size="lg" content={helpAfterEncryption} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { type } from '@tauri-apps/plugin-os';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtom, useAtomValue } from 'jotai';
|
||||||
import React, { memo } from 'react';
|
import React, { memo } from 'react';
|
||||||
import { activeWorkspaceAtom, activeWorkspaceMetaAtom } from '../hooks/useActiveWorkspace';
|
import { activeWorkspaceAtom, activeWorkspaceMetaAtom } from '../hooks/useActiveWorkspace';
|
||||||
import { useToggleCommandPalette } from '../hooks/useToggleCommandPalette';
|
import { workspaceLayoutAtom } from '../lib/atoms';
|
||||||
import { setupOrConfigureEncryption } from '../lib/setupOrConfigureEncryption';
|
import { setupOrConfigureEncryption } from '../lib/setupOrConfigureEncryption';
|
||||||
import { CookieDropdown } from './CookieDropdown';
|
import { CookieDropdown } from './CookieDropdown';
|
||||||
import { BadgeButton } from './core/BadgeButton';
|
import { BadgeButton } from './core/BadgeButton';
|
||||||
@@ -23,7 +22,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Props) {
|
export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Props) {
|
||||||
const togglePalette = useToggleCommandPalette();
|
const [workspaceLayout, setWorkspaceLayout] = useAtom(workspaceLayoutAtom);
|
||||||
const workspace = useAtomValue(activeWorkspaceAtom);
|
const workspace = useAtomValue(activeWorkspaceAtom);
|
||||||
const workspaceMeta = useAtomValue(activeWorkspaceMetaAtom);
|
const workspaceMeta = useAtomValue(activeWorkspaceMetaAtom);
|
||||||
const showEncryptionSetup =
|
const showEncryptionSetup =
|
||||||
@@ -57,14 +56,22 @@ export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Prop
|
|||||||
) : (
|
) : (
|
||||||
<LicenseBadge />
|
<LicenseBadge />
|
||||||
)}
|
)}
|
||||||
|
<SettingsDropdown />
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={type() == 'macos' ? 'command' : 'square_terminal'}
|
icon={
|
||||||
title="Search or execute a command"
|
workspaceLayout === 'responsive'
|
||||||
|
? 'magic_wand'
|
||||||
|
: workspaceLayout === 'horizontal'
|
||||||
|
? 'columns_2'
|
||||||
|
: 'rows_2'
|
||||||
|
}
|
||||||
|
title={`Change to ${workspaceLayout === 'horizontal' ? 'vertical' : 'horizontal'} layout`}
|
||||||
size="sm"
|
size="sm"
|
||||||
iconColor="secondary"
|
iconColor="secondary"
|
||||||
onClick={togglePalette}
|
onClick={() =>
|
||||||
|
setWorkspaceLayout((prev) => (prev === 'horizontal' ? 'vertical' : 'horizontal'))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<SettingsDropdown />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { useContainerSize } from '../../hooks/useContainerQuery';
|
|||||||
import { clamp } from '../../lib/clamp';
|
import { clamp } from '../../lib/clamp';
|
||||||
import { ResizeHandle } from '../ResizeHandle';
|
import { ResizeHandle } from '../ResizeHandle';
|
||||||
|
|
||||||
|
export type SplitLayoutLayout = 'responsive' | 'horizontal' | 'vertical';
|
||||||
|
|
||||||
export interface SlotProps {
|
export interface SlotProps {
|
||||||
orientation: 'horizontal' | 'vertical';
|
orientation: 'horizontal' | 'vertical';
|
||||||
style: CSSProperties;
|
style: CSSProperties;
|
||||||
@@ -22,7 +24,7 @@ interface Props {
|
|||||||
defaultRatio?: number;
|
defaultRatio?: number;
|
||||||
minHeightPx?: number;
|
minHeightPx?: number;
|
||||||
minWidthPx?: number;
|
minWidthPx?: number;
|
||||||
layout?: 'responsive' | 'vertical' | 'horizontal';
|
layout?: SplitLayoutLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseProperties = { minWidth: 0 };
|
const baseProperties = { minWidth: 0 };
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import deepEqual from '@gilbarbara/deep-equal';
|
import deepEqual from '@gilbarbara/deep-equal';
|
||||||
import type { Atom } from 'jotai';
|
import type { Atom } from 'jotai';
|
||||||
import { selectAtom } from 'jotai/utils';
|
import { selectAtom } from 'jotai/utils';
|
||||||
|
import type { SplitLayoutLayout } from '../components/core/SplitLayout';
|
||||||
|
import { atomWithKVStorage } from './atoms/atomWithKVStorage';
|
||||||
|
|
||||||
export function deepEqualAtom<T>(a: Atom<T>) {
|
export function deepEqualAtom<T>(a: Atom<T>) {
|
||||||
return selectAtom(
|
return selectAtom(
|
||||||
@@ -9,3 +11,8 @@ export function deepEqualAtom<T>(a: Atom<T>) {
|
|||||||
(a, b) => deepEqual(a, b),
|
(a, b) => deepEqual(a, b),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const workspaceLayoutAtom = atomWithKVStorage<SplitLayoutLayout>(
|
||||||
|
'workspace_layout',
|
||||||
|
'horizontal',
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user