From 31f90856ef2f7c1d420f8f649849a08a6de2f720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chy=C5=82a?= Date: Tue, 18 Feb 2025 14:36:17 +0100 Subject: [PATCH] Improvements for filters after acceptance phase (#5420) * Fixes for collections * Fixes for gift cards placeholder * Update copy in draft orders * Fixes for attributes * Fixes for product types * Add changeset * Change configurable label * Add Inactive label for staff members * Remove filterableInDashboard * Update label in order creation date * Remove searchable field from attributes datagrid --- .changeset/spicy-poems-shout.md | 5 ++ locale/defaultMessages.json | 60 +++++++++---------- .../AttributeListDatagrid/datagrid.ts | 7 --- .../AttributeListDatagrid/messages.ts | 15 ++--- .../AttributeProperties.tsx | 14 ++--- src/attributes/urls.ts | 1 - src/attributes/views/AttributeList/sort.ts | 2 - .../views/CollectionList/CollectionList.tsx | 5 +- .../attributes/InitialAttributesState.test.ts | 33 ---------- .../attributes/InitialAttributesState.ts | 4 -- .../attributes/useInitialAttributesState.ts | 1 - .../collections/useInitialCollectionsState.ts | 7 --- .../API/initialState/helpers.ts | 3 +- .../useInitialProdutTypesState.ts | 22 ++----- .../InitialStaffMembersState.test.ts | 2 +- .../ConditionalFilter/API/messages.ts | 4 +- .../providers/AttributesFilterAPIProvider.tsx | 1 - .../providers/CollectionFilterAPIProvider.tsx | 23 ++++--- .../ProductTypesFilterAPIProvider.tsx | 6 +- .../ValueProvider/UrlToken.ts | 1 - src/components/ConditionalFilter/constants.ts | 19 ++---- .../ConditionalFilter/queryVariables.test.ts | 19 +----- .../ConditionalFilter/queryVariables.ts | 21 ++++++- .../GiftCardListSearchAndFilters/messages.ts | 4 +- 24 files changed, 103 insertions(+), 176 deletions(-) create mode 100644 .changeset/spicy-poems-shout.md diff --git a/.changeset/spicy-poems-shout.md b/.changeset/spicy-poems-shout.md new file mode 100644 index 00000000000..85463ba5e12 --- /dev/null +++ b/.changeset/spicy-poems-shout.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Apply improvments for new filters so they looks align diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 6fb88581423..d44e748fa3e 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -1678,6 +1678,10 @@ "9FGTOt": { "string": "Allow access to orders of all channels" }, + "9IrVVZ": { + "context": "attribute can be searched in storefront", + "string": "Filterable in storefront" + }, "9MGrEp": { "string": "Is available" }, @@ -4548,10 +4552,6 @@ "context": "info text", "string": "Set up an end date of preorder. When end date will be reached product will be automatically taken from preorder to standard selling" }, - "RH+aOF": { - "context": "use attribute in filtering", - "string": "Use in Filtering" - }, "RK6l3Z": { "context": "radio button label", "string": "Refund with manual amount" @@ -4751,10 +4751,6 @@ "context": "header", "string": "Translation Attribute \"{attribute}\" - {languageCode}" }, - "SPF/Zn": { - "context": "staff members status deactivated", - "string": "Deactivated" - }, "SPp3cx": { "context": "alert message", "string": "Orders cannot be placed in an inactive channel." @@ -4774,6 +4770,10 @@ "context": "product weight", "string": "Weight" }, + "SV0FRm": { + "context": "attribute is filterable in storefront", + "string": "Filterable in storefront" + }, "SZH0fw": { "context": "set variant as default, button", "string": "Set as default" @@ -5330,6 +5330,10 @@ "W6nwjo": { "string": "Draft" }, + "W75xMz": { + "context": "attribute is visible in storefront", + "string": "Visible in storefront" + }, "W8i2Ez": { "context": "product field", "string": "Name" @@ -5693,10 +5697,6 @@ "context": "table column header", "string": "Price" }, - "Y3pCRX": { - "context": "attribute can be searched in storefront", - "string": "Use as filter" - }, "Y3zr/B": { "context": "voucher application, switch button", "string": "Apply only to a single cheapest eligible product" @@ -6575,10 +6575,6 @@ "e0lt+l": { "string": "See documentation" }, - "e1vU/4": { - "context": "attribute is filterable in storefront", - "string": "Use as filter" - }, "e4UtKH": { "context": "Transaction event status - failure", "string": "Failure" @@ -7012,10 +7008,6 @@ "context": "caption", "string": "If enabled, attribute will be accessible to customers." }, - "h2hEKV": { - "context": "search gift card placeholder", - "string": "Search gift cards, e.g {exampleGiftCardCode}" - }, "h2vipu": { "string": "Code" }, @@ -7265,6 +7257,10 @@ "context": "header", "string": "App Information" }, + "inWs4U": { + "context": "attribute visibility in storefront", + "string": "Visible in storefront" + }, "ipbT0Q": { "context": "btn label", "string": "Mark all as done" @@ -7318,6 +7314,10 @@ "context": "order history message", "string": "Shipping tracking number was sent to customer" }, + "j5hGyJ": { + "context": "attribute is filterable in dashboard", + "string": "Filterable in dashboard" + }, "j8PV7E": { "context": "attribute values", "string": "Values" @@ -7367,6 +7367,10 @@ "context": "product availability", "string": "Hide in product listings" }, + "jY80Gs": { + "context": "search gift card placeholder", + "string": "Search by code, e.g {exampleGiftCardCode}" + }, "ja+tNj": { "string": "requests access to new permissions." }, @@ -7457,10 +7461,6 @@ "context": "select label", "string": "Unset" }, - "k6WDZl": { - "context": "attribute is visible", - "string": "Visible" - }, "k6sfZr": { "context": "tooltip content when product is in preorder", "string": "This product is still in preorder. You will be able to fulfill it after it reaches it’s release date" @@ -8164,6 +8164,10 @@ "oYGfnY": { "string": "ZIP / Postal code" }, + "oYV+Ru": { + "context": "staff members status deactivated", + "string": "Inactive" + }, "oboeOT": { "string": "Add following permissions" }, @@ -9429,10 +9433,6 @@ "context": "ProductTypeDeleteWarningDialog title", "string": "Delete product {selectedTypesCount,plural,one{type} other{types}}" }, - "x8V/xS": { - "context": "attribute visibility in storefront", - "string": "Public" - }, "xAHOGV": { "context": "dialog header", "string": "Assign Variant" @@ -9595,10 +9595,6 @@ "context": "discount value", "string": "discount" }, - "yKuba7": { - "context": "attribute can be searched in dashboard", - "string": "Searchable" - }, "yLfbSh": { "context": "support label", "string": "Channel name" diff --git a/src/attributes/components/AttributeListDatagrid/datagrid.ts b/src/attributes/components/AttributeListDatagrid/datagrid.ts index 21c467c4c84..d0d66ca08dc 100644 --- a/src/attributes/components/AttributeListDatagrid/datagrid.ts +++ b/src/attributes/components/AttributeListDatagrid/datagrid.ts @@ -31,11 +31,6 @@ export const attributesListStaticColumnsAdapter = ( title: intl.formatMessage(columnsMessages.visible), width: 200, }, - { - id: "searchable", - title: intl.formatMessage(columnsMessages.searchable), - width: 200, - }, { id: "use-in-faceted-search", title: intl.formatMessage(columnsMessages.useInFacetedSearch), @@ -71,8 +66,6 @@ export const createGetCellContent = return readonlyTextCell(rowData?.name ?? PLACEHOLDER); case "visible": return readonlyTextCell(translateBoolean(rowData?.visibleInStorefront, intl)); - case "searchable": - return readonlyTextCell(translateBoolean(rowData?.filterableInDashboard, intl)); case "use-in-faceted-search": return readonlyTextCell(translateBoolean(rowData?.filterableInStorefront, intl)); default: diff --git a/src/attributes/components/AttributeListDatagrid/messages.ts b/src/attributes/components/AttributeListDatagrid/messages.ts index a57e274a6f0..f8366f11815 100644 --- a/src/attributes/components/AttributeListDatagrid/messages.ts +++ b/src/attributes/components/AttributeListDatagrid/messages.ts @@ -11,18 +11,13 @@ export const columnsMessages = defineMessages({ description: "attribute's label'", }, visible: { - id: "k6WDZl", - defaultMessage: "Visible", - description: "attribute is visible", - }, - searchable: { - id: "yKuba7", - defaultMessage: "Searchable", - description: "attribute can be searched in dashboard", + id: "W75xMz", + defaultMessage: "Visible in storefront", + description: "attribute is visible in storefront", }, useInFacetedSearch: { - defaultMessage: "Use as filter", - id: "Y3pCRX", + defaultMessage: "Filterable in storefront", + id: "9IrVVZ", description: "attribute can be searched in storefront", }, }); diff --git a/src/attributes/components/AttributeProperties/AttributeProperties.tsx b/src/attributes/components/AttributeProperties/AttributeProperties.tsx index ab88d526b25..a0f7b8c9c1a 100644 --- a/src/attributes/components/AttributeProperties/AttributeProperties.tsx +++ b/src/attributes/components/AttributeProperties/AttributeProperties.tsx @@ -31,9 +31,9 @@ const messages = defineMessages({ description: "attribute properties regarding dashboard", }, filterableInDashboard: { - id: "RH+aOF", - defaultMessage: "Use in Filtering", - description: "use attribute in filtering", + id: "j5hGyJ", + defaultMessage: "Filterable in dashboard", + description: "attribute is filterable in dashboard", }, filterableInDashboardCaption: { id: "Q9wTrz", @@ -42,8 +42,8 @@ const messages = defineMessages({ description: "caption", }, filterableInStorefront: { - defaultMessage: "Use as filter", - id: "e1vU/4", + defaultMessage: "Filterable in storefront", + id: "SV0FRm", description: "attribute is filterable in storefront", }, storefrontPropertiesTitle: { @@ -57,8 +57,8 @@ const messages = defineMessages({ description: "attribute position in storefront filters", }, visibleInStorefront: { - id: "x8V/xS", - defaultMessage: "Public", + id: "inWs4U", + defaultMessage: "Visible in storefront", description: "attribute visibility in storefront", }, visibleInStorefrontCaption: { diff --git a/src/attributes/urls.ts b/src/attributes/urls.ts index d7ff0d978ef..85ee0d9aaf2 100644 --- a/src/attributes/urls.ts +++ b/src/attributes/urls.ts @@ -27,7 +27,6 @@ export enum AttributeListUrlSortField { name = "name", slug = "slug", visible = "visible", - searchable = "searchable", useInFacetedSearch = "use-in-faceted-search", } export type AttributeListUrlSort = Sort; diff --git a/src/attributes/views/AttributeList/sort.ts b/src/attributes/views/AttributeList/sort.ts index 1249422a148..0f3197334af 100644 --- a/src/attributes/views/AttributeList/sort.ts +++ b/src/attributes/views/AttributeList/sort.ts @@ -8,8 +8,6 @@ export function getSortQueryField(sort: AttributeListUrlSortField): AttributeSor return AttributeSortField.NAME; case AttributeListUrlSortField.slug: return AttributeSortField.SLUG; - case AttributeListUrlSortField.searchable: - return AttributeSortField.FILTERABLE_IN_DASHBOARD; case AttributeListUrlSortField.useInFacetedSearch: return AttributeSortField.FILTERABLE_IN_STOREFRONT; case AttributeListUrlSortField.visible: diff --git a/src/collections/views/CollectionList/CollectionList.tsx b/src/collections/views/CollectionList/CollectionList.tsx index fc1e2d5e852..8a2a5f25654 100644 --- a/src/collections/views/CollectionList/CollectionList.tsx +++ b/src/collections/views/CollectionList/CollectionList.tsx @@ -102,7 +102,10 @@ export const CollectionList: React.FC = ({ params }) => { return { ...paginationState, - filter: variables, + filter: { + ...variables, + search: params.query, + }, sort: getSortQueryVariables(params), channel, // Saleor docs say 'channel' in filter is deprecated and should be moved to root }; diff --git a/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.test.ts b/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.test.ts index ac5d3b878f8..ce8b17fc227 100644 --- a/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.test.ts +++ b/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.test.ts @@ -101,39 +101,6 @@ describe("ConditionalFilter / API / Page / InitialAttributesState", () => { expect(result).toEqual(expectedOutput); }); - it("should filter by filterableInDashboard", () => { - // Arrange - const initialAttributesState = InitialAttributesStateResponse.empty(); - - initialAttributesState.filterableInDashboard = [ - { - label: "Yes", - value: "true", - slug: "true", - }, - { - label: "No", - value: "false", - slug: "false", - }, - ]; - - const token = UrlToken.fromUrlEntry(new UrlEntry("s0.filterableInDashboard", "false")); - const expectedOutput = [ - { - label: "No", - value: "false", - slug: "false", - }, - ]; - - // Act - const result = initialAttributesState.filterByUrlToken(token); - - // Assert - expect(result).toEqual(expectedOutput); - }); - it("should filter by isVariantOnly", () => { // Arrange const initialAttributesState = InitialAttributesStateResponse.empty(); diff --git a/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.ts b/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.ts index 6adc38b75fb..71d4a203804 100644 --- a/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.ts +++ b/src/components/ConditionalFilter/API/initialState/attributes/InitialAttributesState.ts @@ -5,7 +5,6 @@ export interface InitialAttributesState { channels: ItemOption[]; attributeTypes: ItemOption[]; filterableInStorefront: ItemOption[]; - filterableInDashboard: ItemOption[]; isVariantOnly: ItemOption[]; valueRequired: ItemOption[]; visibleInStorefront: ItemOption[]; @@ -16,7 +15,6 @@ export class InitialAttributesStateResponse implements InitialAttributesState { public channels: ItemOption[] = [], public attributeTypes: ItemOption[] = [], public filterableInStorefront: ItemOption[] = [], - public filterableInDashboard: ItemOption[] = [], public isVariantOnly: ItemOption[] = [], public valueRequired: ItemOption[] = [], public visibleInStorefront: ItemOption[] = [], @@ -44,8 +42,6 @@ export class InitialAttributesStateResponse implements InitialAttributesState { return this.attributeTypes; case "filterableInStorefront": return this.filterableInStorefront; - case "filterableInDashboard": - return this.filterableInDashboard; case "isVariantOnly": return this.isVariantOnly; case "valueRequired": diff --git a/src/components/ConditionalFilter/API/initialState/attributes/useInitialAttributesState.ts b/src/components/ConditionalFilter/API/initialState/attributes/useInitialAttributesState.ts index 4baaa0283fd..eb7ce6a671d 100644 --- a/src/components/ConditionalFilter/API/initialState/attributes/useInitialAttributesState.ts +++ b/src/components/ConditionalFilter/API/initialState/attributes/useInitialAttributesState.ts @@ -58,7 +58,6 @@ export const useInitialAttributesState = (): InitialAttributesAPIState => { initialState.channels, initialState.attributeType, initialState.filterableInStorefront, - initialState.filterableInDashboard, initialState.isVariantOnly, initialState.valueRequired, initialState.visibleInStorefront, diff --git a/src/components/ConditionalFilter/API/initialState/collections/useInitialCollectionsState.ts b/src/components/ConditionalFilter/API/initialState/collections/useInitialCollectionsState.ts index 44ef37b8f96..1b3bdceac5e 100644 --- a/src/components/ConditionalFilter/API/initialState/collections/useInitialCollectionsState.ts +++ b/src/components/ConditionalFilter/API/initialState/collections/useInitialCollectionsState.ts @@ -4,12 +4,9 @@ import { _GetChannelOperandsDocument, _GetChannelOperandsQuery, _GetChannelOperandsQueryVariables, - CollectionPublished, } from "@dashboard/graphql"; import { useState } from "react"; -import { useIntl } from "react-intl"; -import { EnumValuesHandler } from "../../Handler"; import { createInitialCollectionState } from "../helpers"; import { InitialCollectionAPIResponse } from "../types"; import { InitialCollectionStateResponse } from "./InitialCollectionState"; @@ -22,7 +19,6 @@ export interface InitialCollectionAPIState { export const useInitialCollectionState = (): InitialCollectionAPIState => { const client = useApolloClient(); - const intl = useIntl(); const [data, setData] = useState( InitialCollectionStateResponse.empty(), @@ -40,12 +36,9 @@ export const useInitialCollectionState = (): InitialCollectionAPIState => { ); } - const publishedInit = new EnumValuesHandler(CollectionPublished, "published", intl); - const data = await Promise.all(queriesToRun); const initialState = { ...createInitialCollectionState(data, channel), - published: await publishedInit.fetch(), }; setData( diff --git a/src/components/ConditionalFilter/API/initialState/helpers.ts b/src/components/ConditionalFilter/API/initialState/helpers.ts index e595d4ebe0c..d82bd45989b 100644 --- a/src/components/ConditionalFilter/API/initialState/helpers.ts +++ b/src/components/ConditionalFilter/API/initialState/helpers.ts @@ -271,7 +271,7 @@ export const createInitialCollectionState = ( }, { channel: [], - published: [], + published: createBooleanOptions(), metadata: [], }, ); @@ -296,7 +296,6 @@ export const createInitialAttributeState = (data: InitialAttributesAPIResponse[] channels: [], attributeTypes: [], filterableInStorefront: createBooleanOptions(), - filterableInDashboard: createBooleanOptions(), isVariantOnly: createBooleanOptions(), valueRequired: createBooleanOptions(), visibleInStorefront: createBooleanOptions(), diff --git a/src/components/ConditionalFilter/API/initialState/productTypes/useInitialProdutTypesState.ts b/src/components/ConditionalFilter/API/initialState/productTypes/useInitialProdutTypesState.ts index a954173dbeb..30cc3545002 100644 --- a/src/components/ConditionalFilter/API/initialState/productTypes/useInitialProdutTypesState.ts +++ b/src/components/ConditionalFilter/API/initialState/productTypes/useInitialProdutTypesState.ts @@ -1,10 +1,11 @@ import { InitialProductTypesStateResponse } from "@dashboard/components/ConditionalFilter/API/initialState/productTypes/InitialProductTypesState"; -import { ProductTypeConfigurable, ProductTypeEnum } from "@dashboard/graphql"; +import { createBooleanOptions } from "@dashboard/components/ConditionalFilter/constants"; +import { ProductTypeEnum } from "@dashboard/graphql"; import { useState } from "react"; import { useIntl } from "react-intl"; import { ProductTypesFetchingParams } from "../../../ValueProvider/TokenArray/fetchingParams"; -import { BooleanValuesHandler, EnumValuesHandler } from "../../Handler"; +import { EnumValuesHandler } from "../../Handler"; export interface InitialProductTypesAPIState { data: InitialProductTypesStateResponse; @@ -27,24 +28,9 @@ export const useInitialProductTypesState = (): InitialProductTypesAPIState => { typeOfProduct, ); - const configurableInit = new BooleanValuesHandler([ - { - label: "Yes", - value: ProductTypeConfigurable.CONFIGURABLE, - type: "configurable", - slug: "true", - }, - { - label: "No", - value: ProductTypeConfigurable.SIMPLE, - type: "configurable", - slug: "false", - }, - ]); - const initialState = { typeOfProduct: await typeOfProductInit.fetch(), - configurable: await configurableInit.fetch(), + configurable: createBooleanOptions(), }; setData( diff --git a/src/components/ConditionalFilter/API/initialState/staffMembers/InitialStaffMembersState.test.ts b/src/components/ConditionalFilter/API/initialState/staffMembers/InitialStaffMembersState.test.ts index 45459b0f013..b1bdc1eb87c 100644 --- a/src/components/ConditionalFilter/API/initialState/staffMembers/InitialStaffMembersState.test.ts +++ b/src/components/ConditionalFilter/API/initialState/staffMembers/InitialStaffMembersState.test.ts @@ -13,7 +13,7 @@ describe("ConditionalFilter / API / Page / InitialStaffMembersState", () => { slug: "active", }, { - label: "Deactivated", + label: "Inactive", value: "deactivated", slug: "deactivated", }, diff --git a/src/components/ConditionalFilter/API/messages.ts b/src/components/ConditionalFilter/API/messages.ts index f075d01dbdd..3bef8133de6 100644 --- a/src/components/ConditionalFilter/API/messages.ts +++ b/src/components/ConditionalFilter/API/messages.ts @@ -97,9 +97,9 @@ export const staffMembersStatusMessages = defineMessages({ id: "nG1+Cz", }, deactivated: { - defaultMessage: "Deactivated", + defaultMessage: "Inactive", description: "staff members status deactivated", - id: "SPF/Zn", + id: "oYV+Ru", }, }); diff --git a/src/components/ConditionalFilter/API/providers/AttributesFilterAPIProvider.tsx b/src/components/ConditionalFilter/API/providers/AttributesFilterAPIProvider.tsx index 7c7aac6a193..8cbcdce464d 100644 --- a/src/components/ConditionalFilter/API/providers/AttributesFilterAPIProvider.tsx +++ b/src/components/ConditionalFilter/API/providers/AttributesFilterAPIProvider.tsx @@ -17,7 +17,6 @@ const getFilterElement = (value: FilterContainer, index: number): FilterElement }; const booleanTypes = [ - "filterableInDashboard", "isVariantOnly", "valueRequired", "visibleInStorefront", diff --git a/src/components/ConditionalFilter/API/providers/CollectionFilterAPIProvider.tsx b/src/components/ConditionalFilter/API/providers/CollectionFilterAPIProvider.tsx index 78b1620cb85..57215712857 100644 --- a/src/components/ConditionalFilter/API/providers/CollectionFilterAPIProvider.tsx +++ b/src/components/ConditionalFilter/API/providers/CollectionFilterAPIProvider.tsx @@ -1,22 +1,32 @@ import { ApolloClient, useApolloClient } from "@apollo/client"; -import { CollectionPublished } from "@dashboard/graphql/types.generated"; -import { IntlShape, useIntl } from "react-intl"; import { FilterContainer, FilterElement } from "../../FilterElement"; import { FilterAPIProvider } from "../FilterAPIProvider"; -import { ChannelHandler, EnumValuesHandler, Handler, NoopValuesHandler } from "../Handler"; +import { BooleanValuesHandler, ChannelHandler, Handler, NoopValuesHandler } from "../Handler"; import { getFilterElement } from "../utils"; const createAPIHandler = ( selectedRow: FilterElement, client: ApolloClient, inputValue: string, - intl: IntlShape, ): Handler => { const rowType = selectedRow.rowType(); if (rowType === "published") { - return new EnumValuesHandler(CollectionPublished, "published", intl); + return new BooleanValuesHandler([ + { + label: "Yes", + value: "true", + type: rowType, + slug: "true", + }, + { + label: "No", + value: "false", + type: rowType, + slug: "false", + }, + ]); } if (rowType === "metadata") { @@ -31,7 +41,6 @@ const createAPIHandler = ( }; export const useCollectionFilterAPIProvider = (): FilterAPIProvider => { - const intl = useIntl(); const client = useApolloClient(); const fetchRightOptions = async ( @@ -42,7 +51,7 @@ export const useCollectionFilterAPIProvider = (): FilterAPIProvider => { const index = parseInt(position, 10); const filterElement = getFilterElement(value, index); - const handler = createAPIHandler(filterElement, client, inputValue, intl); + const handler = createAPIHandler(filterElement, client, inputValue); return handler.fetch(); }; diff --git a/src/components/ConditionalFilter/API/providers/ProductTypesFilterAPIProvider.tsx b/src/components/ConditionalFilter/API/providers/ProductTypesFilterAPIProvider.tsx index 092b3e7064e..7267a4a9f39 100644 --- a/src/components/ConditionalFilter/API/providers/ProductTypesFilterAPIProvider.tsx +++ b/src/components/ConditionalFilter/API/providers/ProductTypesFilterAPIProvider.tsx @@ -2,7 +2,7 @@ import { BooleanValuesHandler, EnumValuesHandler, } from "@dashboard/components/ConditionalFilter/API/Handler"; -import { ProductTypeConfigurable, ProductTypeEnum } from "@dashboard/graphql"; +import { ProductTypeEnum } from "@dashboard/graphql"; import { useIntl } from "react-intl"; import { FilterContainer } from "../../FilterElement"; @@ -21,13 +21,13 @@ export const useProductTypesFilterAPIProvider = (): FilterAPIProvider => { return await new BooleanValuesHandler([ { label: "Yes", - value: ProductTypeConfigurable.CONFIGURABLE, + value: "true", type: rowType, slug: "true", }, { label: "No", - value: ProductTypeConfigurable.SIMPLE, + value: "false", type: rowType, slug: "false", }, diff --git a/src/components/ConditionalFilter/ValueProvider/UrlToken.ts b/src/components/ConditionalFilter/ValueProvider/UrlToken.ts index 8cc680db52f..26cc0347c77 100644 --- a/src/components/ConditionalFilter/ValueProvider/UrlToken.ts +++ b/src/components/ConditionalFilter/ValueProvider/UrlToken.ts @@ -47,7 +47,6 @@ const ATTRIBUTES_STATICS = [ "channel", "attributeType", "filterableInStorefront", - "filterableInDashboard", "isVariantOnly", "valueRequired", "visibleInStorefront", diff --git a/src/components/ConditionalFilter/constants.ts b/src/components/ConditionalFilter/constants.ts index fa4d8085507..81490e376e7 100644 --- a/src/components/ConditionalFilter/constants.ts +++ b/src/components/ConditionalFilter/constants.ts @@ -46,7 +46,6 @@ export const STATIC_CONDITIONS = { valueRequired: [{ type: "select", label: "is", value: "input-1" }], visibleInStorefront: [{ type: "select", label: "is", value: "input-1" }], filterableInStorefront: [{ type: "select", label: "is", value: "input-1" }], - filterableInDashboard: [{ type: "select", label: "is", value: "input-1" }], attributeType: [{ type: "select", label: "is", value: "input-1" }], hasCategory: [{ type: "select", label: "is", value: "input-1" }], giftCard: [{ type: "select", label: "is", value: "input-1" }], @@ -317,7 +316,7 @@ export const STATIC_ORDER_OPTIONS: LeftOperand[] = [ }, { value: "created", - label: "Created", + label: "Creation date", type: "created", slug: "created", }, @@ -413,7 +412,7 @@ export const STATIC_VOUCHER_OPTIONS: LeftOperand[] = [ export const STATIC_COLLECTION_OPTIONS: LeftOperand[] = [ { value: "published", - label: "Published", + label: "Is published", type: "published", slug: "published", }, @@ -449,7 +448,7 @@ export const STATIC_DRAFT_ORDER_OPTIONS: LeftOperand[] = [ }, { value: "created", - label: "Created", + label: "Creation date", type: "created", slug: "created", }, @@ -518,7 +517,7 @@ export const STATIC_CUSTOMER_OPTIONS: LeftOperand[] = [ export const STATIC_PRODUCT_TYPES_OPTIONS: LeftOperand[] = [ { value: "configurable", - label: "Configurable", + label: "Has variant attributes", type: "configurable", slug: "configurable", }, @@ -546,12 +545,6 @@ export const STATIC_ATTRIBUTES_OPTIONS: LeftOperand[] = [ type: "filterableInStorefront", slug: "filterableInStorefront", }, - { - value: "filterableInDashboard", - label: "Filterable in Dashboard", - type: "filterableInDashboard", - slug: "filterableInDashboard", - }, { value: "isVariantOnly", label: "Variant only", @@ -560,13 +553,13 @@ export const STATIC_ATTRIBUTES_OPTIONS: LeftOperand[] = [ }, { value: "valueRequired", - label: "Value Required", + label: "Is required", type: "valueRequired", slug: "valueRequired", }, { value: "visibleInStorefront", - label: "Visible on Product Page in Storefront", + label: "Visible in Storefront", type: "visibleInStorefront", slug: "visibleInStorefront", }, diff --git a/src/components/ConditionalFilter/queryVariables.test.ts b/src/components/ConditionalFilter/queryVariables.test.ts index 10dfefd05e8..19e627dfe0a 100644 --- a/src/components/ConditionalFilter/queryVariables.test.ts +++ b/src/components/ConditionalFilter/queryVariables.test.ts @@ -673,27 +673,10 @@ describe("ConditionalFilter / queryVariables / creatAttributesQueryVariables", ( false, ); - const isFilterableInDashboardFilterElement = new FilterElement( - new ExpressionValue("filterableInDashboard", "Filterable", "filterableInDashboard"), - new Condition( - ConditionOptions.fromStaticElementName("filterableInDashboard"), - new ConditionSelected("true", { type: "select", label: "is", value: "input-1" }, [], false), - false, - ), - false, - ); - - const filters: FilterContainer = [ - channelFilterElemen, - "AND", - typeFilterElement, - "AND", - isFilterableInDashboardFilterElement, - ]; + const filters: FilterContainer = [channelFilterElemen, "AND", typeFilterElement]; const expectedOutput = { channel: "default-channel", type: "PRODUCT_TYPE", - filterableInDashboard: true, }; // Act const result = creatAttributesQueryVariables(filters); diff --git a/src/components/ConditionalFilter/queryVariables.ts b/src/components/ConditionalFilter/queryVariables.ts index b66468991c8..a809c7ee534 100644 --- a/src/components/ConditionalFilter/queryVariables.ts +++ b/src/components/ConditionalFilter/queryVariables.ts @@ -2,6 +2,7 @@ import { AttributeFilterInput, AttributeInput, CollectionFilterInput, + CollectionPublished, CustomerFilterInput, DateRangeInput, DateTimeFilterInput, @@ -11,6 +12,7 @@ import { GlobalIdFilterInput, OrderDraftFilterInput, PageFilterInput, + ProductTypeConfigurable, ProductTypeFilterInput, ProductWhereInput, PromotionWhereInput, @@ -351,6 +353,8 @@ export const createCollectionsQueryVariables = (value: FilterContainer): Collect return value.reduce((p, c) => { if (typeof c === "string" || Array.isArray(c)) return p; + const value = mapStaticQueryPartToLegacyVariables(createStaticQueryPart(c.condition.selected)); + if (c.value.type === "metadata") { p.metadata = p.metadata || []; @@ -361,9 +365,13 @@ export const createCollectionsQueryVariables = (value: FilterContainer): Collect return p; } - p[c.value.value as keyof CollectionFilterInput] = mapStaticQueryPartToLegacyVariables( - createStaticQueryPart(c.condition.selected), - ); + if (c.value.type === "published") { + p["published"] = value === true ? CollectionPublished.PUBLISHED : CollectionPublished.HIDDEN; + + return p; + } + + p[c.value.value as keyof CollectionFilterInput] = value; return p; }, {} as CollectionQueryVars); @@ -383,6 +391,13 @@ export const createProductTypesQueryVariables = ( return p; } + if (c.value.type === "configurable") { + p["configurable"] = + value === true ? ProductTypeConfigurable.CONFIGURABLE : ProductTypeConfigurable.SIMPLE; + + return p; + } + (p[c.value.value as keyof ProductTypeFilterInput] as ProductTypeFilterInput) = value; return p; diff --git a/src/giftCards/GiftCardsList/GiftCardListSearchAndFilters/messages.ts b/src/giftCards/GiftCardsList/GiftCardListSearchAndFilters/messages.ts index a8984ae6111..5273f10c586 100644 --- a/src/giftCards/GiftCardsList/GiftCardListSearchAndFilters/messages.ts +++ b/src/giftCards/GiftCardsList/GiftCardListSearchAndFilters/messages.ts @@ -15,8 +15,8 @@ export const giftCardListFilterErrorMessages = defineMessages({ export const giftCardListSearchAndFiltersMessages = defineMessages({ searchPlaceholder: { - id: "h2hEKV", - defaultMessage: "Search gift cards, e.g {exampleGiftCardCode}", + id: "jY80Gs", + defaultMessage: "Search by code, e.g {exampleGiftCardCode}", description: "search gift card placeholder", }, defaultTabLabel: {