Skip to content

Commit

Permalink
chore: Fix the content layout title
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieweiyi committed Jul 2, 2024
1 parent 02d236d commit 7372d75
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const ContentLayout: FC<PropsWithChildren<ContentLayoutProps>> = ({
variant="h1"
{...props}
>
{applicationInfo.name ? `${title} for: ` + applicationInfo.name : 'Insights dashboard'}
{applicationInfo.name ? `${title} for: ${applicationInfo.name}` : title}
</Header>}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Spinner from '@cloudscape-design/components/spinner';
import StatusIndicator from '@cloudscape-design/components/status-indicator';
import * as awsui from '@cloudscape-design/design-tokens';
import { css } from '@emotion/react';
import { FC, useEffect, useCallback, useState, ReactNode, PropsWithChildren } from 'react';
import { FC, useEffect, useCallback, useState, ReactNode, PropsWithChildren, useMemo } from 'react';
import { DataExchangeFormat, HasContentDetails, ViewNavigationEvent } from '../../../../../customTypes';
import printStyles from '../../../../../styles/print';
import convertToYaml from '../../../../../utils/convertToYaml';
Expand Down Expand Up @@ -199,73 +199,43 @@ const ThreatModelView: FC<ThreatModelViewProps> = ({
return buttons.flatMap((b, index) => index === len - 1 ? <Box>{b}</Box> : [b, <Box fontWeight="bold" css={styles.text}>or</Box>]);
}, [hasContentDetails, props]);

const actions = useMemo(() => <SpaceBetween direction="horizontal" size="xs">
<Popover
dismissButton={false}
position="top"
size="small"
triggerType="custom"
content={
<StatusIndicator type="success">
Content copied
</StatusIndicator>
}
>
<Button
onClick={handleCopyMarkdown}>
Copy as Markdown
</Button>
</Popover>
{downloadFileName && showPrintDownloadButtons && <ButtonDropdown
items={[
{ text: 'Download as Markdown File', id: 'markdown' },
...(convertToDocx ? [{ text: 'Download as Word - Docx File', id: 'docx' }] : []),
{ text: 'Download as JSON File', id: 'json' },
]}
onItemClick={handleDownloadClick}
>
Download
</ButtonDropdown>}
{showPrintDownloadButtons && <Button variant="primary" onClick={onPrintButtonClick || (() => window.print())}>Print</Button>}
</SpaceBetween>, [handleCopyMarkdown, downloadFileName, showPrintDownloadButtons, convertToDocx, handleDownloadClick, onPrintButtonClick]);

return (<ContentLayout
isPreview={isPreview}
actions={
<SpaceBetween direction="horizontal" size="xs">
<Popover
dismissButton={false}
position="top"
size="small"
triggerType="custom"
content={
<StatusIndicator type="success">
Content copied
</StatusIndicator>
}
>
<Button
onClick={handleCopyMarkdown}>
Copy as Markdown
</Button>
</Popover>
{downloadFileName && showPrintDownloadButtons && <ButtonDropdown
items={[
{ text: 'Download as Markdown File', id: 'markdown' },
...(convertToDocx ? [{ text: 'Download as Word - Docx File', id: 'docx' }] : []),
{ text: 'Download as JSON File', id: 'json' },
]}
onItemClick={handleDownloadClick}
>
Download
</ButtonDropdown>}
{showPrintDownloadButtons && <Button variant="primary" onClick={onPrintButtonClick || (() => window.print())}>Print</Button>}
</SpaceBetween>
}>
actions={actions}>
<SpaceBetween direction='vertical' size='s'>
{isPreview && <div css={printStyles.hiddenPrint}>
<Header
actions={
<SpaceBetween direction="horizontal" size="xs">
<Popover
dismissButton={false}
position="top"
size="small"
triggerType="custom"
content={
<StatusIndicator type="success">
Content copied
</StatusIndicator>
}
>
<Button
onClick={handleCopyMarkdown}>
Copy as Markdown
</Button>
</Popover>
{downloadFileName && showPrintDownloadButtons && <ButtonDropdown
items={[
{ text: 'Download as Markdown File', id: 'markdown' },
...(convertToDocx ? [{ text: 'Download as Word - Docx File', id: 'docx' }] : []),
{ text: 'Download as JSON File', id: 'json' },
]}
onItemClick={handleDownloadClick}
>
Download
</ButtonDropdown>}
{showPrintDownloadButtons && <Button variant="primary" onClick={onPrintButtonClick || (() => window.print())}>Print</Button>}
</SpaceBetween>
}
actions={actions}
>
</Header>
</div>}
Expand Down

0 comments on commit 7372d75

Please sign in to comment.