saleor-dashboard/src/storybook/stories/attributes/AttributePage.tsx

79 lines
2 KiB
TypeScript
Raw Normal View History

2019-08-09 10:17:04 +00:00
import AttributePage, {
AttributePageProps,
2019-08-09 10:17:04 +00:00
} from "@saleor/attributes/components/AttributePage";
import { attribute } from "@saleor/attributes/fixtures";
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
import { AttributeErrorCode, AttributeInputTypeEnum } from "@saleor/graphql";
import { storiesOf } from "@storybook/react";
import React from "react";
2019-08-09 10:17:04 +00:00
import Decorator from "../../Decorator";
const props: AttributePageProps = {
children: () => null,
2019-08-09 10:17:04 +00:00
attribute,
disabled: false,
errors: [],
onDelete: () => undefined,
onSubmit: () => undefined,
onValueAdd: () => undefined,
onValueDelete: () => undefined,
onValueReorder: () => undefined,
onValueUpdate: () => undefined,
saveButtonBarState: "default",
values: attribute.choices,
pageInfo: {
hasNextPage: false,
hasPreviousPage: false,
},
onNextPage: () => undefined,
onPreviousPage: () => undefined,
2019-08-09 10:17:04 +00:00
};
storiesOf("Views / Attributes / Attribute details", module)
.addDecorator(Decorator)
.add("default", () => <AttributePage {...props}>{() => null}</AttributePage>)
2019-08-09 10:17:04 +00:00
.add("loading", () => (
<AttributePage
{...props}
attribute={undefined}
disabled={true}
values={undefined}
>
{() => null}
</AttributePage>
))
.add("no values", () => (
<AttributePage {...props} values={undefined}>
{() => null}
</AttributePage>
2019-08-09 10:17:04 +00:00
))
.add("form errors", () => (
<AttributePage
{...props}
2020-03-09 14:59:58 +00:00
errors={["name", "slug", "storefrontSearchPosition"].map(field => ({
Page types (#807) * Create attribute class selector * Use ProductAttributeType to check if product is simple or with variants * Allow attribute class selection only during its creation * Update attribute type selection translations * Show only product attributes in columns picker on product list view * Cleanups in Attribute Organization component * Create Page Types list page * Create content management section in settings * Implement page types list view * Remove unused imports from page type list * Updatte page type list style * Remove legacy code from page type list component * Update PageTypeListPage component * Create Page Types details page * Fix page type attribute reordering * Implement PageType create view * Implement PageType update view * gUpdate page type details components * Fix page type update component * Update page type components stories * Update page type errors handling * Update page type details view * Create Page Types details page * Implement PageType create view * Update product attribute assignment mutations * Add page types attribute assignment mutations * Add page types attribute assignment handling * Temporarily fix page create mutation * Update page type error messages * Remove legacy storybook page type stories * Update attribute assignment dialogs stories * Update page type details error handling * Update props for page type components * Create attribute class selector * Implement page types list view * Add page type selector on page create and details views * Add attributes list to page details views * Update page types list * Use attribute errors for attributes muatations * Save attribute values on page create and update * Update messages for page view * Update page attributes fragment * Use AttributeError in AttributeBulkDelete * Update page type and its attribute selection * Handle page types deleting * Update page types deleting messages * Handle page types attribute reorder * Fix PageOrganizeContent component types * Update graphqql types * Fix page fixture * Update messages * Update test snapshots * Pass pageTypes to PageForm * Update changelog with page type addition note * Update package-lock * Update test snapshots * Fix malformed generated type * Update messages after rebase
2020-11-19 14:42:14 +00:00
__typename: "AttributeError",
code: AttributeErrorCode.INVALID,
field,
message: "Attribute code invalid",
2020-03-09 14:59:58 +00:00
}))}
>
{() => null}
</AttributePage>
2019-08-09 10:17:04 +00:00
))
.add("multiple select input", () => (
<AttributePage
{...props}
attribute={{
...attribute,
inputType: AttributeInputTypeEnum.MULTISELECT,
2019-08-09 10:17:04 +00:00
}}
>
{() => null}
</AttributePage>
2019-08-09 10:17:04 +00:00
))
.add("create", () => (
<AttributePage {...props} attribute={null}>
{() => null}
</AttributePage>
));