|
| 1 | +import { createFakeDeployment } from "@/mocks"; |
| 2 | +import { routerDecorator } from "@/storybook/utils"; |
| 3 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 4 | +import type { AutomationTrigger } from "./constants"; |
| 5 | +import { DeploymentsStatusDetails } from "./deployments-status-details"; |
| 6 | + |
| 7 | +const ANY_DEPLOYMENTS_ENTER: AutomationTrigger = { |
| 8 | + type: "event", |
| 9 | + id: "bc1f8369-67fd-4b04-98ba-602bd2f8b075", |
| 10 | + match: { "prefect.resource.id": "prefect.deployment.*" }, |
| 11 | + match_related: {}, |
| 12 | + after: [], |
| 13 | + expect: ["prefect.deployment.not-ready"], |
| 14 | + for_each: ["prefect.resource.id"], |
| 15 | + posture: "Reactive", |
| 16 | + threshold: 1, |
| 17 | + within: 0, |
| 18 | +}; |
| 19 | + |
| 20 | +const ANY_DEPLOYMENTS_STAY: AutomationTrigger = { |
| 21 | + type: "event", |
| 22 | + id: "413e09b4-b7cd-42a8-b503-cddcbbd5533f", |
| 23 | + match: { "prefect.resource.id": "prefect.deployment.*" }, |
| 24 | + match_related: {}, |
| 25 | + after: ["prefect.deployment.not-ready"], |
| 26 | + expect: ["prefect.deployment.ready"], |
| 27 | + for_each: ["prefect.resource.id"], |
| 28 | + posture: "Proactive", |
| 29 | + threshold: 1, |
| 30 | + within: 30, |
| 31 | +}; |
| 32 | + |
| 33 | +const SPECIFIC_DEPLOYMENTS_ENTER: AutomationTrigger = { |
| 34 | + type: "event", |
| 35 | + id: "46d8316b-8b3f-441e-b4b5-8cb98ed81ea3", |
| 36 | + match: { |
| 37 | + "prefect.resource.id": [ |
| 38 | + "prefect.deployment.18940945-9107-4d8c-8734-ab2dc839cdba", |
| 39 | + "prefect.deployment.38ce4d9e-df55-4df6-a65b-38a8f2baf975", |
| 40 | + ], |
| 41 | + }, |
| 42 | + match_related: {}, |
| 43 | + after: [], |
| 44 | + expect: ["prefect.deployment.not-ready"], |
| 45 | + for_each: ["prefect.resource.id"], |
| 46 | + posture: "Reactive", |
| 47 | + threshold: 1, |
| 48 | + within: 0, |
| 49 | +}; |
| 50 | + |
| 51 | +const SPECIFIC_DEPLOYMENTS_STAY: AutomationTrigger = { |
| 52 | + type: "event", |
| 53 | + id: "3f8e54f3-13da-4880-bbca-32c42c2f7688", |
| 54 | + match: { |
| 55 | + "prefect.resource.id": [ |
| 56 | + "prefect.deployment.18940945-9107-4d8c-8734-ab2dc839cdba", |
| 57 | + "prefect.deployment.38ce4d9e-df55-4df6-a65b-38a8f2baf975", |
| 58 | + "prefect.deployment.06597581-a4ed-4e1a-a451-d430bd6f33d6", |
| 59 | + ], |
| 60 | + }, |
| 61 | + match_related: {}, |
| 62 | + after: ["prefect.deployment.not-ready"], |
| 63 | + expect: ["prefect.deployment.ready"], |
| 64 | + for_each: ["prefect.resource.id"], |
| 65 | + posture: "Proactive", |
| 66 | + threshold: 1, |
| 67 | + within: 1800, |
| 68 | +}; |
| 69 | + |
| 70 | +const meta = { |
| 71 | + title: "Components/Automations/DeploymentsStatusDetails", |
| 72 | + component: StoryComponent, |
| 73 | + decorators: [routerDecorator], |
| 74 | +} satisfies Meta<typeof DeploymentsStatusDetails>; |
| 75 | + |
| 76 | +export default meta; |
| 77 | + |
| 78 | +function StoryComponent() { |
| 79 | + return ( |
| 80 | + <div className="flex flex-col gap-4"> |
| 81 | + {[ |
| 82 | + ANY_DEPLOYMENTS_ENTER, |
| 83 | + ANY_DEPLOYMENTS_STAY, |
| 84 | + SPECIFIC_DEPLOYMENTS_ENTER, |
| 85 | + SPECIFIC_DEPLOYMENTS_STAY, |
| 86 | + ].map((trigger, i) => ( |
| 87 | + <DeploymentsStatusDetails |
| 88 | + key={i} |
| 89 | + trigger={trigger} |
| 90 | + deployments={[createFakeDeployment(), createFakeDeployment()]} |
| 91 | + /> |
| 92 | + ))} |
| 93 | + </div> |
| 94 | + ); |
| 95 | +} |
| 96 | + |
| 97 | +export const Story: StoryObj = { |
| 98 | + name: "DeploymentsStatusDetails", |
| 99 | +}; |
0 commit comments