Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions packages/compass-components/src/hooks/use-error-details.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { showConfirmation } from './use-confirmation';
import { Code, ConfirmationModalVariant } from '../components/leafygreen';
import { css } from '@leafygreen-ui/emotion';
import { spacing } from '@leafygreen-ui/tokens';
import React from 'react';

const errorDetailsContentStyles = css({
paddingTop: spacing[400], // small gap above JSON
maxHeight: '60vh', // cap JSON area height so footer can stay visible
overflow: 'auto', // scroll JSON when long
});

export const showErrorDetails = function showErrorDetails({
details,
closeAction,
Expand All @@ -12,13 +20,15 @@ export const showErrorDetails = function showErrorDetails({
void showConfirmation({
title: 'Error details',
description: (
<Code
language="json"
data-testid="error-details-json"
id="error-details-json"
>
{JSON.stringify(details, undefined, 2)}
</Code>
<div className={errorDetailsContentStyles}>
<Code
language="json"
data-testid="error-details-json"
id="error-details-json"
>
{JSON.stringify(details, undefined, 2)}
</Code>
</div>
),
hideCancelButton: true,
buttonText: closeAction.replace(/\b\w/g, (c) => c.toUpperCase()),
Expand Down
Loading