Update Toast.stories.tsx
Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
@@ -558,111 +558,4 @@ export const AlertApiIntegration = meta.story({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* This story tests the real AlertApi integration.
|
||||
* It uses the alertApi from the TestApiProvider (set up in storybook preview)
|
||||
* and shows how alerts posted via alertApi.post() appear.
|
||||
*
|
||||
* Note: The storybook preview.tsx renders AlertDisplay from core-components,
|
||||
* which still uses Material UI. To test the new ToastDisplay, run the actual
|
||||
* Backstage app where the app plugin's elements.tsx is used.
|
||||
*/
|
||||
function RealAlertApiStory() {
|
||||
const alertApi = useApi(alertApiRef);
|
||||
|
||||
return (
|
||||
<Flex direction="column" gap="4">
|
||||
<Flex direction="column" gap="2">
|
||||
<Text variant="body-medium" weight="bold">
|
||||
Real AlertApi Test
|
||||
</Text>
|
||||
<Text variant="body-small">
|
||||
These buttons call alertApi.post() directly. Alerts appear in the OLD
|
||||
AlertDisplay (top of screen) because Storybook uses core-components.
|
||||
</Text>
|
||||
<Text variant="body-small">
|
||||
To test the NEW ToastDisplay, run: yarn start
|
||||
</Text>
|
||||
</Flex>
|
||||
<Flex gap="3">
|
||||
<Button
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'Entity saved successfully!',
|
||||
severity: 'success',
|
||||
display: 'transient',
|
||||
})
|
||||
}
|
||||
>
|
||||
Success (transient)
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'Catalog refresh in progress',
|
||||
severity: 'info',
|
||||
display: 'transient',
|
||||
})
|
||||
}
|
||||
>
|
||||
Info (transient)
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'Entity validation has warnings',
|
||||
severity: 'warning',
|
||||
display: 'transient',
|
||||
})
|
||||
}
|
||||
>
|
||||
Warning (transient)
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'Failed to fetch entity from catalog',
|
||||
severity: 'error',
|
||||
display: 'transient',
|
||||
})
|
||||
}
|
||||
>
|
||||
Error (transient)
|
||||
</Button>
|
||||
</Flex>
|
||||
<Flex gap="3">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'This alert stays until dismissed',
|
||||
severity: 'info',
|
||||
display: 'permanent',
|
||||
})
|
||||
}
|
||||
>
|
||||
Permanent Alert
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onPress={() =>
|
||||
alertApi.post({
|
||||
message: 'Critical error - requires attention!',
|
||||
severity: 'error',
|
||||
display: 'permanent',
|
||||
})
|
||||
}
|
||||
>
|
||||
Permanent Error
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
export const RealAlertApi = meta.story({
|
||||
name: 'Real AlertApi Test',
|
||||
render: () => <RealAlertApiStory />,
|
||||
});
|
||||
|
||||
export default meta;
|
||||
|
||||
Reference in New Issue
Block a user