Skip to content

Commit

Permalink
Improvements for filters after acceptance phase (#5420)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
poulch authored Feb 18, 2025
1 parent 83606ae commit 31f9085
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 176 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-poems-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Apply improvments for new filters so they looks align
60 changes: 28 additions & 32 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand All @@ -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"
Expand Down Expand Up @@ -5330,6 +5330,10 @@
"W6nwjo": {
"string": "Draft"
},
"W75xMz": {
"context": "attribute is visible in storefront",
"string": "Visible in storefront"
},
"W8i2Ez": {
"context": "product field",
"string": "Name"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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."
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -8164,6 +8164,10 @@
"oYGfnY": {
"string": "ZIP / Postal code"
},
"oYV+Ru": {
"context": "staff members status deactivated",
"string": "Inactive"
},
"oboeOT": {
"string": "Add following permissions"
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions src/attributes/components/AttributeListDatagrid/datagrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 5 additions & 10 deletions src/attributes/components/AttributeListDatagrid/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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: {
Expand All @@ -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: {
Expand Down
1 change: 0 additions & 1 deletion src/attributes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export enum AttributeListUrlSortField {
name = "name",
slug = "slug",
visible = "visible",
searchable = "searchable",
useInFacetedSearch = "use-in-faceted-search",
}
export type AttributeListUrlSort = Sort<AttributeListUrlSortField>;
Expand Down
2 changes: 0 additions & 2 deletions src/attributes/views/AttributeList/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/collections/views/CollectionList/CollectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export const CollectionList: React.FC<CollectionListProps> = ({ 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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface InitialAttributesState {
channels: ItemOption[];
attributeTypes: ItemOption[];
filterableInStorefront: ItemOption[];
filterableInDashboard: ItemOption[];
isVariantOnly: ItemOption[];
valueRequired: ItemOption[];
visibleInStorefront: ItemOption[];
Expand All @@ -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[] = [],
Expand Down Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const useInitialAttributesState = (): InitialAttributesAPIState => {
initialState.channels,
initialState.attributeType,
initialState.filterableInStorefront,
initialState.filterableInDashboard,
initialState.isVariantOnly,
initialState.valueRequired,
initialState.visibleInStorefront,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -22,7 +19,6 @@ export interface InitialCollectionAPIState {

export const useInitialCollectionState = (): InitialCollectionAPIState => {
const client = useApolloClient();
const intl = useIntl();

const [data, setData] = useState<InitialCollectionStateResponse>(
InitialCollectionStateResponse.empty(),
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 31f9085

Please sign in to comment.