2020-08-19 11:35:35 +00:00
|
|
|
import { PluginErrorCode } from "@saleor/types/globalTypes";
|
2019-08-28 13:02:45 +00:00
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import PluginsDetailsPage, {
|
|
|
|
FormData,
|
|
|
|
PluginsDetailsPageProps
|
|
|
|
} from "../../../plugins/components/PluginsDetailsPage";
|
|
|
|
import { plugin } from "../../../plugins/fixtures";
|
|
|
|
import Decorator from "../../Decorator";
|
|
|
|
|
|
|
|
const props: PluginsDetailsPageProps = {
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
onBack: () => undefined,
|
2019-11-07 15:54:05 +00:00
|
|
|
onClear: () => undefined,
|
|
|
|
onEdit: () => undefined,
|
2019-08-28 13:50:03 +00:00
|
|
|
onSubmit: () => undefined,
|
2019-08-28 13:02:45 +00:00
|
|
|
plugin,
|
|
|
|
saveButtonBarState: "default"
|
|
|
|
};
|
|
|
|
|
|
|
|
storiesOf("Views / Plugins / Plugin details", module)
|
|
|
|
.addDecorator(Decorator)
|
|
|
|
.add("default", () => <PluginsDetailsPage {...props} />)
|
|
|
|
.add("loading", () => (
|
|
|
|
<PluginsDetailsPage {...props} disabled={true} plugin={undefined} />
|
|
|
|
))
|
|
|
|
.add("form errors", () => (
|
|
|
|
<PluginsDetailsPage
|
|
|
|
{...props}
|
2020-08-19 11:35:35 +00:00
|
|
|
errors={[
|
|
|
|
...(["active", "Username or account", "Password or license"] as Array<
|
|
|
|
keyof FormData
|
|
|
|
>).map(field => ({
|
|
|
|
__typename: "PluginError" as "PluginError",
|
|
|
|
code: PluginErrorCode.INVALID,
|
|
|
|
field
|
|
|
|
})),
|
|
|
|
{
|
|
|
|
__typename: "PluginError" as "PluginError",
|
|
|
|
code: PluginErrorCode.PLUGIN_MISCONFIGURED,
|
|
|
|
field: null
|
|
|
|
}
|
|
|
|
]}
|
2019-08-28 13:02:45 +00:00
|
|
|
/>
|
2019-11-07 15:54:05 +00:00
|
|
|
))
|
|
|
|
.add("not configurable", () => (
|
|
|
|
<PluginsDetailsPage
|
|
|
|
{...props}
|
|
|
|
plugin={{
|
|
|
|
...plugin,
|
|
|
|
configuration: null
|
|
|
|
}}
|
|
|
|
/>
|
2019-08-28 13:02:45 +00:00
|
|
|
));
|