From 987ae4240e40b3a469fe6d302b6b29d8a0aad2fe Mon Sep 17 00:00:00 2001 From: Marcus Forsberg Date: Mon, 22 Apr 2024 10:33:54 +0200 Subject: [PATCH] fix: ensure Studio navbar remains fixed when scrolling a long list of webhook attempts --- src/components/Webhooks.tsx | 202 ++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 102 deletions(-) diff --git a/src/components/Webhooks.tsx b/src/components/Webhooks.tsx index cd2ed6a..a405710 100644 --- a/src/components/Webhooks.tsx +++ b/src/components/Webhooks.tsx @@ -1,4 +1,4 @@ -import {Badge, Card, Flex, Heading, Inline, Spinner, Stack, Text} from '@sanity/ui' +import {Badge, Box, Card, Flex, Heading, Inline, Spinner, Stack, Text} from '@sanity/ui' import {FC, useEffect, useState} from 'react' import {useClient, useDataset, useProjectId} from 'sanity' import {Link, useRouter} from 'sanity/router' @@ -10,19 +10,34 @@ import {WebhookBodyComponentProps} from '../types/WebhookBodyComponentProps' import {BadgeRow} from './BadgeRow' import {Webhook} from './Webhook' +const ToolWrapper = styled(Box)` + @media (min-width: 1000px) { + height: 100%; + overflow: hidden; + } +` + const LayoutWrapper = styled(Flex)` flex-direction: column; @media (min-width: 1000px) { flex-direction: row; + height: 100%; } ` -const WebhooksList = styled.div` +const WebhooksList = styled(Stack)` @media (min-width: 1000px) { flex: 0 0 500px; + overflow-y: auto; + height: 100%; } ` +const AttemptsList = styled(Stack)` + flex-grow: 1; + overflow-y: auto; + height: 100%; +` export interface WebhooksProps { refreshInterval: number | undefined @@ -61,108 +76,91 @@ export function Webhooks({refreshInterval, webhookBodyComponent}: WebhooksProps) }, [router.state]) return ( - <> - - - - - - - Webhooks - - + + + + + Webhooks + - {isLoading && ( - - - - )} + {isLoading && ( + + + + )} - {!isLoading && webhooks.length === 0 && ( - - No webhooks are configured for the current dataset. - - )} - - {!isLoading && - webhooks?.map((webhook) => ( - - - - - - - {webhook.name} - - - {webhook.isDisabled ? 'Disabled' : 'Enabled'} - - - - - - - - - - - - - - - ))} - - - - - {webhookId && ( -
- + No webhooks are configured for the current dataset. + + )} + + {!isLoading && + webhooks?.map((webhook) => ( + + - - Events for {webhooks?.find((webhook) => webhook.id === webhookId)?.name} - - - - - -
- )} -
-
-
- + + + + + {webhook.name} + + + {webhook.isDisabled ? 'Disabled' : 'Enabled'} + + + + + + + + + + + + + + + ))} + + + + {webhookId && ( + <> + + + Events for {webhooks?.find((webhook) => webhook.id === webhookId)?.name} + + + + + )} + + + ) }