Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old select fields after migration #5035

Merged
merged 51 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a1a1c35
Replace old SingleSelectField with new in AttributeDetails
poulch Jul 3, 2024
6437ef2
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 4, 2024
98be8f2
Replace Select in NumericUnits
poulch Jul 4, 2024
0447158
Replace Select in ChannelDeleteDialog
poulch Jul 4, 2024
f277763
Replace Select in AppChannelSelect
poulch Jul 4, 2024
38091ef
Replace Select in FilterSingleSelectField
poulch Jul 4, 2024
6a57123
Replace Select in PhoneField
poulch Jul 4, 2024
20aab25
Replace rest Select
poulch Jul 4, 2024
72657c4
Migrade change shipping dialog, fix tests
poulch Jul 4, 2024
07c8375
Change locators
poulch Jul 5, 2024
5885796
Fix add shipping method
poulch Jul 5, 2024
a171ff3
Replace empty strings
poulch Jul 5, 2024
53775dc
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 5, 2024
2736840
Fix attrb and tax select locators
poulch Jul 5, 2024
9c7d0ee
Update attributeReferencesEntities
poulch Jul 5, 2024
585562b
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 5, 2024
386c998
Fix tag page
poulch Jul 5, 2024
9d0338d
Fix home page channel select test
poulch Jul 5, 2024
6443fb7
Add changeset
poulch Jul 5, 2024
4046f96
Fix ts
poulch Jul 5, 2024
5b2fb7e
Replace multiselect
poulch Jul 6, 2024
fc856c1
Fix AttributeDetails select
poulch Jul 7, 2024
978d599
Fix NumericUnits select
poulch Jul 7, 2024
8369c8b
Add new action dialog
poulch Jul 8, 2024
1000bd4
Change ActionModal in ChannelDeleteDialog and rename name
poulch Jul 8, 2024
946a9e4
Set const width to AppChannelSelect
poulch Jul 8, 2024
2c9bc6f
Add now border
poulch Jul 8, 2024
915d7dd
Adjust GiftCardSendToCustomer
poulch Jul 8, 2024
b789923
Adjust OrderShippingMethodEditDialog
poulch Jul 8, 2024
5471009
Adjust TaxAppLabel
poulch Jul 8, 2024
9608a67
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 8, 2024
ebd02a5
Extract messages
poulch Jul 8, 2024
6c577da
Update changeset
poulch Jul 8, 2024
b5e2139
Merge branch 'merx-644-replace-old-select' of github.com:saleor/saleo…
poulch Jul 8, 2024
6e7a5fe
Fix typo
poulch Jul 8, 2024
659edeb
Fix OrderShippingMethodEditDialog
poulch Jul 8, 2024
49a358b
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 8, 2024
e9fbfe8
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 8, 2024
dd06b0d
Merge branch 'merx-644-replace-old-select' of github.com:saleor/saleo…
poulch Jul 8, 2024
211963c
Remove not used components
poulch Jul 8, 2024
e7e8ddc
Use Option type
poulch Jul 8, 2024
6bb268a
Merge branch 'main' into merx-644-replace-old-select
poulch Jul 9, 2024
2374b24
Merge branch 'merx-644-replace-old-select' into remove-legacy-dropdowns
poulch Jul 9, 2024
409e72b
Merge branch 'main' into merx-662-migrate-dialog-components
poulch Jul 16, 2024
63e7fcd
Merge branch 'main' into remove-legacy-dropdowns
poulch Jul 22, 2024
7b9b7e3
Add changeset
poulch Jul 22, 2024
4a56dba
Merge branch 'main' into remove-legacy-dropdowns
poulch Jul 25, 2024
3cf9278
Merge branch 'main' into remove-legacy-dropdowns
poulch Jul 25, 2024
b95007d
Extract messages
poulch Jul 25, 2024
5662557
Merge branch 'remove-legacy-dropdowns' of github.com:saleor/saleor-da…
poulch Jul 25, 2024
8da9b7e
Merge branch 'main' into remove-legacy-dropdowns
poulch Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-apricots-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

The migrated dropdown components and there types no longer exist within the codebase
3 changes: 0 additions & 3 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,6 @@
"context": "Transaction capture button - charge preauthorized transaction amount",
"string": "Capture"
},
"450Fty": {
"string": "None"
},
"45aV8u": {
"context": "gift card bulk create modal bottom explanation",
"string": "After creation Saleor will create a list of gift card codes that you will be able to download."
Expand Down
10 changes: 5 additions & 5 deletions src/attributes/components/AttributeDetails/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Choice } from "@dashboard/components/SingleSelectField";
import { MeasurementUnitsEnum } from "@dashboard/graphql";
import { Option } from "@saleor/macaw-ui-next";
import React from "react";
import { IntlShape, MessageDescriptor } from "react-intl";

Expand Down Expand Up @@ -56,7 +56,7 @@ export const getMeasurementUnitMessage = (
: formatMessage(message as MessageDescriptor);
};

export const unitSystemChoices: Array<Choice<UnitSystem, MessageDescriptor>> = [
export const unitSystemChoices = [
{
label: M.unitSystemMessages.metric,
value: "metric",
Expand All @@ -67,7 +67,7 @@ export const unitSystemChoices: Array<Choice<UnitSystem, MessageDescriptor>> = [
},
];

export const unitTypeChoices: Array<Choice<UnitType, MessageDescriptor>> = [
export const unitTypeChoices = [
{
label: M.unitTypeMessages.volume,
value: "volume",
Expand Down Expand Up @@ -149,7 +149,7 @@ export const getUnitChoices = (
formatMessage: IntlShape["formatMessage"],
): {
[key in UnitSystem]: {
[key in UnitType]: Array<Choice<MeasurementUnitsEnum>>;
[key in UnitType]: Option[];
};
} =>
Object.entries(unitMapping).reduce(
Expand All @@ -160,6 +160,6 @@ export const getUnitChoices = (
{},
) as {
[key in UnitSystem]: {
[key in UnitType]: Array<Choice<MeasurementUnitsEnum>>;
[key in UnitType]: Option[];
};
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import ActionDialog from "@dashboard/components/ActionDialog";
import { Combobox } from "@dashboard/components/Combobox";
import { ConfirmButtonTransitionState } from "@dashboard/components/ConfirmButton";
import { Choice } from "@dashboard/components/SingleSelectField";
import useChoiceSearch from "@dashboard/hooks/useChoiceSearch";
import useModalDialogOpen from "@dashboard/hooks/useModalDialogOpen";
import useStateFromProps from "@dashboard/hooks/useStateFromProps";
import { Option } from "@saleor/macaw-ui-next";
import React from "react";
import { useIntl } from "react-intl";

import { messages } from "./messages";

export interface ChannelPickerDialogProps {
channelsChoices: Array<Choice<string, string>>;
channelsChoices: Option[];
confirmButtonState: ConfirmButtonTransitionState;
defaultChoice: string;
open: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Form from "@dashboard/components/Form";
import { DetailPageLayout } from "@dashboard/components/Layouts";
import RequirePermissions from "@dashboard/components/RequirePermissions";
import { Savebar } from "@dashboard/components/Savebar";
import { SingleAutocompleteChoiceType } from "@dashboard/components/SingleAutocompleteSelectField";
import {
AllocationStrategyEnum,
ChannelDetailsFragment,
Expand All @@ -35,6 +34,7 @@ import useStateFromProps from "@dashboard/hooks/useStateFromProps";
import { FetchMoreProps, RelayToFlat } from "@dashboard/types";
import createSingleAutocompleteSelectHandler from "@dashboard/utils/handlers/singleAutocompleteSelectChangeHandler";
import { mapCountriesToChoices } from "@dashboard/utils/maps";
import { Option } from "@saleor/macaw-ui-next";
import React, { useState } from "react";
import { useIntl } from "react-intl";

Expand All @@ -51,7 +51,7 @@ import { ChannelShippingZones, ChannelWarehouses } from "./types";

export interface ChannelDetailsPageProps<TErrors extends ChannelErrorFragment[]> {
channel?: ChannelDetailsFragment;
currencyCodes?: SingleAutocompleteChoiceType[];
currencyCodes?: Option[];
disabled: boolean;
disabledStatus?: boolean;
errors: ChannelErrorFragment[];
Expand Down
4 changes: 2 additions & 2 deletions src/collections/components/CollectionListPage/filters.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { IFilter } from "@dashboard/components/Filter";
import { MultiAutocompleteChoiceType } from "@dashboard/components/MultiAutocompleteSelectField";
import { CollectionPublished } from "@dashboard/graphql";
import { commonMessages } from "@dashboard/intl";
import { FilterOpts } from "@dashboard/types";
import { createOptionsField } from "@dashboard/utils/filters/fields";
import { Option } from "@saleor/macaw-ui-next";
import { defineMessages, IntlShape } from "react-intl";

export interface CollectionListFilterOpts {
status: FilterOpts<CollectionPublished>;
channel: FilterOpts<string> & { choices: MultiAutocompleteChoiceType[] };
channel: FilterOpts<string> & { choices: Option[] };
}

export enum CollectionFilterKeys {
Expand Down
6 changes: 3 additions & 3 deletions src/collections/views/CollectionList/filters.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createFilterStructure } from "@dashboard/collections/components/CollectionListPage";
import { CollectionListUrlFilters } from "@dashboard/collections/urls";
import { MultiAutocompleteChoiceType } from "@dashboard/components/MultiAutocompleteSelectField";
import { CollectionPublished } from "@dashboard/graphql";
import { FilterOpts } from "@dashboard/types";
import { getFilterQueryParams } from "@dashboard/utils/filters";
import { stringifyQs } from "@dashboard/utils/urls";
import { Option } from "@saleor/macaw-ui-next";
import { getExistingKeys, setFilterOptsStatus } from "@test/filters";
import { config } from "@test/intl";
import { createIntl } from "react-intl";
Expand Down Expand Up @@ -35,7 +35,7 @@ describe("Filtering URL params", () => {
value: CollectionPublished.PUBLISHED,
},
channel: undefined as unknown as FilterOpts<string> & {
choices: MultiAutocompleteChoiceType[];
choices: Option[];
},
});

Expand All @@ -51,7 +51,7 @@ describe("Filtering URL params", () => {
value: CollectionPublished.PUBLISHED,
},
channel: undefined as unknown as FilterOpts<string> & {
choices: MultiAutocompleteChoiceType[];
choices: Option[];
},
});
const filterQueryParams = getFilterQueryParams(
Expand Down
4 changes: 2 additions & 2 deletions src/collections/views/CollectionList/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
CollectionListFilterOpts,
} from "@dashboard/collections/components/CollectionListPage";
import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter";
import { SingleAutocompleteChoiceType } from "@dashboard/components/SingleAutocompleteSelectField";
import { CollectionFilterInput, CollectionPublished } from "@dashboard/graphql";
import { findValueInEnum, maybe } from "@dashboard/misc";
import { Option } from "@saleor/macaw-ui-next";

import {
createFilterTabUtils,
Expand All @@ -24,7 +24,7 @@ export const COLLECTION_FILTERS_KEY = "collectionFilters";

export function getFilterOpts(
params: CollectionListUrlFilters,
channels: SingleAutocompleteChoiceType[],
channels: Option[],
): CollectionListFilterOpts {
return {
channel: {
Expand Down
9 changes: 4 additions & 5 deletions src/components/Attributes/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @ts-strict-ignore
import { AttributeInput } from "@dashboard/components/Attributes/Attributes";
import { FileChoiceType } from "@dashboard/components/FileUploadField";
import { MultiAutocompleteChoiceType } from "@dashboard/components/MultiAutocompleteSelectField";
import { SingleAutocompleteChoiceType } from "@dashboard/components/SingleAutocompleteSelectField";
import { SortableChipsFieldValueType } from "@dashboard/components/SortableChipsField";
import {
AttributeValueFragment,
Expand All @@ -12,9 +10,10 @@ import {
import { getProductErrorMessage } from "@dashboard/utils/errors";
import getPageErrorMessage from "@dashboard/utils/errors/page";
import { OutputData } from "@editorjs/editorjs";
import { Option } from "@saleor/macaw-ui-next";
import { IntlShape } from "react-intl";

export function getSingleChoices(values: AttributeValueFragment[]): SingleAutocompleteChoiceType[] {
export function getSingleChoices(values: AttributeValueFragment[]): Option[] {
return values.map(value => ({
label: value.name,
value: value.slug,
Expand Down Expand Up @@ -90,7 +89,7 @@ export function getReferenceDisplayValue(attribute: AttributeInput): SortableChi
});
}

export function getMultiChoices(values: AttributeValueFragment[]): MultiAutocompleteChoiceType[] {
export function getMultiChoices(values: AttributeValueFragment[]): Option[] {
return values.map(value => ({
label: value.name,
value: value.slug,
Expand All @@ -112,7 +111,7 @@ export function getSingleDisplayValue(
export function getMultiDisplayValue(
attribute: AttributeInput,
attributeValues: AttributeValueFragment[],
): MultiAutocompleteChoiceType[] {
): Option[] {
if (!attribute.value) {
return [];
}
Expand Down
12 changes: 5 additions & 7 deletions src/components/Filter/FilterAutocompleteField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
import { toggle } from "@dashboard/utils/lists";
import { FormControlLabel, TextField } from "@material-ui/core";
import { makeStyles } from "@saleor/macaw-ui";
import { Text } from "@saleor/macaw-ui-next";
import { Option, Text } from "@saleor/macaw-ui-next";
import React from "react";
import { FormattedMessage } from "react-intl";

import Checkbox from "../Checkbox";
import Hr from "../Hr";
import Link from "../Link";
import { MultiAutocompleteChoiceType } from "../MultiAutocompleteSelectField";
import { FieldType, FilterFieldBaseProps } from "./types";

interface FilterAutocompleteFieldProps
Expand All @@ -19,7 +18,7 @@ interface FilterAutocompleteFieldProps
initialDisplayValues: FilterAutocompleteDisplayValues;
}

export type FilterAutocompleteDisplayValues = Record<string, MultiAutocompleteChoiceType[]>;
export type FilterAutocompleteDisplayValues = Record<string, Option[]>;

const useStyles = makeStyles(
theme => ({
Expand Down Expand Up @@ -63,14 +62,14 @@ const FilterAutocompleteField: React.FC<FilterAutocompleteFieldProps> = ({
fieldDisplayValues.every(displayValue => displayValue.value !== option.value),
);
const displayNoResults = availableOptions.length === 0 && fieldDisplayValues.length === 0;
const getUpdatedFilterValue = (option: MultiAutocompleteChoiceType) => {
const getUpdatedFilterValue = (option: Option) => {
if (filter.multiple) {
return toggle(option.value, filter.value, (a, b) => a === b);
}

return [option.value];
};
const handleChange = (option: MultiAutocompleteChoiceType) => {
const handleChange = (option: Option) => {
onFilterPropertyChange({
payload: {
name: filter.name,
Expand All @@ -89,8 +88,7 @@ const FilterAutocompleteField: React.FC<FilterAutocompleteFieldProps> = ({
});
}
};
const isValueChecked = (displayValue: MultiAutocompleteChoiceType) =>
filter.value.includes(displayValue.value);
const isValueChecked = (displayValue: Option) => filter.value.includes(displayValue.value);
const filteredValuesChecked = initialFieldDisplayValues.filter(isValueChecked);
const filteredValuesUnchecked = fieldDisplayValues.filter(
displayValue => !isValueChecked(displayValue),
Expand Down
7 changes: 2 additions & 5 deletions src/components/Filter/FilterContent/FilterContentBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { FilterDateTimeField } from "@dashboard/components/Filter/FilterContent/
import { FilterNumericField } from "@dashboard/components/Filter/FilterContent/FilterNumericField";
import { FilterSingleSelectField } from "@dashboard/components/Filter/FilterContent/FilterSingleSelectField";
import { useCommonStyles } from "@dashboard/components/Filter/FilterContent/utils";
import { MultiAutocompleteChoiceType } from "@dashboard/components/MultiAutocompleteSelectField";
import { FormControlLabel, Radio, TextField } from "@material-ui/core";
import { makeStyles } from "@saleor/macaw-ui";
import { Skeleton } from "@saleor/macaw-ui-next";
import { Option, Skeleton } from "@saleor/macaw-ui-next";
import clsx from "clsx";
import React from "react";

Expand Down Expand Up @@ -49,9 +48,7 @@ export interface FilterContentBodyProps<K extends string> {
initialAutocompleteDisplayValues: FilterAutocompleteDisplayValues;
onFilterPropertyChange: <T extends FieldType>(value: FilterReducerAction<K, T>) => void;
autocompleteDisplayValues: FilterAutocompleteDisplayValues;
setAutocompleteDisplayValues: React.Dispatch<
React.SetStateAction<Record<string, MultiAutocompleteChoiceType[]>>
>;
setAutocompleteDisplayValues: React.Dispatch<React.SetStateAction<Record<string, Option[]>>>;
}

const FilterContentBody = <K extends string = string>({
Expand Down
4 changes: 2 additions & 2 deletions src/components/Filter/FilterContent/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-strict-ignore
import { SingleAutocompleteChoiceType } from "@dashboard/components/SingleAutocompleteSelectField";
import { joinDateTime, splitDateTime } from "@dashboard/misc";
import { makeStyles } from "@saleor/macaw-ui";
import { Option } from "@saleor/macaw-ui-next";
import { IntlShape } from "react-intl";

import { FilterType } from "../types";
Expand Down Expand Up @@ -34,7 +34,7 @@ export const useCommonStyles = makeStyles(
{ name: "FilterContentBodyCommon" },
);

export function getIsFilterMultipleChoices(intl: IntlShape): SingleAutocompleteChoiceType[] {
export function getIsFilterMultipleChoices(intl: IntlShape): Option[] {
return [
{
label: intl.formatMessage({
Expand Down
6 changes: 3 additions & 3 deletions src/components/Filter/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PermissionEnum } from "@dashboard/graphql";
import { FetchMoreProps, KeyValue, SearchPageProps } from "@dashboard/types";
import { Option } from "@saleor/macaw-ui-next";
import { MessageDescriptor } from "react-intl";

import { MultiAutocompleteChoiceType } from "../MultiAutocompleteSelectField";
import { FilterDispatchFunction } from "./useFilter";

export enum FieldType {
Expand All @@ -20,7 +20,7 @@ export enum FieldType {
interface FilterElementCommonData {
active: boolean;
multiple: boolean;
options?: MultiAutocompleteChoiceType[];
options?: Option[];
}

export interface KeyValueFilterElementData {
Expand Down Expand Up @@ -48,7 +48,7 @@ export type IFilterElementMutableDataGeneric<T extends FieldType> = T extends Fi

type FilterElementCommon<K extends string = string> = {
autocomplete?: boolean;
displayValues?: MultiAutocompleteChoiceType[];
displayValues?: Option[];
group?: K;
label: string;
name: K;
Expand Down
4 changes: 2 additions & 2 deletions src/components/LinkChoice/LinkChoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import { FormChange } from "@dashboard/hooks/useForm";
import ArrowDropdown from "@dashboard/icons/ArrowDropdown";
import { ClickAwayListener, MenuItem, Paper, Popper } from "@material-ui/core";
import { Option } from "@saleor/macaw-ui-next";
import clsx from "clsx";
import { codes } from "keycode";
import React from "react";

import Link from "../Link";
import { SingleAutocompleteChoiceType } from "../SingleAutocompleteSelectField";
import { useStyles } from "./styles";

export interface LinkChoiceProps {
className?: string;
choices: SingleAutocompleteChoiceType[];
choices: Option[];
name?: string;
value: string;
onChange: FormChange;
Expand Down
Loading
Loading