|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import { ComponentStory, ComponentMeta } from '@storybook/react'; |
| 4 | +import { VSCodeButton, VSCodeLink } from '@vscode/webview-ui-toolkit/react'; |
| 5 | + |
| 6 | +import { VariantAnalysisContainer } from '../../view/variant-analysis/VariantAnalysisContainer'; |
| 7 | +import { Alert } from '../../view/common'; |
| 8 | + |
| 9 | +export default { |
| 10 | + title: 'Alert', |
| 11 | + component: Alert, |
| 12 | + decorators: [ |
| 13 | + (Story) => ( |
| 14 | + <VariantAnalysisContainer> |
| 15 | + <Story /> |
| 16 | + </VariantAnalysisContainer> |
| 17 | + ) |
| 18 | + ], |
| 19 | +} as ComponentMeta<typeof Alert>; |
| 20 | + |
| 21 | +const Template: ComponentStory<typeof Alert> = (args) => ( |
| 22 | + <Alert {...args} /> |
| 23 | +); |
| 24 | + |
| 25 | +export const Warning = Template.bind({}); |
| 26 | +Warning.args = { |
| 27 | + type: 'warning', |
| 28 | + title: 'This query found a warning', |
| 29 | + message: <>Warning content with <VSCodeLink>links</VSCodeLink></>, |
| 30 | +}; |
| 31 | + |
| 32 | +export const WarningInverse = Template.bind({}); |
| 33 | +WarningInverse.args = { |
| 34 | + ...Warning.args, |
| 35 | + message: 'Warning content', |
| 36 | + inverse: true, |
| 37 | +}; |
| 38 | + |
| 39 | +export const WarningExample = Template.bind({}); |
| 40 | +WarningExample.args = { |
| 41 | + type: 'warning', |
| 42 | + title: 'Query manually stopped', |
| 43 | + message: 'This query was manually stopped before the analysis completed. Results may be partial.', |
| 44 | +}; |
| 45 | + |
| 46 | +export const Error = Template.bind({}); |
| 47 | +Error.args = { |
| 48 | + type: 'error', |
| 49 | + title: 'This query found an error', |
| 50 | + message: <>Error content with <VSCodeLink>links</VSCodeLink></>, |
| 51 | +}; |
| 52 | + |
| 53 | +export const ErrorInverse = Template.bind({}); |
| 54 | +ErrorInverse.args = { |
| 55 | + ...Error.args, |
| 56 | + message: 'Error content', |
| 57 | + inverse: true, |
| 58 | +}; |
| 59 | + |
| 60 | +export const ErrorExample = Template.bind({}); |
| 61 | +ErrorExample.args = { |
| 62 | + type: 'error', |
| 63 | + title: 'Request failed', |
| 64 | + message: <> |
| 65 | + Request to https://api.github.com/repos/octodemo/Hello-World/code-scanning/codeql/queries failed.{' '} |
| 66 | + <VSCodeLink>Check logs</VSCodeLink> and try running this query again. |
| 67 | + </>, |
| 68 | +}; |
| 69 | + |
| 70 | +export const ErrorWithButtons = Template.bind({}); |
| 71 | +ErrorWithButtons.args = { |
| 72 | + type: 'error', |
| 73 | + title: 'Request failed', |
| 74 | + message: 'Request to https://api.github.com/repos/octodemo/Hello-World/code-scanning/codeql/queries failed. Try running this query again.', |
| 75 | + actions: ( |
| 76 | + <> |
| 77 | + <VSCodeButton appearance="secondary">View logs</VSCodeButton> |
| 78 | + <VSCodeButton>Retry</VSCodeButton> |
| 79 | + </> |
| 80 | + ), |
| 81 | +}; |
0 commit comments