From 8bedf7051cf8512f1fccfb4ee50d5a53d4ec6792 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Wed, 1 Oct 2025 14:23:22 +0200 Subject: [PATCH 1/9] remove old exports --- locale/defaultMessages.json | 4 - .../components/AttributeListPage/filters.ts | 2 +- .../AttributeValues/AttributeValues.tsx | 2 +- src/attributes/views/AttributeList/filters.ts | 2 +- .../components/CollectionListPage/filters.ts | 2 +- .../views/CollectionList/filters.ts | 2 +- .../AppLayout/ListFilters/ListFilters.tsx | 2 +- .../ListFilters/components/FiltersSelect.tsx | 4 +- .../AppLayout/ListFilters/utils.test.ts | 2 +- src/components/AppLayout/ListFilters/utils.ts | 2 +- src/components/Filter/Filter.tsx | 177 ------------------ .../Filter/FilterContent/FilterContent.tsx | 11 +- .../FilterContent/FilterContentBody.tsx | 4 +- .../FilterContentBodyNameField.tsx | 4 +- .../FilterContent/FilterContentHeader.tsx | 4 +- .../FilterContent/FilterDateTimeField.tsx | 3 +- .../Filter/FilterContent/FilterErrorsList.tsx | 4 +- .../FilterContent/FilterNumericField.tsx | 2 +- .../FilterContent/FilterSingleSelectField.tsx | 2 +- src/components/Filter/FilterContent/index.tsx | 2 - src/components/Filter/index.ts | 4 - src/components/Filter/utils.ts | 16 +- .../TablePagination/TablePagination.tsx | 1 - .../TablePaginationWithContext.tsx | 2 +- src/components/TablePagination/index.ts | 1 - src/components/Timeline/TimelineEvent.tsx | 1 - src/components/Timeline/TimelineNote.test.tsx | 2 +- src/components/Timeline/TimelineNote.tsx | 1 - .../components/CustomerListPage/filters.ts | 2 +- src/customers/views/CustomerList/filters.ts | 2 +- .../SaleListDatagrid/SaleListDatagrid.tsx | 158 ---------------- .../components/SaleListDatagrid/datagrid.ts | 104 ---------- .../components/SaleListDatagrid/index.tsx | 1 - .../components/SaleListDatagrid/messages.ts | 31 --- .../components/SaleListPage/filters.ts | 4 +- .../components/SaleSummary/SaleSummary.tsx | 94 ---------- src/discounts/components/SaleSummary/index.ts | 2 - .../components/SaleSummary/styles.ts | 14 -- .../components/VoucherListPage/filters.ts | 2 +- src/discounts/urls.ts | 20 +- src/discounts/views/SaleDetails/types.ts | 1 - src/discounts/views/SaleList/filters.ts | 2 +- src/discounts/views/SaleList/sort.ts | 20 -- src/discounts/views/VoucherList/filters.ts | 2 +- .../GiftCardsListDatagrid.tsx | 2 +- src/giftCards/GiftCardsList/filters.ts | 2 +- .../GiftCardListProvider.tsx | 2 +- src/hooks/useChannelsSearch.ts | 6 - src/hooks/useFilterHandlers.ts | 2 +- src/misc.ts | 8 - src/modeling/views/PageList/filters.ts | 2 +- .../components/OrderDraftListPage/filters.ts | 2 +- src/orders/views/OrderDraftList/filters.ts | 2 +- src/orders/views/OrderList/filters.ts | 2 +- src/plugins/urls.ts | 2 +- .../components/ProductTypeListPage/filters.ts | 2 +- .../views/ProductTypeList/filters.ts | 2 +- .../ProductListPage/ProductListPage.tsx | 2 +- src/products/views/ProductList/filters.ts | 2 +- src/staff/components/StaffListPage/filters.ts | 2 +- src/staff/views/StaffList/filters.ts | 2 +- src/types.ts | 2 +- src/utils/filters/fields.ts | 2 +- src/utils/filters/filters.ts | 2 +- src/utils/handlers/filterHandlers.ts | 2 +- src/utils/maps.ts | 18 -- testUtils/filters.ts | 2 +- 67 files changed, 56 insertions(+), 740 deletions(-) delete mode 100644 src/components/Filter/Filter.tsx delete mode 100644 src/components/Filter/FilterContent/index.tsx delete mode 100644 src/components/Filter/index.ts delete mode 100644 src/discounts/components/SaleListDatagrid/SaleListDatagrid.tsx delete mode 100644 src/discounts/components/SaleListDatagrid/datagrid.ts delete mode 100644 src/discounts/components/SaleListDatagrid/index.tsx delete mode 100644 src/discounts/components/SaleListDatagrid/messages.ts delete mode 100644 src/discounts/components/SaleSummary/SaleSummary.tsx delete mode 100644 src/discounts/components/SaleSummary/index.ts delete mode 100644 src/discounts/components/SaleSummary/styles.ts delete mode 100644 src/discounts/views/SaleDetails/types.ts delete mode 100644 src/discounts/views/SaleList/sort.ts diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 44bdcd5d9e1..23bef347945 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -5784,10 +5784,6 @@ "context": "edit attribute value", "string": "Edit Value" }, - "XZR590": { - "context": "sale value", - "string": "Value" - }, "XZpRr8": { "context": "btn label", "string": "Go to all products" diff --git a/src/attributes/components/AttributeListPage/filters.ts b/src/attributes/components/AttributeListPage/filters.ts index c3d36ebb5f7..0388ca95e56 100644 --- a/src/attributes/components/AttributeListPage/filters.ts +++ b/src/attributes/components/AttributeListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { commonMessages } from "@dashboard/intl"; import { FilterOpts } from "@dashboard/types"; import { createBooleanField } from "@dashboard/utils/filters/fields"; diff --git a/src/attributes/components/AttributeValues/AttributeValues.tsx b/src/attributes/components/AttributeValues/AttributeValues.tsx index a707ad5772c..8fcbbeedeed 100644 --- a/src/attributes/components/AttributeValues/AttributeValues.tsx +++ b/src/attributes/components/AttributeValues/AttributeValues.tsx @@ -1,7 +1,7 @@ import { DashboardCard } from "@dashboard/components/Card"; import ResponsiveTable from "@dashboard/components/ResponsiveTable"; import { SortableTableBody, SortableTableRow } from "@dashboard/components/SortableTable"; -import TablePagination from "@dashboard/components/TablePagination"; +import { TablePagination } from "@dashboard/components/TablePagination"; import TableRowLink from "@dashboard/components/TableRowLink"; import { AttributeInputTypeEnum, diff --git a/src/attributes/views/AttributeList/filters.ts b/src/attributes/views/AttributeList/filters.ts index d55e3668982..981e7a64a58 100644 --- a/src/attributes/views/AttributeList/filters.ts +++ b/src/attributes/views/AttributeList/filters.ts @@ -2,7 +2,7 @@ import { AttributeFilterKeys, AttributeListFilterOpts, } from "@dashboard/attributes/components/AttributeListPage"; -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { AttributeFilterInput } from "@dashboard/graphql"; import { parseBoolean } from "@dashboard/misc"; diff --git a/src/collections/components/CollectionListPage/filters.ts b/src/collections/components/CollectionListPage/filters.ts index 5305f561ff0..e2d52e876e8 100644 --- a/src/collections/components/CollectionListPage/filters.ts +++ b/src/collections/components/CollectionListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { CollectionPublished } from "@dashboard/graphql"; import { commonMessages } from "@dashboard/intl"; import { FilterOpts } from "@dashboard/types"; diff --git a/src/collections/views/CollectionList/filters.ts b/src/collections/views/CollectionList/filters.ts index 31423f6de44..4f02c18a6f4 100644 --- a/src/collections/views/CollectionList/filters.ts +++ b/src/collections/views/CollectionList/filters.ts @@ -3,7 +3,7 @@ import { CollectionFilterKeys, CollectionListFilterOpts, } from "@dashboard/collections/components/CollectionListPage"; -import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter"; +import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter/types"; import { CollectionFilterInput, CollectionPublished } from "@dashboard/graphql"; import { findValueInEnum, maybe } from "@dashboard/misc"; import { Option } from "@saleor/macaw-ui-next"; diff --git a/src/components/AppLayout/ListFilters/ListFilters.tsx b/src/components/AppLayout/ListFilters/ListFilters.tsx index 36616c8fdee..fd8f4245cde 100644 --- a/src/components/AppLayout/ListFilters/ListFilters.tsx +++ b/src/components/AppLayout/ListFilters/ListFilters.tsx @@ -1,4 +1,4 @@ -import { FilterErrorMessages, IFilter } from "@dashboard/components/Filter"; +import { FilterErrorMessages, IFilter } from "@dashboard/components/Filter/types"; import { FilterProps, SearchPageProps } from "@dashboard/types"; import { Box } from "@saleor/macaw-ui-next"; import { ReactNode } from "react"; diff --git a/src/components/AppLayout/ListFilters/components/FiltersSelect.tsx b/src/components/AppLayout/ListFilters/components/FiltersSelect.tsx index 5a39b66533b..5fd39768d22 100644 --- a/src/components/AppLayout/ListFilters/components/FiltersSelect.tsx +++ b/src/components/AppLayout/ListFilters/components/FiltersSelect.tsx @@ -1,11 +1,11 @@ // @ts-strict-ignore +import { FilterContent } from "@dashboard/components/Filter/FilterContent/FilterContent"; import { - FilterContent, FilterElement, FilterErrorMessages, IFilter, InvalidFilters, -} from "@dashboard/components/Filter"; +} from "@dashboard/components/Filter/types"; import useFilter from "@dashboard/components/Filter/useFilter"; import { extractInvalidFilters } from "@dashboard/components/Filter/utils"; import { ClickAwayListener, Grow, Popper } from "@material-ui/core"; diff --git a/src/components/AppLayout/ListFilters/utils.test.ts b/src/components/AppLayout/ListFilters/utils.test.ts index b2ca8198c1f..b91fa897290 100644 --- a/src/components/AppLayout/ListFilters/utils.test.ts +++ b/src/components/AppLayout/ListFilters/utils.test.ts @@ -1,4 +1,4 @@ -import { FilterElement, IFilter } from "@dashboard/components/Filter"; +import { FilterElement, IFilter } from "@dashboard/components/Filter/types"; import { getSelectedFilterAmount } from "./utils"; diff --git a/src/components/AppLayout/ListFilters/utils.ts b/src/components/AppLayout/ListFilters/utils.ts index 444c04c66af..e153136b7e4 100644 --- a/src/components/AppLayout/ListFilters/utils.ts +++ b/src/components/AppLayout/ListFilters/utils.ts @@ -1,4 +1,4 @@ -import { FilterElement, IFilter } from "@dashboard/components/Filter"; +import { FilterElement, IFilter } from "@dashboard/components/Filter/types"; export const getSelectedFilterAmount = ( menu: IFilter, diff --git a/src/components/Filter/Filter.tsx b/src/components/Filter/Filter.tsx deleted file mode 100644 index da9673d125d..00000000000 --- a/src/components/Filter/Filter.tsx +++ /dev/null @@ -1,177 +0,0 @@ -// @ts-strict-ignore -import { ClickAwayListener, Grow, Popper } from "@material-ui/core"; -import { alpha } from "@material-ui/core/styles"; -import { Button, makeStyles } from "@saleor/macaw-ui"; -import { Text, vars } from "@saleor/macaw-ui-next"; -import clsx from "clsx"; -import { useMemo, useRef, useState } from "react"; -import { FormattedMessage } from "react-intl"; - -import { FilterContent } from "."; -import { FilterElement, FilterErrorMessages, IFilter, InvalidFilters } from "./types"; -import useFilter from "./useFilter"; -import { extractInvalidFilters, getSelectedFiltersAmount } from "./utils"; - -interface FilterProps { - currencySymbol?: string; - errorMessages?: FilterErrorMessages; - menu: IFilter; - onFilterAdd: (filter: Array>) => void; - onFilterAttributeFocus?: (id?: string) => void; -} - -const useStyles = makeStyles( - theme => ({ - addFilterButton: { - "&$filterButton": { - "&:hover, &:focus": { - backgroundColor: alpha(theme.palette.primary.main, 0.1), - }, - backgroundColor: theme.palette.background.paper, - border: `1px solid ${theme.palette.primary.main}`, - cursor: "pointer", - marginBottom: 0, - marginRight: theme.spacing(2), - marginTop: 0, - transition: theme.transitions.duration.short + "ms", - }, - }, - addFilterButtonActive: { - "&$addFilterButton": { - backgroundColor: alpha(theme.palette.primary.main, 0.1), - }, - }, - addFilterIcon: { - transition: theme.transitions.duration.short + "ms", - }, - addFilterText: { - color: theme.palette.primary.main, - fontSize: 14, - fontWeight: 600 as const, - }, - filterButton: { - padding: theme.spacing(1, 2), - marginRight: theme.spacing(2), - }, - paper: { - "& p": { - paddingBottom: 10, - }, - marginTop: theme.spacing(2), - padding: theme.spacing(2), - width: 240, - }, - popover: { - backgroundColor: vars.colors.background.default1, - overflowY: "scroll", - boxShadow: `0px 6px 11px 9px ${theme.palette.divider}`, - height: 450, - width: 376, - zIndex: 3, - }, - rotate: { - transform: "rotate(180deg)", - }, - separator: { - backgroundColor: theme.palette.primary.main, - display: "inline-block", - height: 14, - margin: theme.spacing(0, 1.5, 0, 1), - width: 1, - }, - }), - { name: "Filter" }, -); -const Filter = (props: FilterProps) => { - const { currencySymbol, menu, onFilterAdd, onFilterAttributeFocus, errorMessages } = props; - const classes = useStyles(props); - const anchor = useRef(); - const [isFilterMenuOpened, setFilterMenuOpened] = useState(false); - const [filterErrors, setFilterErrors] = useState>({}); - const [data, dispatch, reset] = useFilter(menu); - const isFilterActive = menu.some(filterElement => filterElement.active); - const selectedFilterAmount = useMemo(() => getSelectedFiltersAmount(menu, data), [data, menu]); - const handleSubmit = () => { - const invalidFilters = extractInvalidFilters(data, menu); - - if (Object.keys(invalidFilters).length > 0) { - setFilterErrors(invalidFilters); - - return; - } - - setFilterErrors({}); - onFilterAdd(data); - setFilterMenuOpened(false); - }; - const handleClear = () => { - reset(); - setFilterErrors({}); - }; - - return ( - { - if ((event.target as HTMLElement).getAttribute("role") !== "option") { - setFilterMenuOpened(false); - } - }} - mouseEvent="onMouseUp" - > -
- - - {() => ( - - - - )} - -
-
- ); -}; - -Filter.displayName = "Filter"; -export default Filter; diff --git a/src/components/Filter/FilterContent/FilterContent.tsx b/src/components/Filter/FilterContent/FilterContent.tsx index 93056ceae72..b15ea8de0a6 100644 --- a/src/components/Filter/FilterContent/FilterContent.tsx +++ b/src/components/Filter/FilterContent/FilterContent.tsx @@ -9,10 +9,10 @@ import { useState } from "react"; import { FilterAutocompleteDisplayValues } from "../FilterAutocompleteField"; import { FilterReducerAction } from "../reducer"; import { FieldType, FilterElement, FilterErrorMessages, IFilter, InvalidFilters } from "../types"; -import FilterContentBody, { FilterContentBodyProps } from "./FilterContentBody"; -import FilterContentBodyNameField from "./FilterContentBodyNameField"; -import FilterContentHeader from "./FilterContentHeader"; -import FilterErrorsList from "./FilterErrorsList"; +import { FilterContentBody, FilterContentBodyProps } from "./FilterContentBody"; +import { FilterContentBodyNameField } from "./FilterContentBodyNameField"; +import { FilterContentHeader } from "./FilterContentHeader"; +import { FilterErrorsList } from "./FilterErrorsList"; const useExpanderStyles = makeStyles( theme => ({ @@ -69,7 +69,7 @@ interface FilterContentProps { errorMessages?: FilterErrorMessages; } -const FilterContent = ({ +export const FilterContent = ({ currencySymbol, errors, errorMessages, @@ -240,4 +240,3 @@ const FilterContent = ({ }; FilterContent.displayName = "FilterContent"; -export default FilterContent; diff --git a/src/components/Filter/FilterContent/FilterContentBody.tsx b/src/components/Filter/FilterContent/FilterContentBody.tsx index 60a1694abd4..90cfa8db43e 100644 --- a/src/components/Filter/FilterContent/FilterContentBody.tsx +++ b/src/components/Filter/FilterContent/FilterContentBody.tsx @@ -51,7 +51,7 @@ export interface FilterContentBodyProps { setAutocompleteDisplayValues: React.Dispatch>>; } -const FilterContentBody = ({ +export const FilterContentBody = ({ filter, children, currencySymbol, @@ -164,5 +164,3 @@ const FilterContentBody = ({ ); }; - -export default FilterContentBody; diff --git a/src/components/Filter/FilterContent/FilterContentBodyNameField.tsx b/src/components/Filter/FilterContent/FilterContentBodyNameField.tsx index 9d334b808fa..90f2468831d 100644 --- a/src/components/Filter/FilterContent/FilterContentBodyNameField.tsx +++ b/src/components/Filter/FilterContent/FilterContentBodyNameField.tsx @@ -21,7 +21,7 @@ interface FilterContentBodyNameFieldProps { onFilterPropertyChange: FilterDispatchFunction; } -const FilterContentBodyNameField = ({ +export const FilterContentBodyNameField = ({ filter, onFilterPropertyChange, }: FilterContentBodyNameFieldProps) => { @@ -50,5 +50,3 @@ const FilterContentBodyNameField = ({ ); }; - -export default FilterContentBodyNameField; diff --git a/src/components/Filter/FilterContent/FilterContentHeader.tsx b/src/components/Filter/FilterContent/FilterContentHeader.tsx index 3f011fdb89f..dc9e438a631 100644 --- a/src/components/Filter/FilterContent/FilterContentHeader.tsx +++ b/src/components/Filter/FilterContent/FilterContentHeader.tsx @@ -31,7 +31,7 @@ interface FilterContentHeaderProps { onClear: () => void; } -const FilterContentHeader = ({ onClear }: FilterContentHeaderProps) => { +export const FilterContentHeader = ({ onClear }: FilterContentHeaderProps) => { const classes = useStyles({}); return ( @@ -55,5 +55,3 @@ const FilterContentHeader = ({ onClear }: FilterContentHeaderProps) => { ); }; - -export default FilterContentHeader; diff --git a/src/components/Filter/FilterContent/FilterDateTimeField.tsx b/src/components/Filter/FilterContent/FilterDateTimeField.tsx index 070e98616fc..25d8fa0df73 100644 --- a/src/components/Filter/FilterContent/FilterDateTimeField.tsx +++ b/src/components/Filter/FilterContent/FilterDateTimeField.tsx @@ -1,6 +1,7 @@ // @ts-strict-ignore -import { FieldType, FilterFieldBaseProps } from "@dashboard/components/Filter"; + import Arrow from "@dashboard/components/Filter/Arrow"; +import { FieldType, FilterFieldBaseProps } from "@dashboard/components/Filter/types"; import { splitDateTime } from "@dashboard/misc"; import { TextField } from "@material-ui/core"; import { FormattedMessage } from "react-intl"; diff --git a/src/components/Filter/FilterContent/FilterErrorsList.tsx b/src/components/Filter/FilterContent/FilterErrorsList.tsx index 038f754ac7b..4602c4b50ef 100644 --- a/src/components/Filter/FilterContent/FilterErrorsList.tsx +++ b/src/components/Filter/FilterContent/FilterErrorsList.tsx @@ -40,7 +40,7 @@ interface FilterErrorsListProps { errorMessages?: FilterErrorMessages; } -const FilterErrorsList = ({ +export const FilterErrorsList = ({ filter: { dependencies }, errors = [], errorMessages, @@ -79,5 +79,3 @@ const FilterErrorsList = ({ ); }; - -export default FilterErrorsList; diff --git a/src/components/Filter/FilterContent/FilterNumericField.tsx b/src/components/Filter/FilterContent/FilterNumericField.tsx index a82e9ee3e37..bdf7954ebfc 100644 --- a/src/components/Filter/FilterContent/FilterNumericField.tsx +++ b/src/components/Filter/FilterContent/FilterNumericField.tsx @@ -1,5 +1,5 @@ -import { FieldType, FilterFieldBaseProps } from "@dashboard/components/Filter"; import Arrow from "@dashboard/components/Filter/Arrow"; +import { FieldType, FilterFieldBaseProps } from "@dashboard/components/Filter/types"; import { TextField } from "@material-ui/core"; import { FormattedMessage } from "react-intl"; diff --git a/src/components/Filter/FilterContent/FilterSingleSelectField.tsx b/src/components/Filter/FilterContent/FilterSingleSelectField.tsx index 6a23d37215c..93bdd9e4ae2 100644 --- a/src/components/Filter/FilterContent/FilterSingleSelectField.tsx +++ b/src/components/Filter/FilterContent/FilterSingleSelectField.tsx @@ -1,6 +1,6 @@ // @ts-strict-ignore -import { FilterFieldBaseProps, FilterType } from "@dashboard/components/Filter"; import { getIsFilterMultipleChoices } from "@dashboard/components/Filter/FilterContent/utils"; +import { FilterFieldBaseProps, FilterType } from "@dashboard/components/Filter/types"; import FormSpacer from "@dashboard/components/FormSpacer"; import { Select } from "@dashboard/components/Select"; import { useIntl } from "react-intl"; diff --git a/src/components/Filter/FilterContent/index.tsx b/src/components/Filter/FilterContent/index.tsx deleted file mode 100644 index 21dd6c64bc3..00000000000 --- a/src/components/Filter/FilterContent/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./FilterContent"; -export { default } from "./FilterContent"; diff --git a/src/components/Filter/index.ts b/src/components/Filter/index.ts deleted file mode 100644 index 621aae4458d..00000000000 --- a/src/components/Filter/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./Filter"; -export { default as FilterContent } from "./FilterContent"; -export * from "./FilterContent"; -export * from "./types"; diff --git a/src/components/Filter/utils.ts b/src/components/Filter/utils.ts index db2eaf83841..8c423f0eeb8 100644 --- a/src/components/Filter/utils.ts +++ b/src/components/Filter/utils.ts @@ -1,7 +1,7 @@ // @ts-strict-ignore import compact from "lodash/compact"; -import { FieldType, FilterElement, IFilter, InvalidFilters, ValidationErrorCode } from "./types"; +import { FieldType, FilterElement, InvalidFilters, ValidationErrorCode } from "./types"; export const getByName = (nameToCompare: string) => (obj: { name: string }) => obj.name === nameToCompare; @@ -104,17 +104,3 @@ export const extractInvalidFilters = function ( }; }, {} as InvalidFilters); }; - -export const getSelectedFiltersAmount = ( - menu: IFilter, - data: Array>, -) => - menu.reduce((acc, filterElement) => { - const dataFilterElement = data.find(({ name }) => name === filterElement.name); - - if (!dataFilterElement) { - return acc; - } - - return acc + (dataFilterElement.active ? 1 : 0); - }, 0); diff --git a/src/components/TablePagination/TablePagination.tsx b/src/components/TablePagination/TablePagination.tsx index ec68b87cbe6..49df680b3af 100644 --- a/src/components/TablePagination/TablePagination.tsx +++ b/src/components/TablePagination/TablePagination.tsx @@ -94,4 +94,3 @@ export const TablePagination = ({ }; TablePagination.displayName = "TablePagination"; -export default TablePagination; diff --git a/src/components/TablePagination/TablePaginationWithContext.tsx b/src/components/TablePagination/TablePaginationWithContext.tsx index baa23883af9..21c47cbf33a 100644 --- a/src/components/TablePagination/TablePaginationWithContext.tsx +++ b/src/components/TablePagination/TablePaginationWithContext.tsx @@ -1,7 +1,7 @@ // @ts-strict-ignore import { usePaginatorContext } from "@dashboard/hooks/usePaginator"; -import TablePagination, { PaginationProps } from "./TablePagination"; +import { PaginationProps, TablePagination } from "./TablePagination"; type TablePaginationWithContextProps = Omit< PaginationProps, diff --git a/src/components/TablePagination/index.ts b/src/components/TablePagination/index.ts index b9642402ecd..f775619e62a 100644 --- a/src/components/TablePagination/index.ts +++ b/src/components/TablePagination/index.ts @@ -1,3 +1,2 @@ -export { default } from "./TablePagination"; export * from "./TablePagination"; export * from "./TablePaginationWithContext"; diff --git a/src/components/Timeline/TimelineEvent.tsx b/src/components/Timeline/TimelineEvent.tsx index 0b9a99a7d2d..4027d51a090 100644 --- a/src/components/Timeline/TimelineEvent.tsx +++ b/src/components/Timeline/TimelineEvent.tsx @@ -63,4 +63,3 @@ export const TimelineEvent = (props: TimelineEventProps) => { ); }; TimelineEvent.displayName = "TimelineEvent"; -export default TimelineEvent; diff --git a/src/components/Timeline/TimelineNote.test.tsx b/src/components/Timeline/TimelineNote.test.tsx index 05d56f774a6..d2501a1aa9a 100644 --- a/src/components/Timeline/TimelineNote.test.tsx +++ b/src/components/Timeline/TimelineNote.test.tsx @@ -3,7 +3,7 @@ import Wrapper from "@test/wrapper"; import { act, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import TimelineNote from "./TimelineNote"; +import { TimelineNote } from "./TimelineNote"; const wrapperFriendlyDate = new Date("2018-08-07T14:30:40+00:00").toISOString(); diff --git a/src/components/Timeline/TimelineNote.tsx b/src/components/Timeline/TimelineNote.tsx index 467b0e3c191..15b5e54651c 100644 --- a/src/components/Timeline/TimelineNote.tsx +++ b/src/components/Timeline/TimelineNote.tsx @@ -156,4 +156,3 @@ export const TimelineNote = ({ ); }; TimelineNote.displayName = "TimelineNote"; -export default TimelineNote; diff --git a/src/customers/components/CustomerListPage/filters.ts b/src/customers/components/CustomerListPage/filters.ts index e1be0295e50..70b6919177c 100644 --- a/src/customers/components/CustomerListPage/filters.ts +++ b/src/customers/components/CustomerListPage/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { hasPermissions } from "@dashboard/components/RequirePermissions"; import { PermissionEnum, UserFragment } from "@dashboard/graphql"; import { FilterOpts, MinMax } from "@dashboard/types"; diff --git a/src/customers/views/CustomerList/filters.ts b/src/customers/views/CustomerList/filters.ts index 1228413956f..e9adb4d9b36 100644 --- a/src/customers/views/CustomerList/filters.ts +++ b/src/customers/views/CustomerList/filters.ts @@ -1,4 +1,4 @@ -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { CustomerFilterKeys, CustomerListFilterOpts, diff --git a/src/discounts/components/SaleListDatagrid/SaleListDatagrid.tsx b/src/discounts/components/SaleListDatagrid/SaleListDatagrid.tsx deleted file mode 100644 index 3f750e8a3e9..00000000000 --- a/src/discounts/components/SaleListDatagrid/SaleListDatagrid.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import { ColumnPicker } from "@dashboard/components/Datagrid/ColumnPicker/ColumnPicker"; -import { useColumns } from "@dashboard/components/Datagrid/ColumnPicker/useColumns"; -import Datagrid from "@dashboard/components/Datagrid/Datagrid"; -import { - DatagridChangeStateContext, - useDatagridChangeState, -} from "@dashboard/components/Datagrid/hooks/useDatagridChange"; -import { TablePaginationWithContext } from "@dashboard/components/TablePagination"; -import { commonTooltipMessages } from "@dashboard/components/TooltipTableCellHeader/messages"; -import { SaleListUrlSortField, saleUrl } from "@dashboard/discounts/urls"; -import { SaleFragment } from "@dashboard/graphql"; -import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState"; -import useLocale from "@dashboard/hooks/useLocale"; -import { ChannelProps, ListProps, SortPage } from "@dashboard/types"; -import { Item } from "@glideapps/glide-data-grid"; -import { Box } from "@saleor/macaw-ui-next"; -import { useCallback, useMemo } from "react"; -import { useIntl } from "react-intl"; - -import { canBeSorted } from "../../views/SaleList/sort"; -import { createGetCellContent, salesListStaticColumnsAdapter } from "./datagrid"; -import { messages } from "./messages"; - -interface SaleListDatagridProps extends ListProps, SortPage, ChannelProps { - sales: SaleFragment[]; - onSelectSaleIds: (ids: number[], clearSelection: () => void) => void; - onRowClick: (id: string) => void; - hasRowHover?: boolean; -} - -export const SaleListDatagrid = ({ - disabled, - onSort, - sales, - selectedChannelId, - sort, - filterDependency, - onUpdateListSettings, - onSelectSaleIds, - onRowClick, - hasRowHover = true, - settings, -}: SaleListDatagridProps) => { - const intl = useIntl(); - const { locale } = useLocale(); - const datagrid = useDatagridChangeState(); - const collectionListStaticColumns = useMemo( - () => salesListStaticColumnsAdapter(intl, sort), - [intl, sort], - ); - const onColumnChange = useCallback( - (picked: string[]) => { - if (onUpdateListSettings) { - onUpdateListSettings("columns", picked.filter(Boolean)); - } - }, - [onUpdateListSettings], - ); - const { handlers, visibleColumns, staticColumns, selectedColumns, recentlyAddedColumn } = - useColumns({ - gridName: "sale_list", - staticColumns: collectionListStaticColumns, - selectedColumns: settings?.columns ?? [], - onSave: onColumnChange, - }); - const getCellContent = useCallback( - createGetCellContent({ - sales, - columns: visibleColumns, - locale, - selectedChannelId, - }), - [sales, selectedChannelId, locale, visibleColumns], - ); - const handleRowClick = useCallback( - ([_, row]: Item) => { - if (!onRowClick) { - return; - } - - const rowData: SaleFragment = sales[row]; - - onRowClick(rowData.id); - }, - [onRowClick, sales], - ); - const handleRowAnchor = useCallback(([, row]: Item) => saleUrl(sales[row].id), [sales]); - const handleGetColumnTooltipContent = useCallback( - (col: number): string => { - const columnName = visibleColumns[col].id as SaleListUrlSortField; - - if (canBeSorted(columnName, !!selectedChannelId)) { - return ""; - } - - // Sortable but requrie selected channel - return intl.formatMessage(commonTooltipMessages.noFilterSelected, { - filterName: filterDependency?.label ?? "", - }); - }, - [filterDependency, intl, selectedChannelId, visibleColumns], - ); - const handleHeaderClick = useCallback( - (col: number) => { - const columnName = visibleColumns[col].id as SaleListUrlSortField; - - if (canBeSorted(columnName, !!selectedChannelId)) { - onSort(columnName); - } - }, - [visibleColumns, onSort], - ); - - return ( - - false} - selectionActions={() => null} - menuItems={() => []} - onRowClick={handleRowClick} - onHeaderClicked={handleHeaderClick} - rowAnchor={handleRowAnchor} - getColumnTooltipContent={handleGetColumnTooltipContent} - recentlyAddedColumn={recentlyAddedColumn} - renderColumnPicker={() => ( - - )} - navigatorOpts={{ state: getPrevLocationState(location) }} - /> - - - - - - ); -}; diff --git a/src/discounts/components/SaleListDatagrid/datagrid.ts b/src/discounts/components/SaleListDatagrid/datagrid.ts deleted file mode 100644 index 8d9b04f74f4..00000000000 --- a/src/discounts/components/SaleListDatagrid/datagrid.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { PLACEHOLDER } from "@dashboard/components/Datagrid/const"; -import { readonlyTextCell } from "@dashboard/components/Datagrid/customCells/cells"; -import { AvailableColumn } from "@dashboard/components/Datagrid/types"; -import { Locale } from "@dashboard/components/Locale"; -import { formatMoney } from "@dashboard/components/Money"; -import { formatPercantage } from "@dashboard/components/Percent/utils"; -import { SaleListUrlSortField } from "@dashboard/discounts/urls"; -import { SaleFragment } from "@dashboard/graphql"; -import { Sort } from "@dashboard/types"; -import { getColumnSortDirectionIcon } from "@dashboard/utils/columns/getColumnSortDirectionIcon"; -import { GridCell, Item } from "@glideapps/glide-data-grid"; -import moment from "moment"; -import { IntlShape } from "react-intl"; - -import { columnsMessages } from "./messages"; - -export const salesListStaticColumnsAdapter = (intl: IntlShape, sort: Sort) => - [ - { - id: "name", - title: intl.formatMessage(columnsMessages.name), - width: 350, - }, - { - id: "startDate", - title: intl.formatMessage(columnsMessages.starts), - width: 200, - }, - { - id: "endDate", - title: intl.formatMessage(columnsMessages.ends), - width: 200, - }, - { - id: "value", - title: intl.formatMessage(columnsMessages.value), - width: 200, - }, - ].map(column => ({ - ...column, - icon: getColumnSortDirectionIcon(sort, column.id), - })); - -export const createGetCellContent = - ({ - sales, - columns, - locale, - selectedChannelId, - }: { - sales: SaleFragment[]; - columns: AvailableColumn[]; - locale: Locale; - selectedChannelId?: string; - }) => - ([column, row]: Item): GridCell => { - const rowData = sales[row]; - const columnId = columns[column]?.id; - const channel = rowData?.channelListings?.find( - lisiting => lisiting.channel.id === selectedChannelId, - ); - - if (!columnId || !rowData) { - return readonlyTextCell(""); - } - - switch (columnId) { - case "name": - return readonlyTextCell(rowData.name); - case "startDate": - return readonlyTextCell( - rowData.startDate ? moment(rowData.startDate).locale(locale).format("lll") : PLACEHOLDER, - ); - case "endDate": - return readonlyTextCell( - rowData.endDate ? moment(rowData.endDate).locale(locale).format("lll") : PLACEHOLDER, - ); - case "value": - if (!channel) { - return readonlyTextCell(PLACEHOLDER); - } - - if (rowData?.type && channel?.discountValue) { - if (rowData.type === "FIXED") { - return readonlyTextCell( - formatMoney( - { - amount: channel.discountValue, - currency: channel.channel.currencyCode, - }, - locale, - ), - ); - } - - return readonlyTextCell(formatPercantage(channel.discountValue, locale)); - } - - return readonlyTextCell(PLACEHOLDER); - - default: - return readonlyTextCell(""); - } - }; diff --git a/src/discounts/components/SaleListDatagrid/index.tsx b/src/discounts/components/SaleListDatagrid/index.tsx deleted file mode 100644 index 788a5e5c9b0..00000000000 --- a/src/discounts/components/SaleListDatagrid/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "./SaleListDatagrid"; diff --git a/src/discounts/components/SaleListDatagrid/messages.ts b/src/discounts/components/SaleListDatagrid/messages.ts deleted file mode 100644 index e71b1715cb2..00000000000 --- a/src/discounts/components/SaleListDatagrid/messages.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { defineMessages } from "react-intl"; - -export const columnsMessages = defineMessages({ - name: { - id: "F56hOz", - defaultMessage: "Name", - description: "sale name", - }, - starts: { - id: "iBSq6l", - defaultMessage: "Starts", - description: "sale start date", - }, - ends: { - id: "giF5UV", - defaultMessage: "Ends", - description: "sale end date", - }, - value: { - id: "XZR590", - defaultMessage: "Value", - description: "sale value", - }, -}); - -export const messages = defineMessages({ - empty: { - id: "U2mOqA", - defaultMessage: "No vouchers found", - }, -}); diff --git a/src/discounts/components/SaleListPage/filters.ts b/src/discounts/components/SaleListPage/filters.ts index e7c37d7234d..47b6fc77bfc 100644 --- a/src/discounts/components/SaleListPage/filters.ts +++ b/src/discounts/components/SaleListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { DiscountStatusEnum, DiscountValueTypeEnum } from "@dashboard/graphql"; import { FilterOpts, MinMax } from "@dashboard/types"; import { createDateField, createOptionsField } from "@dashboard/utils/filters/fields"; @@ -12,7 +12,7 @@ export enum SaleFilterKeys { channel = "channel", } -export interface SaleListFilterOpts { +interface SaleListFilterOpts { saleType: FilterOpts; started: FilterOpts; status: FilterOpts; diff --git a/src/discounts/components/SaleSummary/SaleSummary.tsx b/src/discounts/components/SaleSummary/SaleSummary.tsx deleted file mode 100644 index c32ff113735..00000000000 --- a/src/discounts/components/SaleSummary/SaleSummary.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { DashboardCard } from "@dashboard/components/Card"; -import CardSpacer from "@dashboard/components/CardSpacer"; -import Date from "@dashboard/components/Date"; -import FormSpacer from "@dashboard/components/FormSpacer"; -import Hr from "@dashboard/components/Hr"; -import Money from "@dashboard/components/Money"; -import Percent from "@dashboard/components/Percent"; -import { SaleDetailsFragment, SaleType } from "@dashboard/graphql"; -import { commonMessages } from "@dashboard/intl"; -import { ChannelProps } from "@dashboard/types"; -import { Skeleton, Text } from "@saleor/macaw-ui-next"; -import { FormattedMessage, useIntl } from "react-intl"; - -import { maybe } from "../../../misc"; -import useStyles from "./styles"; - -interface SaleSummaryProps extends ChannelProps { - sale: SaleDetailsFragment; -} - -const SaleSummary = ({ selectedChannelId, sale }: SaleSummaryProps) => { - const classes = useStyles(); - const intl = useIntl(); - const channel = sale?.channelListings?.find(listing => listing.channel.id === selectedChannelId); - - return ( - - - {intl.formatMessage(commonMessages.summary)} - - - - - - - {maybe(() => sale.name, )} - - - - - - - - {sale ? ( - sale.type === SaleType.FIXED && channel?.discountValue ? ( - - ) : channel?.discountValue ? ( - - ) : ( - "-" - ) - ) : ( - - )} - - - -
- - - - - - - {maybe( - () => ( - - ), - , - )} - - - - - - - - {maybe( - () => (sale.endDate === null ? "-" : ), - , - )} - -
-
- ); -}; - -SaleSummary.displayName = "SaleSummary"; -export default SaleSummary; diff --git a/src/discounts/components/SaleSummary/index.ts b/src/discounts/components/SaleSummary/index.ts deleted file mode 100644 index 6e0a510f5c1..00000000000 --- a/src/discounts/components/SaleSummary/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from "./SaleSummary"; -export * from "./SaleSummary"; diff --git a/src/discounts/components/SaleSummary/styles.ts b/src/discounts/components/SaleSummary/styles.ts deleted file mode 100644 index e4bf242577b..00000000000 --- a/src/discounts/components/SaleSummary/styles.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { makeStyles } from "@saleor/macaw-ui"; - -const useStyles = makeStyles( - { - ellipsis: { - overflow: "hidden", - whiteSpace: "nowrap", - textOverflow: "ellipsis", - }, - }, - { name: "SaleSummary" }, -); - -export default useStyles; diff --git a/src/discounts/components/VoucherListPage/filters.ts b/src/discounts/components/VoucherListPage/filters.ts index 137c1291af5..06ff232b85a 100644 --- a/src/discounts/components/VoucherListPage/filters.ts +++ b/src/discounts/components/VoucherListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { DiscountStatusEnum, VoucherDiscountType } from "@dashboard/graphql"; import { FilterOpts, MinMax } from "@dashboard/types"; import { diff --git a/src/discounts/urls.ts b/src/discounts/urls.ts index 506936e5ba8..a48a167f1bb 100644 --- a/src/discounts/urls.ts +++ b/src/discounts/urls.ts @@ -31,7 +31,7 @@ export enum SaleListUrlFiltersWithMultipleValues { export type SaleListUrlFilters = Filters & FiltersWithMultipleValues; type SaleListUrlDialog = "remove" | TabActionDialog; -export enum SaleListUrlSortField { +enum SaleListUrlSortField { name = "name", endDate = "endDate", startDate = "startDate", @@ -39,7 +39,7 @@ export enum SaleListUrlSortField { value = "value", } type SaleListUrlSort = Sort; -export type SaleListUrlQueryParams = ActiveTab & +type SaleListUrlQueryParams = ActiveTab & BulkAction & Dialog & Pagination & @@ -48,21 +48,7 @@ export type SaleListUrlQueryParams = ActiveTab & export const saleListUrl = (params?: SaleListUrlQueryParams) => saleListPath + "?" + stringifyQs(params); export const salePath = (id: string) => urlJoin(saleSection, id); -export type SaleUrlDialog = - | "assign-category" - | "assign-collection" - | "assign-product" - | "assign-variant" - | "unassign-category" - | "unassign-collection" - | "unassign-product" - | "unassign-variant" - | "remove" - | ChannelsAction; -export type SaleUrlQueryParams = BulkAction & Dialog; -export type SaleCreateUrlQueryParams = Dialog; -export const saleUrl = (id: string, params?: SaleUrlQueryParams) => - salePath(encodeURIComponent(id)) + "?" + stringifyQs(params); +type SaleCreateUrlQueryParams = Dialog; export const saleAddPath = urlJoin(saleSection, "add"); export const saleAddUrl = (params?: SaleCreateUrlQueryParams) => saleAddPath + "?" + stringifyQs(params); diff --git a/src/discounts/views/SaleDetails/types.ts b/src/discounts/views/SaleDetails/types.ts deleted file mode 100644 index cc0797124e9..00000000000 --- a/src/discounts/views/SaleDetails/types.ts +++ /dev/null @@ -1 +0,0 @@ -export const SALE_UPDATE_FORM_ID = Symbol("sale-update-form-id"); diff --git a/src/discounts/views/SaleList/filters.ts b/src/discounts/views/SaleList/filters.ts index 7183ac13fc2..39eadcceb43 100644 --- a/src/discounts/views/SaleList/filters.ts +++ b/src/discounts/views/SaleList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter"; +import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter/types"; import { SaleFilterKeys } from "@dashboard/discounts/components/SaleListPage"; import { DiscountStatusEnum, DiscountValueTypeEnum, SaleFilterInput } from "@dashboard/graphql"; import { findValueInEnum, joinDateTime } from "@dashboard/misc"; diff --git a/src/discounts/views/SaleList/sort.ts b/src/discounts/views/SaleList/sort.ts deleted file mode 100644 index e819ca15768..00000000000 --- a/src/discounts/views/SaleList/sort.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-strict-ignore -import { SaleListUrlSortField } from "@dashboard/discounts/urls"; - -export function canBeSorted(sort: SaleListUrlSortField | undefined, isChannelSelected: boolean) { - if (sort === undefined) { - return false; - } - - switch (sort) { - case SaleListUrlSortField.name: - case SaleListUrlSortField.startDate: - case SaleListUrlSortField.endDate: - case SaleListUrlSortField.type: - return true; - case SaleListUrlSortField.value: - return isChannelSelected; - default: - return false; - } -} diff --git a/src/discounts/views/VoucherList/filters.ts b/src/discounts/views/VoucherList/filters.ts index 6c33c6f876d..6739dec2cdb 100644 --- a/src/discounts/views/VoucherList/filters.ts +++ b/src/discounts/views/VoucherList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter"; +import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter/types"; import { VoucherFilterKeys, VoucherListFilterOpts, diff --git a/src/giftCards/GiftCardsList/GiftCardsListDatagrid/GiftCardsListDatagrid.tsx b/src/giftCards/GiftCardsList/GiftCardsListDatagrid/GiftCardsListDatagrid.tsx index 30c4486c839..853f5afbc9e 100644 --- a/src/giftCards/GiftCardsList/GiftCardsListDatagrid/GiftCardsListDatagrid.tsx +++ b/src/giftCards/GiftCardsList/GiftCardsListDatagrid/GiftCardsListDatagrid.tsx @@ -5,7 +5,7 @@ import { DatagridChangeStateContext, useDatagridChangeState, } from "@dashboard/components/Datagrid/hooks/useDatagridChange"; -import TablePagination from "@dashboard/components/TablePagination"; +import { TablePagination } from "@dashboard/components/TablePagination"; import { commonTooltipMessages } from "@dashboard/components/TooltipTableCellHeader/messages"; import { giftCardListUrl, giftCardUrl } from "@dashboard/giftCards/urls"; import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState"; diff --git a/src/giftCards/GiftCardsList/filters.ts b/src/giftCards/GiftCardsList/filters.ts index 8194b2dd6d3..51981c5190b 100644 --- a/src/giftCards/GiftCardsList/filters.ts +++ b/src/giftCards/GiftCardsList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { createFilterTabUtils, getMinMaxQueryParam, diff --git a/src/giftCards/GiftCardsList/providers/GiftCardListProvider/GiftCardListProvider.tsx b/src/giftCards/GiftCardsList/providers/GiftCardListProvider/GiftCardListProvider.tsx index b5c2399b0a5..eb271541d44 100644 --- a/src/giftCards/GiftCardsList/providers/GiftCardListProvider/GiftCardListProvider.tsx +++ b/src/giftCards/GiftCardsList/providers/GiftCardListProvider/GiftCardListProvider.tsx @@ -1,7 +1,7 @@ import { ApolloError } from "@apollo/client"; import { useConditionalFilterContext } from "@dashboard/components/ConditionalFilter"; import { createGiftCardQueryVariables } from "@dashboard/components/ConditionalFilter/queryVariables"; -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { ExtendedGiftCard } from "@dashboard/giftCards/GiftCardUpdate/providers/GiftCardDetailsProvider/types"; import { getExtendedGiftCard } from "@dashboard/giftCards/GiftCardUpdate/providers/GiftCardDetailsProvider/utils"; import { giftCardListUrl } from "@dashboard/giftCards/urls"; diff --git a/src/hooks/useChannelsSearch.ts b/src/hooks/useChannelsSearch.ts index 76fd47cc542..a181ee22922 100644 --- a/src/hooks/useChannelsSearch.ts +++ b/src/hooks/useChannelsSearch.ts @@ -1,6 +1,4 @@ -import { ChannelDetailsFragment } from "@dashboard/graphql"; import { fuzzySearch } from "@dashboard/misc"; -import { FetchMoreProps, Search, SearchProps } from "@dashboard/types"; import { useState } from "react"; export const useChannelsSearch = function (channels: T[]) { @@ -9,7 +7,3 @@ export const useChannelsSearch = function (channels: return { query, onQueryChange, filteredChannels }; }; - -export interface ChannelsWithLoadMoreProps extends FetchMoreProps, Search, SearchProps { - channels: ChannelDetailsFragment[]; -} diff --git a/src/hooks/useFilterHandlers.ts b/src/hooks/useFilterHandlers.ts index cf3efb6e696..fe6d07ea0ec 100644 --- a/src/hooks/useFilterHandlers.ts +++ b/src/hooks/useFilterHandlers.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { ActiveTab, Pagination, Search, Sort } from "@dashboard/types"; import { GetFilterQueryParam, getFilterQueryParams } from "@dashboard/utils/filters"; import { useEffect, useRef } from "react"; diff --git a/src/misc.ts b/src/misc.ts index 8d854497748..33f2ba1463f 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -58,14 +58,6 @@ export function renderCollection( return collection.map(renderItem); } -export function decimal(value: string | number) { - if (typeof value === "string") { - return value === "" ? null : value; - } - - return value; -} - export function weight(value: string) { return value === "" ? null : parseFloat(value); } diff --git a/src/modeling/views/PageList/filters.ts b/src/modeling/views/PageList/filters.ts index d2f4a4e4557..8016d54369d 100644 --- a/src/modeling/views/PageList/filters.ts +++ b/src/modeling/views/PageList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { SearchWithFetchMoreProps } from "@dashboard/giftCards/GiftCardsList/GiftCardListSearchAndFilters/types"; import { SearchPageTypesQuery } from "@dashboard/graphql"; import { PageListUrlFilters } from "@dashboard/modeling/urls"; diff --git a/src/orders/components/OrderDraftListPage/filters.ts b/src/orders/components/OrderDraftListPage/filters.ts index 75b9abfa6d5..bf2db38e295 100644 --- a/src/orders/components/OrderDraftListPage/filters.ts +++ b/src/orders/components/OrderDraftListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { FilterOpts, MinMax } from "@dashboard/types"; import { createDateField, createTextField } from "@dashboard/utils/filters/fields"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/orders/views/OrderDraftList/filters.ts b/src/orders/views/OrderDraftList/filters.ts index b79bf8b2c75..ec2e3cdc16f 100644 --- a/src/orders/views/OrderDraftList/filters.ts +++ b/src/orders/views/OrderDraftList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { OrderDraftFilterInput } from "@dashboard/graphql"; import { maybe } from "@dashboard/misc"; import { diff --git a/src/orders/views/OrderList/filters.ts b/src/orders/views/OrderList/filters.ts index a1eb2a41b88..8fa181f3829 100644 --- a/src/orders/views/OrderList/filters.ts +++ b/src/orders/views/OrderList/filters.ts @@ -5,7 +5,7 @@ import { FilterElement, FilterElementKeyValue, FilterElementRegular, -} from "../../../components/Filter"; +} from "../../../components/Filter/types"; import { createFilterTabUtils, getKeyValueQueryParam, diff --git a/src/plugins/urls.ts b/src/plugins/urls.ts index 82e384ed8b2..ad03bf683e5 100644 --- a/src/plugins/urls.ts +++ b/src/plugins/urls.ts @@ -1,4 +1,4 @@ import { Dialog, SingleAction } from "../types"; -export type PluginUrlDialog = "clear" | "edit"; +type PluginUrlDialog = "clear" | "edit"; export type PluginUrlQueryParams = Dialog & SingleAction; diff --git a/src/productTypes/components/ProductTypeListPage/filters.ts b/src/productTypes/components/ProductTypeListPage/filters.ts index 7518cbf26ae..d25cff00be7 100644 --- a/src/productTypes/components/ProductTypeListPage/filters.ts +++ b/src/productTypes/components/ProductTypeListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { ProductTypeConfigurable, ProductTypeEnum } from "@dashboard/graphql"; import { commonMessages } from "@dashboard/intl"; import { FilterOpts } from "@dashboard/types"; diff --git a/src/productTypes/views/ProductTypeList/filters.ts b/src/productTypes/views/ProductTypeList/filters.ts index 538f3ce7c9a..f068cfb4f78 100644 --- a/src/productTypes/views/ProductTypeList/filters.ts +++ b/src/productTypes/views/ProductTypeList/filters.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { ProductTypeConfigurable, ProductTypeEnum, diff --git a/src/products/components/ProductListPage/ProductListPage.tsx b/src/products/components/ProductListPage/ProductListPage.tsx index debaa557979..9be60eb5b12 100644 --- a/src/products/components/ProductListPage/ProductListPage.tsx +++ b/src/products/components/ProductListPage/ProductListPage.tsx @@ -6,7 +6,7 @@ import { TopNav } from "@dashboard/components/AppLayout/TopNav"; import { BulkDeleteButton } from "@dashboard/components/BulkDeleteButton"; import { ButtonGroupWithDropdown } from "@dashboard/components/ButtonGroupWithDropdown"; import { DashboardCard } from "@dashboard/components/Card"; -import { FilterElement } from "@dashboard/components/Filter"; +import { FilterElement } from "@dashboard/components/Filter/types"; import { FilterPresetsSelect } from "@dashboard/components/FilterPresetsSelect"; import { ListPageLayout } from "@dashboard/components/Layouts"; import LimitReachedAlert from "@dashboard/components/LimitReachedAlert"; diff --git a/src/products/views/ProductList/filters.ts b/src/products/views/ProductList/filters.ts index 7d2d88d6715..9113e821dd9 100644 --- a/src/products/views/ProductList/filters.ts +++ b/src/products/views/ProductList/filters.ts @@ -8,7 +8,7 @@ import { FilterElement, FilterElementKeyValue, FilterElementRegular, -} from "../../../components/Filter"; +} from "../../../components/Filter/types"; import { createFilterTabUtils, getGteLteVariables, diff --git a/src/staff/components/StaffListPage/filters.ts b/src/staff/components/StaffListPage/filters.ts index 6e969d4e0e2..48763d414ae 100644 --- a/src/staff/components/StaffListPage/filters.ts +++ b/src/staff/components/StaffListPage/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { StaffMemberStatus } from "@dashboard/graphql"; import { FilterOpts } from "@dashboard/types"; import { createOptionsField } from "@dashboard/utils/filters/fields"; diff --git a/src/staff/views/StaffList/filters.ts b/src/staff/views/StaffList/filters.ts index 067c3c17849..1fac632d996 100644 --- a/src/staff/views/StaffList/filters.ts +++ b/src/staff/views/StaffList/filters.ts @@ -1,4 +1,4 @@ -import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter"; +import { FilterElement, FilterElementRegular } from "@dashboard/components/Filter/types"; import { StaffMemberStatus, StaffUserInput } from "@dashboard/graphql"; import { findValueInEnum } from "@dashboard/misc"; import { StaffFilterKeys, StaffListFilterOpts } from "@dashboard/staff/components/StaffListPage"; diff --git a/src/types.ts b/src/types.ts index 7a3b01b5507..c747ab7b7fc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,7 @@ import { ConfirmButtonTransitionState } from "@dashboard/components/ConfirmButto import { UserPermissionFragment } from "@dashboard/graphql"; import { Option } from "@saleor/macaw-ui-next"; -import { FilterElement, IFilter } from "./components/Filter"; +import { FilterElement, IFilter } from "./components/Filter/types"; export interface UserError { field: string | null; diff --git a/src/utils/filters/fields.ts b/src/utils/filters/fields.ts index 77c7d71f967..511279eac32 100644 --- a/src/utils/filters/fields.ts +++ b/src/utils/filters/fields.ts @@ -1,4 +1,4 @@ -import { FieldType, FilterElementGeneric } from "@dashboard/components/Filter"; +import { FieldType, FilterElementGeneric } from "@dashboard/components/Filter/types"; import { MinMax } from "@dashboard/types"; import { Option } from "@saleor/macaw-ui-next"; diff --git a/src/utils/filters/filters.ts b/src/utils/filters/filters.ts index 5dd09819ad3..d9bdbb76293 100644 --- a/src/utils/filters/filters.ts +++ b/src/utils/filters/filters.ts @@ -3,7 +3,7 @@ import { FilterElementKeyValue, FilterElementRegular, IFilter, -} from "@dashboard/components/Filter"; +} from "@dashboard/components/Filter/types"; import { findValueInEnum } from "@dashboard/misc"; import { ActiveTab } from "@dashboard/types"; diff --git a/src/utils/handlers/filterHandlers.ts b/src/utils/handlers/filterHandlers.ts index 3a7afc7f82f..93d21a3387e 100644 --- a/src/utils/handlers/filterHandlers.ts +++ b/src/utils/handlers/filterHandlers.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import { UseNavigatorResult } from "@dashboard/hooks/useNavigator"; import { ActiveTab, Pagination, Search, Sort } from "@dashboard/types"; diff --git a/src/utils/maps.ts b/src/utils/maps.ts index 482822c0440..ff944b6f15c 100644 --- a/src/utils/maps.ts +++ b/src/utils/maps.ts @@ -7,7 +7,6 @@ import { MetadataInput, MetadataItemFragment, } from "@dashboard/graphql"; -import { getFullName } from "@dashboard/misc"; import { pageUrl } from "@dashboard/modeling/urls"; import { productUrl, productVariantEditUrl } from "@dashboard/products/urls"; import { Node, SlugNode } from "@dashboard/types"; @@ -103,23 +102,6 @@ export function mapSingleValueNodeToChoice>( return (nodes as T[]).map(node => ({ label: node[key], value: node[key] })); } -interface Person { - firstName: string; - lastName: string; - id: string; -} - -export function mapPersonNodeToChoice(nodes: T[]): Option[] { - if (!nodes) { - return []; - } - - return nodes.map(({ firstName, lastName, id }) => ({ - value: id, - label: getFullName({ firstName, lastName }), - })); -} - export function getLoadableList(data: Connection | undefined | null): T[] | undefined { // "undefined" is a loading state if (typeof data === "undefined") { diff --git a/testUtils/filters.ts b/testUtils/filters.ts index 8e6132177a5..d78c0aa37ed 100644 --- a/testUtils/filters.ts +++ b/testUtils/filters.ts @@ -1,4 +1,4 @@ -import { IFilter } from "@dashboard/components/Filter"; +import { IFilter } from "@dashboard/components/Filter/types"; import clone from "lodash/clone"; export function getExistingKeys(o: {}): string[] { From 92aae368bb2855f8f1bf3d17edeefb41a11f9fd1 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Wed, 1 Oct 2025 15:01:02 +0200 Subject: [PATCH 2/9] resmove some exports --- .../PermissionAlert/PermissionAlert.test.tsx | 64 ----- .../PermissionAlert/PermissionAlert.tsx | 81 ------ .../components/PermissionAlert/utils.test.ts | 40 --- .../components/PermissionAlert/utils.ts | 243 ------------------ src/custom-apps/queries.ts | 19 -- 5 files changed, 447 deletions(-) delete mode 100644 src/custom-apps/components/PermissionAlert/PermissionAlert.test.tsx delete mode 100644 src/custom-apps/components/PermissionAlert/PermissionAlert.tsx delete mode 100644 src/custom-apps/components/PermissionAlert/utils.test.ts delete mode 100644 src/custom-apps/components/PermissionAlert/utils.ts diff --git a/src/custom-apps/components/PermissionAlert/PermissionAlert.test.tsx b/src/custom-apps/components/PermissionAlert/PermissionAlert.test.tsx deleted file mode 100644 index 62f7e2525b6..00000000000 --- a/src/custom-apps/components/PermissionAlert/PermissionAlert.test.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import "@testing-library/jest-dom"; - -import { Fetcher } from "@graphiql/toolkit"; -import { ApolloMockedProvider } from "@test/ApolloMockedProvider"; -import { render, screen } from "@testing-library/react"; - -import { PermissionAlert } from "./PermissionAlert"; - -jest.mock("@graphiql/toolkit", () => ({ - clear: jest.fn(), - createGraphiQLFetcher: jest.fn(_x => jest.fn() as Fetcher), -})); -jest.mock("react-intl", () => ({ - useIntl: jest.fn(() => ({ - formatMessage: jest.fn(x => x.defaultMessage), - })), - defineMessages: jest.fn(x => x), -})); -jest.mock("@saleor/macaw-ui", () => ({ - useTheme: jest.fn(() => () => ({})), - useStyles: jest.fn(() => () => ({})), - makeStyles: jest.fn(() => () => ({})), - // eslint-disable-next-line react/display-name - DialogHeader: jest.fn(() => () => <>), -})); -beforeEach(() => { - window.localStorage.clear(); -}); -describe("WebhookSubscriptionQuery", () => { - it("is available on the webhook page", async () => { - // Arrange - const props = { - query: `subscription { - event { - ... on SaleUpdated { - version - sale { - name - } - } - ... on OrderCreated { - version - order { - invoices { - number - } - } - } - } - } - `, - }; - - render( - - - , - ); - // FIXME async components don't work with the current setup - // await waitFor(() => new Promise((res) => setTimeout(res, 500))) - // Assert - expect(screen.queryByTestId("permission-alert")).toBeInTheDocument(); - }); -}); diff --git a/src/custom-apps/components/PermissionAlert/PermissionAlert.tsx b/src/custom-apps/components/PermissionAlert/PermissionAlert.tsx deleted file mode 100644 index 8aae7459579..00000000000 --- a/src/custom-apps/components/PermissionAlert/PermissionAlert.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { gql, useQuery } from "@apollo/client"; -import { Alert } from "@saleor/macaw-ui"; -import { Box, Chip, Text } from "@saleor/macaw-ui-next"; -import { getIntrospectionQuery } from "graphql"; -import { useIntl } from "react-intl"; - -import { getPermissions } from "./utils"; - -interface PermissionAlertProps { - query: string; -} - -export const PermissionAlert = ({ query }: PermissionAlertProps) => { - const intl = useIntl(); - const introQuery = getIntrospectionQuery(); - const { data } = useQuery(gql(introQuery), { - fetchPolicy: "network-only", - }); - const permissionInfo = getPermissions(query, data); - const hasPermissions = permissionInfo && Object.entries(permissionInfo).length > 0; - - return ( -
- {hasPermissions && ( - - - {Object.entries(permissionInfo).map( - ([subscription, { isOneOfRequired, permissions }]) => ( - - - {intl.formatMessage({ - id: "0YjGFG", - defaultMessage: "For subscription", - description: "alert message", - })} - - - {subscription} - - - {isOneOfRequired - ? intl.formatMessage({ - id: "I/y4IU", - defaultMessage: "one of", - description: "alert message", - }) - : intl.formatMessage({ - defaultMessage: "all of", - id: "C+WD8j", - description: "alert message", - })} - - {permissions.map(permission => ( - - {permission} - - ))} - - ), - )} - - - )} -
- ); -}; - -PermissionAlert.displayName = "PermissionAlert"; diff --git a/src/custom-apps/components/PermissionAlert/utils.test.ts b/src/custom-apps/components/PermissionAlert/utils.test.ts deleted file mode 100644 index 0d9321779b4..00000000000 --- a/src/custom-apps/components/PermissionAlert/utils.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { extractPermissions } from "./utils"; - -describe("Permission Parsing", () => { - it("should extract permissions from the meta `description` if available", () => { - // Arrange - // -> Order.invoices - // https://docs.saleor.io/api-reference/orders/objects/order - const description = `List of order invoices. Can be fetched for orders created in Saleor 3.2 and later, for other orders requires one of the following permissions: MANAGE_ORDERS, OWNER.`; - // Act - const { permissions } = extractPermissions(description); - - // Assert - expect(permissions).toHaveLength(2); - expect(permissions[0]).toEqual("MANAGE_ORDERS"); - }); - it("should return empty list if the `description` doesn't mention permissions", () => { - // Arrange - // -> Order.number - // https://docs.saleor.io/api-reference/orders/objects/order - const description = `User-friendly number of an order.`; - // Act - const { permissions } = extractPermissions(description); - - // Assert - expect(permissions).toHaveLength(0); - }); - it("should correctly asses if the permissions are optional", () => { - // Arrange - // -> Order.invoices - // https://docs.saleor.io/api-reference/orders/objects/order - const description = `List of order invoices. Can be fetched for orders created in Saleor 3.2 and later, for other orders requires one of the following permissions: MANAGE_ORDERS, OWNER.`; - // Act - const { permissions, isOneOfRequired } = extractPermissions(description); - - // Assert - expect(isOneOfRequired).toBe(true); - expect(permissions).toHaveLength(2); - expect(permissions[1]).toEqual("OWNER"); - }); -}); diff --git a/src/custom-apps/components/PermissionAlert/utils.ts b/src/custom-apps/components/PermissionAlert/utils.ts deleted file mode 100644 index 80de9e19024..00000000000 --- a/src/custom-apps/components/PermissionAlert/utils.ts +++ /dev/null @@ -1,243 +0,0 @@ -import { - buildClientSchema, - DocumentNode, - GraphQLField, - GraphQLList, - GraphQLNonNull, - GraphQLObjectType, - GraphQLSchema, - GraphQLType, - IntrospectionQuery, - Location, - parse, - Token, - visit, -} from "graphql"; -import { TypeMap } from "graphql/type/schema"; - -/** - * Maps field paths to their required permissions and whether one or all are needed - */ -type SubscriptionQueryPermission = Record< - string, - { - /** Indicates if only one of the listed permissions is required, or if all are. */ - isOneOfRequired: boolean; - /** List of permission code names (e.g., "MANAGE_ORDERS") required for the field. */ - permissions: string[]; - } ->; - -const getStartToken = (documentNode: DocumentNode) => { - const loc = documentNode.loc as Location | undefined; - - return loc?.startToken; -}; - -type FlattenedTokenArray = (string | undefined)[]; - -/** - * Turns a linked list of tokens into a flat array - */ -const toFlattenedTokenArray = ( - token: Token | undefined, - tokens: FlattenedTokenArray = [], -): FlattenedTokenArray => { - if (token && token.next) { - tokens.push(token.value); - - return toFlattenedTokenArray(token.next, tokens); - } - - return tokens; -}; - -const flattenedTokenArray = (token: Token | undefined, tokens: string[] = []): string[] => { - const flattened = toFlattenedTokenArray(token, tokens); - - return flattened.filter(Boolean) as string[]; -}; - -/** - * Gets the base type, removing wrappers like List and NonNull - */ -const unwrapType = (type: GraphQLType): GraphQLType => { - if (type instanceof GraphQLNonNull || type instanceof GraphQLList) { - return unwrapType(type.ofType); - } - - return type; -}; - -/** - * Finds permission requirements mentioned in a field's description. - * - * Looks for text like "Requires one of the following permissions: MANAGE_ORDERS, MANAGE_USERS." - * and extracts both the permissions and whether only one is needed. - * - * It works because description in Saleor Core is auto-generated and follows this pattern. - */ -export const extractPermissions = (description?: string) => { - const match = (description || "").match(/following permissions(.*): (.*?)\./); - // We're assuming that if there is no "one of" then all permissions are required - const isOneOfRequired = (description || "").includes("one of"); - const permissions = match ? match[2].split(",") : []; - - return { - isOneOfRequired, - permissions: permissions.map(permission => permission.trim()), - }; -}; - -/** - * Main function that analyzes a subscription query to determine required permissions. - * - * Takes the query and schema information, returning a map of field paths to - * their permission requirements. - */ -export const getPermissions = ( - query: string, - introspectionQuery: IntrospectionQuery, -): SubscriptionQueryPermission => { - return extractPermissionsFromQuery(query, introspectionQuery); -}; - -/** - * Filters subscription types to only those mentioned in the query tokens - */ -const extractSubscriptions = ( - subscriptions: GraphQLObjectType[], - tokens: string[], -): GraphQLObjectType[] => - tokens.reduce((acc, token) => { - const subscription = subscriptions.find(({ name }) => name === token); - - if (subscription) { - return [...acc, subscription]; - } - - return acc as GraphQLObjectType[]; - }, [] as GraphQLObjectType[]); - -/** - * Finds all subscription event types in the schema (types implementing "Event" interface) - */ -const getSubscriptions = (typeMap: TypeMap): GraphQLObjectType[] => - Object.keys(typeMap).reduce((acc, key) => { - const type = typeMap[key] as GraphQLObjectType; - - if (type instanceof GraphQLObjectType) { - const interfaces = type.getInterfaces(); - const hasEvent = interfaces.some(({ name }) => name === "Event"); - - if (hasEvent) { - return [...acc, type]; - } - } - - return acc; - }, [] as GraphQLObjectType[]); - -/** - * Maps the query structure to the schema to find descriptions for each field. - * - * This is the detective work: for each field in the subscription query, - * it locates the corresponding definition in the schema and extracts - * its description, which may contain permission information. - */ -function getDescriptionsFromQuery(query: string, schema: GraphQLSchema): { [key: string]: string } { - const descriptions: { [key: string]: string } = {}; - // Parse the query into a structure we can traverse - const ast = parse(query); - const startToken = getStartToken(ast); - const tree = flattenedTokenArray(startToken, []); - // Get subscription types from the schema - const subscriptions = getSubscriptions(schema.getTypeMap()); - const subscriptionsFromQuery = extractSubscriptions(subscriptions, tree); - - // For each field in the query, find its schema description - visit(ast, { - Field(node, _key, _parent, _path, ancestors) { - for (const _type in subscriptionsFromQuery) { - // Build path like ["orderCreated", "order", "user"] - const fieldPath = ancestors - .filter((ancestor: any) => ancestor.kind === "Field") - .map((ancestor: any) => ancestor.name.value) - .concat(node.name.value); - - // Start with the subscription event type - let type: GraphQLObjectType | undefined = subscriptionsFromQuery[_type]; - - // Navigate the schema to follow the query path - // For path like ["orderCreated", "order", "user"], - // we navigate from Event → Order → User - for (const fieldName of fieldPath.slice(1, -1)) { - if (type) { - const field: GraphQLField = ( - unwrapType(type) as GraphQLObjectType - ).getFields()[fieldName]; - - // Some types can have multiple nested fields eg. lists - type = field && field.type ? (unwrapType(field.type) as GraphQLObjectType) : undefined; - } - } - - // We've navigated to the parent type - now get the field definition - if (type) { - const field = type.getFields()[node.name.value]; - - if (field) { - // Store the description with a dot-separated path as key - // Example: ["orderCreated", "order", "user"] -> "orderCreated.order.user" - descriptions[fieldPath.join(".")] = field.description || "No description available"; - } - } - } - }, - }); - - return descriptions; -} - -/** - * Analyzes the collected field descriptions to extract permission requirements. - * - * For each field description, it calls extractPermissions() to look for permission - * text patterns and builds a map of only the fields that require permissions. - */ -const extractSubscriptionQueryPermissions = (descriptions: { [key: string]: string }) => { - return Object.keys(descriptions).reduce((acc, key) => { - const { isOneOfRequired, permissions } = extractPermissions(descriptions[key]); - - if (permissions.length > 0) { - acc[key] = { isOneOfRequired, permissions }; - } - - return acc; - }, {} as SubscriptionQueryPermission); -}; - -/** - * Combines all the steps to analyze a subscription query for permissions. - * - * 1. Builds the schema from introspection data - * 2. Gets descriptions for each field in the query - * 3. Extracts permission requirements from those descriptions - */ -const extractPermissionsFromQuery = ( - query: string, - introspectionQuery: IntrospectionQuery, -): SubscriptionQueryPermission => { - let permissions: SubscriptionQueryPermission = {}; - - try { - const schema = buildClientSchema(introspectionQuery); - const descriptions = getDescriptionsFromQuery(query, schema); - - permissions = extractSubscriptionQueryPermissions(descriptions); - } catch (error) { - // explicit silent - } - - return permissions; -}; diff --git a/src/custom-apps/queries.ts b/src/custom-apps/queries.ts index 26200282666..11b1ede9ae5 100644 --- a/src/custom-apps/queries.ts +++ b/src/custom-apps/queries.ts @@ -7,22 +7,3 @@ export const webhooksDetails = gql` } } `; - -// TODO As of Feb 15, 2023 GraphQL Codegen is unable to -// handle the introspection queries i.e. queries with the -// `__schema`. Thus, the following query is defined in -// `./utils.ts` as-is, without codegen handling it - -// export const introspectionQueryList = gql` -// query IntrospectionQueryList { -// __schema { -// queryType { -// name -// fields { -// name -// description -// } -// } -// } -// } -// `; From 9eae73b6e503b1a1eaa3955450484dc6aad3bd0c Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Wed, 1 Oct 2025 15:19:45 +0200 Subject: [PATCH 3/9] clean up custom apps --- src/custom-apps/queries.ts | 9 -------- src/custom-apps/urls.ts | 14 ----------- src/custom-apps/utils.tsx | 23 ------------------- .../WebhookDetailsPage/WebhookDetailsPage.tsx | 4 ++-- .../components/WebhookDetailsPage/messages.ts | 2 +- src/{custom-apps => extensions}/handlers.ts | 3 +-- src/extensions/index.tsx | 2 +- src/extensions/queries.ts | 8 +++++++ src/extensions/urls.ts | 9 ++++++++ src/{custom-apps => extensions}/utils.test.ts | 0 src/extensions/utils.tsx | 23 +++++++++++++++++-- .../components/WebhooksList/WebhooksList.tsx | 2 +- src/index.tsx | 9 ++------ 13 files changed, 46 insertions(+), 62 deletions(-) delete mode 100644 src/custom-apps/queries.ts delete mode 100644 src/custom-apps/urls.ts delete mode 100644 src/custom-apps/utils.tsx rename src/{custom-apps => extensions}/handlers.ts (98%) rename src/{custom-apps => extensions}/utils.test.ts (100%) diff --git a/src/custom-apps/queries.ts b/src/custom-apps/queries.ts deleted file mode 100644 index 11b1ede9ae5..00000000000 --- a/src/custom-apps/queries.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { gql } from "@apollo/client"; - -export const webhooksDetails = gql` - query WebhookDetails($id: ID!) { - webhook(id: $id) { - ...WebhookDetails - } - } -`; diff --git a/src/custom-apps/urls.ts b/src/custom-apps/urls.ts deleted file mode 100644 index 99456dde4e7..00000000000 --- a/src/custom-apps/urls.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Dialog, SingleAction } from "../types"; - -type CustomAppDetailsUrlDialog = - | "create-token" - | "remove-webhook" - | "remove-token" - | "app-activate" - | "app-deactivate"; -export type CustomAppDetailsUrlQueryParams = Dialog & SingleAction; - -export const CustomAppSections = { - appsSection: "/custom-apps/", - webhooksSection: "/webhooks/", -}; diff --git a/src/custom-apps/utils.tsx b/src/custom-apps/utils.tsx deleted file mode 100644 index c01d6c700e5..00000000000 --- a/src/custom-apps/utils.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { WebhookEventTypeAsyncEnum, WebhookFragment } from "@dashboard/graphql"; - -export function isUnnamed(webhook: WebhookFragment | undefined): boolean { - return !webhook?.name; -} - -export const filterSelectedAsyncEvents = (asyncEvents: WebhookEventTypeAsyncEnum[]) => { - const anyEvent = asyncEvents.find(event => event === WebhookEventTypeAsyncEnum.ANY_EVENTS); - - if (anyEvent) { - return [anyEvent]; - } - - return asyncEvents; -}; - -export interface IntrospectionNode { - name: string; - interfaces: Array<{ - name: string; - }> | null; - description: string; -} diff --git a/src/extensions/components/WebhookDetailsPage/WebhookDetailsPage.tsx b/src/extensions/components/WebhookDetailsPage/WebhookDetailsPage.tsx index eeb39dd9564..60be5bf804b 100644 --- a/src/extensions/components/WebhookDetailsPage/WebhookDetailsPage.tsx +++ b/src/extensions/components/WebhookDetailsPage/WebhookDetailsPage.tsx @@ -7,8 +7,7 @@ import { Savebar } from "@dashboard/components/Savebar"; import { createAsyncEventsSelectHandler, createSyncEventsSelectHandler, -} from "@dashboard/custom-apps/handlers"; -import { IntrospectionNode } from "@dashboard/custom-apps/utils"; +} from "@dashboard/extensions/handlers"; import { ExtensionsUrls } from "@dashboard/extensions/urls"; import { WebhookDetailsFragment, @@ -25,6 +24,7 @@ import { useEffect, useState } from "react"; import * as React from "react"; import { useIntl } from "react-intl"; +import { IntrospectionNode } from "../../utils"; import { PermissionAlert } from "./components/PermissionAlert/PermissionAlert"; import { WebhookEvents } from "./components/WebhookEvents/WebhookEvents"; import { WebhookHeaders } from "./components/WebhookHeaders/WebhookHeaders"; diff --git a/src/extensions/components/WebhookDetailsPage/messages.ts b/src/extensions/components/WebhookDetailsPage/messages.ts index 00faba45872..1f9bac320f7 100644 --- a/src/extensions/components/WebhookDetailsPage/messages.ts +++ b/src/extensions/components/WebhookDetailsPage/messages.ts @@ -1,4 +1,4 @@ -import { isUnnamed } from "@dashboard/custom-apps/utils"; +import { isUnnamed } from "@dashboard/extensions/utils"; import { WebhookDetailsQuery } from "@dashboard/graphql"; import { getStringOrPlaceholder } from "@dashboard/misc"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/custom-apps/handlers.ts b/src/extensions/handlers.ts similarity index 98% rename from src/custom-apps/handlers.ts rename to src/extensions/handlers.ts index 03111ef905c..aa858764dca 100644 --- a/src/custom-apps/handlers.ts +++ b/src/extensions/handlers.ts @@ -1,5 +1,6 @@ // @ts-strict-ignore import { WebhookFormData } from "@dashboard/extensions/components/WebhookDetailsPage/WebhookDetailsPage"; +import { filterSelectedAsyncEvents, IntrospectionNode } from "@dashboard/extensions/utils"; import { WebhookEventTypeAsyncEnum, WebhookEventTypeSyncEnum } from "@dashboard/graphql"; import { ChangeEvent } from "@dashboard/hooks/useForm"; import { capitalize } from "@dashboard/misc"; @@ -19,8 +20,6 @@ import isEmpty from "lodash/isEmpty"; import { Dispatch, SetStateAction } from "react"; import * as React from "react"; -import { filterSelectedAsyncEvents, IntrospectionNode } from "./utils"; - interface CreateSyncEventsSelectHandler { change: (event: ChangeEvent, cb?: () => void) => void; data: WebhookFormData; diff --git a/src/extensions/index.tsx b/src/extensions/index.tsx index 6bcc6c5e67b..e0ac2cf5294 100644 --- a/src/extensions/index.tsx +++ b/src/extensions/index.tsx @@ -1,9 +1,9 @@ import SectionRoute from "@dashboard/auth/components/SectionRoute"; import { Route } from "@dashboard/components/Router"; import { WindowTitle } from "@dashboard/components/WindowTitle"; -import { CustomAppDetailsUrlQueryParams } from "@dashboard/custom-apps/urls"; import { AppDetailsUrlQueryParams, + CustomAppDetailsUrlQueryParams, ExtensionInstallQueryParams, ExtensionsPaths, } from "@dashboard/extensions/urls"; diff --git a/src/extensions/queries.ts b/src/extensions/queries.ts index d861b232850..369279928e1 100644 --- a/src/extensions/queries.ts +++ b/src/extensions/queries.ts @@ -182,3 +182,11 @@ export const appWebhookDeliveries = gql` } } `; + +export const webhooksDetails = gql` + query WebhookDetails($id: ID!) { + webhook(id: $id) { + ...WebhookDetails + } + } +`; diff --git a/src/extensions/urls.ts b/src/extensions/urls.ts index 6fc13a9bcd5..65272e38de3 100644 --- a/src/extensions/urls.ts +++ b/src/extensions/urls.ts @@ -235,3 +235,12 @@ export const ExtensionsUrls = { })}`, ), }; + +type CustomAppDetailsUrlDialog = + | "create-token" + | "remove-webhook" + | "remove-token" + | "app-activate" + | "app-deactivate"; + +export type CustomAppDetailsUrlQueryParams = Dialog & SingleAction; diff --git a/src/custom-apps/utils.test.ts b/src/extensions/utils.test.ts similarity index 100% rename from src/custom-apps/utils.test.ts rename to src/extensions/utils.test.ts diff --git a/src/extensions/utils.tsx b/src/extensions/utils.tsx index 6bfefd21163..69e612c8d18 100644 --- a/src/extensions/utils.tsx +++ b/src/extensions/utils.tsx @@ -1,5 +1,10 @@ import { gql } from "@apollo/client"; -import { AppErrorCode, AppErrorFragment } from "@dashboard/graphql"; +import { + AppErrorCode, + AppErrorFragment, + WebhookEventTypeAsyncEnum, + WebhookFragment, +} from "@dashboard/graphql"; import errorTracker from "@dashboard/services/errorTracking"; import { IntlShape } from "react-intl"; @@ -97,7 +102,7 @@ export function getCustomAppErrorMessage( return undefined; } -interface IntrospectionNode { +export interface IntrospectionNode { name: string; interfaces: Array<{ name: string; @@ -124,3 +129,17 @@ const isEvent = ({ name }: { name: string }) => name === "Event"; export const buildEventsMap = (elements: IntrospectionNode[]) => elements.filter(({ interfaces }) => (interfaces || []).some(isEvent)); + +export function isUnnamed(webhook: WebhookFragment | undefined): boolean { + return !webhook?.name; +} + +export const filterSelectedAsyncEvents = (asyncEvents: WebhookEventTypeAsyncEnum[]) => { + const anyEvent = asyncEvents.find(event => event === WebhookEventTypeAsyncEnum.ANY_EVENTS); + + if (anyEvent) { + return [anyEvent]; + } + + return asyncEvents; +}; diff --git a/src/extensions/views/EditCustomExtension/components/WebhooksList/WebhooksList.tsx b/src/extensions/views/EditCustomExtension/components/WebhooksList/WebhooksList.tsx index e9677240eeb..bd5c2209c63 100644 --- a/src/extensions/views/EditCustomExtension/components/WebhooksList/WebhooksList.tsx +++ b/src/extensions/views/EditCustomExtension/components/WebhooksList/WebhooksList.tsx @@ -3,8 +3,8 @@ import ResponsiveTable from "@dashboard/components/ResponsiveTable"; import TableButtonWrapper from "@dashboard/components/TableButtonWrapper"; import TableCellHeader from "@dashboard/components/TableCellHeader"; import TableRowLink from "@dashboard/components/TableRowLink"; -import { isUnnamed } from "@dashboard/custom-apps/utils"; import { ExtensionsUrls } from "@dashboard/extensions/urls"; +import { isUnnamed } from "@dashboard/extensions/utils"; import { WebhookFragment } from "@dashboard/graphql"; import useNavigator from "@dashboard/hooks/useNavigator"; import { commonMessages, commonStatusMessages, sectionNames } from "@dashboard/intl"; diff --git a/src/index.tsx b/src/index.tsx index 610f062686e..69046f873da 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -21,7 +21,6 @@ import TagManager from "react-gtm-module"; import { useIntl } from "react-intl"; import { Redirect, Switch } from "react-router-dom"; -import { AppSections } from "./apps/urls"; import AttributeSection from "./attributes"; import { attributeSection } from "./attributes/urls"; import Auth from "./auth"; @@ -52,7 +51,6 @@ import ConfigurationSection from "./configuration"; import { getConfigMenuItemsPermissions } from "./configuration/utils"; import AppStateProvider from "./containers/AppState"; import BackgroundTasksProvider from "./containers/BackgroundTasks"; -import { CustomAppSections } from "./custom-apps/urls"; import { CustomerSection } from "./customers"; import DiscountSection from "./discounts"; import { ExtensionsSection } from "./extensions"; @@ -315,11 +313,8 @@ const Routes = () => { path="/configuration" component={ConfigurationSection} /> - - + + From 205b897501745161b2fbbd0927e8286144d4b020 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Thu, 2 Oct 2025 07:51:09 +0200 Subject: [PATCH 4/9] move custom apps --- src/custom-apps/mutations.ts | 37 ---- src/extensions/mutations.ts | 36 ++++ src/graphql/hooks.generated.ts | 298 ++++++++++++++++----------------- src/graphql/types.generated.ts | 58 +++---- 4 files changed, 214 insertions(+), 215 deletions(-) delete mode 100644 src/custom-apps/mutations.ts diff --git a/src/custom-apps/mutations.ts b/src/custom-apps/mutations.ts deleted file mode 100644 index 6094de40675..00000000000 --- a/src/custom-apps/mutations.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { gql } from "@apollo/client"; - -export const webhookCreate = gql` - mutation WebhookCreate($input: WebhookCreateInput!) { - webhookCreate(input: $input) { - errors { - ...WebhookError - } - webhook { - ...WebhookDetails - } - } - } -`; - -export const webhookUpdate = gql` - mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) { - webhookUpdate(id: $id, input: $input) { - errors { - ...WebhookError - } - webhook { - ...WebhookDetails - } - } - } -`; - -export const webhookDelete = gql` - mutation WebhookDelete($id: ID!) { - webhookDelete(id: $id) { - errors { - ...WebhookError - } - } - } -`; diff --git a/src/extensions/mutations.ts b/src/extensions/mutations.ts index f7a6639df47..643c68613fe 100644 --- a/src/extensions/mutations.ts +++ b/src/extensions/mutations.ts @@ -15,3 +15,39 @@ export const appDeleteFailedInstallationMutation = gql` } } `; + +export const webhookCreate = gql` + mutation WebhookCreate($input: WebhookCreateInput!) { + webhookCreate(input: $input) { + errors { + ...WebhookError + } + webhook { + ...WebhookDetails + } + } + } +`; + +export const webhookUpdate = gql` + mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) { + webhookUpdate(id: $id, input: $input) { + errors { + ...WebhookError + } + webhook { + ...WebhookDetails + } + } + } +`; + +export const webhookDelete = gql` + mutation WebhookDelete($id: ID!) { + webhookDelete(id: $id) { + errors { + ...WebhookError + } + } + } +`; diff --git a/src/graphql/hooks.generated.ts b/src/graphql/hooks.generated.ts index ab78a50d412..8fd5452ec44 100644 --- a/src/graphql/hooks.generated.ts +++ b/src/graphql/hooks.generated.ts @@ -7677,155 +7677,6 @@ export function useCheckOrderInvoicesStatusLazyQuery(baseOptions?: ApolloReactHo export type CheckOrderInvoicesStatusQueryHookResult = ReturnType; export type CheckOrderInvoicesStatusLazyQueryHookResult = ReturnType; export type CheckOrderInvoicesStatusQueryResult = Apollo.QueryResult; -export const WebhookCreateDocument = gql` - mutation WebhookCreate($input: WebhookCreateInput!) { - webhookCreate(input: $input) { - errors { - ...WebhookError - } - webhook { - ...WebhookDetails - } - } -} - ${WebhookErrorFragmentDoc} -${WebhookDetailsFragmentDoc}`; -export type WebhookCreateMutationFn = Apollo.MutationFunction; - -/** - * __useWebhookCreateMutation__ - * - * To run a mutation, you first call `useWebhookCreateMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useWebhookCreateMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [webhookCreateMutation, { data, loading, error }] = useWebhookCreateMutation({ - * variables: { - * input: // value for 'input' - * }, - * }); - */ -export function useWebhookCreateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useMutation(WebhookCreateDocument, options); - } -export type WebhookCreateMutationHookResult = ReturnType; -export type WebhookCreateMutationResult = Apollo.MutationResult; -export type WebhookCreateMutationOptions = Apollo.BaseMutationOptions; -export const WebhookUpdateDocument = gql` - mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) { - webhookUpdate(id: $id, input: $input) { - errors { - ...WebhookError - } - webhook { - ...WebhookDetails - } - } -} - ${WebhookErrorFragmentDoc} -${WebhookDetailsFragmentDoc}`; -export type WebhookUpdateMutationFn = Apollo.MutationFunction; - -/** - * __useWebhookUpdateMutation__ - * - * To run a mutation, you first call `useWebhookUpdateMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useWebhookUpdateMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [webhookUpdateMutation, { data, loading, error }] = useWebhookUpdateMutation({ - * variables: { - * id: // value for 'id' - * input: // value for 'input' - * }, - * }); - */ -export function useWebhookUpdateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useMutation(WebhookUpdateDocument, options); - } -export type WebhookUpdateMutationHookResult = ReturnType; -export type WebhookUpdateMutationResult = Apollo.MutationResult; -export type WebhookUpdateMutationOptions = Apollo.BaseMutationOptions; -export const WebhookDeleteDocument = gql` - mutation WebhookDelete($id: ID!) { - webhookDelete(id: $id) { - errors { - ...WebhookError - } - } -} - ${WebhookErrorFragmentDoc}`; -export type WebhookDeleteMutationFn = Apollo.MutationFunction; - -/** - * __useWebhookDeleteMutation__ - * - * To run a mutation, you first call `useWebhookDeleteMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useWebhookDeleteMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [webhookDeleteMutation, { data, loading, error }] = useWebhookDeleteMutation({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useWebhookDeleteMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useMutation(WebhookDeleteDocument, options); - } -export type WebhookDeleteMutationHookResult = ReturnType; -export type WebhookDeleteMutationResult = Apollo.MutationResult; -export type WebhookDeleteMutationOptions = Apollo.BaseMutationOptions; -export const WebhookDetailsDocument = gql` - query WebhookDetails($id: ID!) { - webhook(id: $id) { - ...WebhookDetails - } -} - ${WebhookDetailsFragmentDoc}`; - -/** - * __useWebhookDetailsQuery__ - * - * To run a query within a React component, call `useWebhookDetailsQuery` and pass it any options that fit your needs. - * When your component renders, `useWebhookDetailsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useWebhookDetailsQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useWebhookDetailsQuery(baseOptions: ApolloReactHooks.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useQuery(WebhookDetailsDocument, options); - } -export function useWebhookDetailsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useLazyQuery(WebhookDetailsDocument, options); - } -export type WebhookDetailsQueryHookResult = ReturnType; -export type WebhookDetailsLazyQueryHookResult = ReturnType; -export type WebhookDetailsQueryResult = Apollo.QueryResult; export const UpdateCustomerDocument = gql` mutation UpdateCustomer($id: ID!, $input: CustomerInput!) { customerUpdate(id: $id, input: $input) { @@ -9656,6 +9507,120 @@ export function usePromotionDetailsQueryLazyQuery(baseOptions?: ApolloReactHooks export type PromotionDetailsQueryQueryHookResult = ReturnType; export type PromotionDetailsQueryLazyQueryHookResult = ReturnType; export type PromotionDetailsQueryQueryResult = Apollo.QueryResult; +export const WebhookCreateDocument = gql` + mutation WebhookCreate($input: WebhookCreateInput!) { + webhookCreate(input: $input) { + errors { + ...WebhookError + } + webhook { + ...WebhookDetails + } + } +} + ${WebhookErrorFragmentDoc} +${WebhookDetailsFragmentDoc}`; +export type WebhookCreateMutationFn = Apollo.MutationFunction; + +/** + * __useWebhookCreateMutation__ + * + * To run a mutation, you first call `useWebhookCreateMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useWebhookCreateMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [webhookCreateMutation, { data, loading, error }] = useWebhookCreateMutation({ + * variables: { + * input: // value for 'input' + * }, + * }); + */ +export function useWebhookCreateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useMutation(WebhookCreateDocument, options); + } +export type WebhookCreateMutationHookResult = ReturnType; +export type WebhookCreateMutationResult = Apollo.MutationResult; +export type WebhookCreateMutationOptions = Apollo.BaseMutationOptions; +export const WebhookUpdateDocument = gql` + mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) { + webhookUpdate(id: $id, input: $input) { + errors { + ...WebhookError + } + webhook { + ...WebhookDetails + } + } +} + ${WebhookErrorFragmentDoc} +${WebhookDetailsFragmentDoc}`; +export type WebhookUpdateMutationFn = Apollo.MutationFunction; + +/** + * __useWebhookUpdateMutation__ + * + * To run a mutation, you first call `useWebhookUpdateMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useWebhookUpdateMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [webhookUpdateMutation, { data, loading, error }] = useWebhookUpdateMutation({ + * variables: { + * id: // value for 'id' + * input: // value for 'input' + * }, + * }); + */ +export function useWebhookUpdateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useMutation(WebhookUpdateDocument, options); + } +export type WebhookUpdateMutationHookResult = ReturnType; +export type WebhookUpdateMutationResult = Apollo.MutationResult; +export type WebhookUpdateMutationOptions = Apollo.BaseMutationOptions; +export const WebhookDeleteDocument = gql` + mutation WebhookDelete($id: ID!) { + webhookDelete(id: $id) { + errors { + ...WebhookError + } + } +} + ${WebhookErrorFragmentDoc}`; +export type WebhookDeleteMutationFn = Apollo.MutationFunction; + +/** + * __useWebhookDeleteMutation__ + * + * To run a mutation, you first call `useWebhookDeleteMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useWebhookDeleteMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [webhookDeleteMutation, { data, loading, error }] = useWebhookDeleteMutation({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useWebhookDeleteMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useMutation(WebhookDeleteDocument, options); + } +export type WebhookDeleteMutationHookResult = ReturnType; +export type WebhookDeleteMutationResult = Apollo.MutationResult; +export type WebhookDeleteMutationOptions = Apollo.BaseMutationOptions; export const InstalledAppsDocument = gql` query InstalledApps($before: String, $after: String, $first: Int, $last: Int, $filter: AppFilterInput) { apps( @@ -9894,6 +9859,41 @@ export function useExtensionListLazyQuery(baseOptions?: ApolloReactHooks.LazyQue export type ExtensionListQueryHookResult = ReturnType; export type ExtensionListLazyQueryHookResult = ReturnType; export type ExtensionListQueryResult = Apollo.QueryResult; +export const WebhookDetailsDocument = gql` + query WebhookDetails($id: ID!) { + webhook(id: $id) { + ...WebhookDetails + } +} + ${WebhookDetailsFragmentDoc}`; + +/** + * __useWebhookDetailsQuery__ + * + * To run a query within a React component, call `useWebhookDetailsQuery` and pass it any options that fit your needs. + * When your component renders, `useWebhookDetailsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useWebhookDetailsQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useWebhookDetailsQuery(baseOptions: ApolloReactHooks.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useQuery(WebhookDetailsDocument, options); + } +export function useWebhookDetailsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useLazyQuery(WebhookDetailsDocument, options); + } +export type WebhookDetailsQueryHookResult = ReturnType; +export type WebhookDetailsLazyQueryHookResult = ReturnType; +export type WebhookDetailsQueryResult = Apollo.QueryResult; export const FileUploadDocument = gql` mutation FileUpload($file: Upload!) { fileUpload(file: $file) { diff --git a/src/graphql/types.generated.ts b/src/graphql/types.generated.ts index fe597fee3df..6b903b59422 100644 --- a/src/graphql/types.generated.ts +++ b/src/graphql/types.generated.ts @@ -9559,35 +9559,6 @@ export type CheckOrderInvoicesStatusQueryVariables = Exact<{ export type CheckOrderInvoicesStatusQuery = { __typename: 'Query', order: { __typename: 'Order', id: string, invoices: Array<{ __typename: 'Invoice', id: string, number: string | null, createdAt: any, url: string | null, status: JobStatusEnum }> } | null }; -export type WebhookCreateMutationVariables = Exact<{ - input: WebhookCreateInput; -}>; - - -export type WebhookCreateMutation = { __typename: 'Mutation', webhookCreate: { __typename: 'WebhookCreate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; - -export type WebhookUpdateMutationVariables = Exact<{ - id: Scalars['ID']; - input: WebhookUpdateInput; -}>; - - -export type WebhookUpdateMutation = { __typename: 'Mutation', webhookUpdate: { __typename: 'WebhookUpdate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; - -export type WebhookDeleteMutationVariables = Exact<{ - id: Scalars['ID']; -}>; - - -export type WebhookDeleteMutation = { __typename: 'Mutation', webhookDelete: { __typename: 'WebhookDelete', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }> } | null }; - -export type WebhookDetailsQueryVariables = Exact<{ - id: Scalars['ID']; -}>; - - -export type WebhookDetailsQuery = { __typename: 'Query', webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null }; - export type UpdateCustomerMutationVariables = Exact<{ id: Scalars['ID']; input: CustomerInput; @@ -9976,6 +9947,28 @@ export type PromotionDetailsQueryQueryVariables = Exact<{ export type PromotionDetailsQueryQuery = { __typename: 'Query', promotion: { __typename: 'Promotion', id: string, name: string, description: any | null, startDate: any, endDate: any | null, type: PromotionTypeEnum | null, rules: Array<{ __typename: 'PromotionRule', id: string, name: string | null, description: any | null, giftIds: Array | null, rewardType: RewardTypeEnum | null, rewardValueType: RewardValueTypeEnum | null, rewardValue: any | null, cataloguePredicate: any | null, orderPredicate: any | null, channels: Array<{ __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } }> | null }> | null } | null }; +export type WebhookCreateMutationVariables = Exact<{ + input: WebhookCreateInput; +}>; + + +export type WebhookCreateMutation = { __typename: 'Mutation', webhookCreate: { __typename: 'WebhookCreate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; + +export type WebhookUpdateMutationVariables = Exact<{ + id: Scalars['ID']; + input: WebhookUpdateInput; +}>; + + +export type WebhookUpdateMutation = { __typename: 'Mutation', webhookUpdate: { __typename: 'WebhookUpdate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; + +export type WebhookDeleteMutationVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type WebhookDeleteMutation = { __typename: 'Mutation', webhookDelete: { __typename: 'WebhookDelete', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }> } | null }; + export type InstalledAppsQueryVariables = Exact<{ before?: InputMaybe; after?: InputMaybe; @@ -10017,6 +10010,13 @@ export type ExtensionListQueryVariables = Exact<{ export type ExtensionListQuery = { __typename: 'Query', appExtensions: { __typename: 'AppExtensionCountableConnection', edges: Array<{ __typename: 'AppExtensionCountableEdge', node: { __typename: 'AppExtension', id: string, label: string, url: string, mount: AppExtensionMountEnum, target: AppExtensionTargetEnum, accessToken: string | null, options: { __typename: 'AppExtensionOptionsNewTab', newTabTarget: { __typename: 'NewTabTargetOptions', method: HttpMethod } | null } | { __typename: 'AppExtensionOptionsWidget', widgetTarget: { __typename: 'WidgetTargetOptions', method: HttpMethod } | null } | null, permissions: Array<{ __typename: 'Permission', code: PermissionEnum }>, app: { __typename: 'App', id: string, appUrl: string | null, name: string | null, brand: { __typename: 'AppBrand', logo: { __typename: 'AppBrandLogo', default: string } } | null } } }> } | null }; +export type WebhookDetailsQueryVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type WebhookDetailsQuery = { __typename: 'Query', webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null }; + export type FileUploadMutationVariables = Exact<{ file: Scalars['Upload']; }>; From 873187fb9d8132afe286d0c055638eb4c85e1d9e Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Thu, 2 Oct 2025 07:59:04 +0200 Subject: [PATCH 5/9] remove plugins dir --- .../ChannelsAvailabilityMenuContent.tsx | 2 +- .../ScrollableContent.tsx | 0 src/extensions/index.tsx | 2 +- src/extensions/mutations.ts | 13 + src/extensions/queries.ts | 40 +++ .../views/EditPluginExtension}/messages.ts | 0 .../views/EditPluginExtension/utils.ts | 2 +- src/graphql/hooks.generated.ts | 266 +++++++++--------- src/graphql/types.generated.ts | 56 ++-- src/plugins/mutations.ts | 14 - src/plugins/queries.ts | 41 --- src/plugins/urls.ts | 4 - 12 files changed, 217 insertions(+), 223 deletions(-) rename src/{plugins/components/PluginsList => components/ChannelsAvailabilityMenuContent}/PluginAvailabilityStatusPopup/ScrollableContent.tsx (100%) rename src/{plugins/components/PluginsList => extensions/views/EditPluginExtension}/messages.ts (100%) delete mode 100644 src/plugins/mutations.ts delete mode 100644 src/plugins/queries.ts delete mode 100644 src/plugins/urls.ts diff --git a/src/components/ChannelsAvailabilityMenuContent/ChannelsAvailabilityMenuContent.tsx b/src/components/ChannelsAvailabilityMenuContent/ChannelsAvailabilityMenuContent.tsx index bb80e8e9d4e..83782b7df6a 100644 --- a/src/components/ChannelsAvailabilityMenuContent/ChannelsAvailabilityMenuContent.tsx +++ b/src/components/ChannelsAvailabilityMenuContent/ChannelsAvailabilityMenuContent.tsx @@ -1,13 +1,13 @@ // @ts-strict-ignore import HorizontalSpacer from "@dashboard/components/HorizontalSpacer"; import { CollectionFragment } from "@dashboard/graphql"; -import { ScrollableContent } from "@dashboard/plugins/components/PluginsList/PluginAvailabilityStatusPopup/ScrollableContent"; import { PillColor } from "@saleor/macaw-ui"; import { Text } from "@saleor/macaw-ui-next"; import { MessageDescriptor, useIntl } from "react-intl"; import { messages } from "../ChannelsAvailabilityDropdown/messages"; import { Pill } from "../Pill"; +import { ScrollableContent } from "./PluginAvailabilityStatusPopup/ScrollableContent"; import { useStyles } from "./styles"; interface ChannelsAvailabilityMenuContentProps { diff --git a/src/plugins/components/PluginsList/PluginAvailabilityStatusPopup/ScrollableContent.tsx b/src/components/ChannelsAvailabilityMenuContent/PluginAvailabilityStatusPopup/ScrollableContent.tsx similarity index 100% rename from src/plugins/components/PluginsList/PluginAvailabilityStatusPopup/ScrollableContent.tsx rename to src/components/ChannelsAvailabilityMenuContent/PluginAvailabilityStatusPopup/ScrollableContent.tsx diff --git a/src/extensions/index.tsx b/src/extensions/index.tsx index e0ac2cf5294..1a46a040c5e 100644 --- a/src/extensions/index.tsx +++ b/src/extensions/index.tsx @@ -6,6 +6,7 @@ import { CustomAppDetailsUrlQueryParams, ExtensionInstallQueryParams, ExtensionsPaths, + PluginUrlQueryParams, } from "@dashboard/extensions/urls"; import { ExploreExtensions } from "@dashboard/extensions/views/ExploreExtensions/ExploreExtensions"; import { InstallCustomExtension } from "@dashboard/extensions/views/InstallCustomExtension/InstallCustomExtension"; @@ -13,7 +14,6 @@ import { InstalledExtensions } from "@dashboard/extensions/views/InstalledExtens import { PermissionEnum } from "@dashboard/graphql"; import { sectionNames } from "@dashboard/intl"; import NotFound from "@dashboard/NotFound"; -import { PluginUrlQueryParams } from "@dashboard/plugins/urls"; import { parse as parseQs } from "qs"; import { useIntl } from "react-intl"; import { RouteComponentProps, Switch } from "react-router-dom"; diff --git a/src/extensions/mutations.ts b/src/extensions/mutations.ts index 643c68613fe..0fb1769ad16 100644 --- a/src/extensions/mutations.ts +++ b/src/extensions/mutations.ts @@ -51,3 +51,16 @@ export const webhookDelete = gql` } } `; + +export const pluginUpdate = gql` + mutation PluginUpdate($channelId: ID, $id: ID!, $input: PluginUpdateInput!) { + pluginUpdate(channelId: $channelId, id: $id, input: $input) { + errors { + ...PluginError + } + plugin { + ...PluginsDetails + } + } + } +`; diff --git a/src/extensions/queries.ts b/src/extensions/queries.ts index 369279928e1..0839ed12388 100644 --- a/src/extensions/queries.ts +++ b/src/extensions/queries.ts @@ -190,3 +190,43 @@ export const webhooksDetails = gql` } } `; + +export const pluginsList = gql` + query Plugins( + $first: Int + $after: String + $last: Int + $before: String + $filter: PluginFilterInput + $sort: PluginSortingInput + ) { + plugins( + before: $before + after: $after + first: $first + last: $last + filter: $filter + sortBy: $sort + ) { + edges { + node { + ...PluginBase + } + } + pageInfo { + hasPreviousPage + hasNextPage + startCursor + endCursor + } + } + } +`; + +export const pluginsDetails = gql` + query Plugin($id: ID!) { + plugin(id: $id) { + ...PluginsDetails + } + } +`; diff --git a/src/plugins/components/PluginsList/messages.ts b/src/extensions/views/EditPluginExtension/messages.ts similarity index 100% rename from src/plugins/components/PluginsList/messages.ts rename to src/extensions/views/EditPluginExtension/messages.ts diff --git a/src/extensions/views/EditPluginExtension/utils.ts b/src/extensions/views/EditPluginExtension/utils.ts index b7b08141156..4270fb86b3e 100644 --- a/src/extensions/views/EditPluginExtension/utils.ts +++ b/src/extensions/views/EditPluginExtension/utils.ts @@ -1,9 +1,9 @@ +import { pluginStatusMessages } from "@dashboard/extensions/views/EditPluginExtension/messages"; import { ConfigurationItemFragment, ConfigurationTypeFieldEnum, PluginConfigurationBaseFragment, } from "@dashboard/graphql"; -import { pluginStatusMessages } from "@dashboard/plugins/components/PluginsList/messages"; import { PillColor } from "@saleor/macaw-ui"; import { MessageDescriptor } from "react-intl"; diff --git a/src/graphql/hooks.generated.ts b/src/graphql/hooks.generated.ts index 8fd5452ec44..df561d21971 100644 --- a/src/graphql/hooks.generated.ts +++ b/src/graphql/hooks.generated.ts @@ -9621,6 +9621,47 @@ export function useWebhookDeleteMutation(baseOptions?: ApolloReactHooks.Mutation export type WebhookDeleteMutationHookResult = ReturnType; export type WebhookDeleteMutationResult = Apollo.MutationResult; export type WebhookDeleteMutationOptions = Apollo.BaseMutationOptions; +export const PluginUpdateDocument = gql` + mutation PluginUpdate($channelId: ID, $id: ID!, $input: PluginUpdateInput!) { + pluginUpdate(channelId: $channelId, id: $id, input: $input) { + errors { + ...PluginError + } + plugin { + ...PluginsDetails + } + } +} + ${PluginErrorFragmentDoc} +${PluginsDetailsFragmentDoc}`; +export type PluginUpdateMutationFn = Apollo.MutationFunction; + +/** + * __usePluginUpdateMutation__ + * + * To run a mutation, you first call `usePluginUpdateMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `usePluginUpdateMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [pluginUpdateMutation, { data, loading, error }] = usePluginUpdateMutation({ + * variables: { + * channelId: // value for 'channelId' + * id: // value for 'id' + * input: // value for 'input' + * }, + * }); + */ +export function usePluginUpdateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useMutation(PluginUpdateDocument, options); + } +export type PluginUpdateMutationHookResult = ReturnType; +export type PluginUpdateMutationResult = Apollo.MutationResult; +export type PluginUpdateMutationOptions = Apollo.BaseMutationOptions; export const InstalledAppsDocument = gql` query InstalledApps($before: String, $after: String, $first: Int, $last: Int, $filter: AppFilterInput) { apps( @@ -9894,6 +9935,98 @@ export function useWebhookDetailsLazyQuery(baseOptions?: ApolloReactHooks.LazyQu export type WebhookDetailsQueryHookResult = ReturnType; export type WebhookDetailsLazyQueryHookResult = ReturnType; export type WebhookDetailsQueryResult = Apollo.QueryResult; +export const PluginsDocument = gql` + query Plugins($first: Int, $after: String, $last: Int, $before: String, $filter: PluginFilterInput, $sort: PluginSortingInput) { + plugins( + before: $before + after: $after + first: $first + last: $last + filter: $filter + sortBy: $sort + ) { + edges { + node { + ...PluginBase + } + } + pageInfo { + hasPreviousPage + hasNextPage + startCursor + endCursor + } + } +} + ${PluginBaseFragmentDoc}`; + +/** + * __usePluginsQuery__ + * + * To run a query within a React component, call `usePluginsQuery` and pass it any options that fit your needs. + * When your component renders, `usePluginsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = usePluginsQuery({ + * variables: { + * first: // value for 'first' + * after: // value for 'after' + * last: // value for 'last' + * before: // value for 'before' + * filter: // value for 'filter' + * sort: // value for 'sort' + * }, + * }); + */ +export function usePluginsQuery(baseOptions?: ApolloReactHooks.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useQuery(PluginsDocument, options); + } +export function usePluginsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useLazyQuery(PluginsDocument, options); + } +export type PluginsQueryHookResult = ReturnType; +export type PluginsLazyQueryHookResult = ReturnType; +export type PluginsQueryResult = Apollo.QueryResult; +export const PluginDocument = gql` + query Plugin($id: ID!) { + plugin(id: $id) { + ...PluginsDetails + } +} + ${PluginsDetailsFragmentDoc}`; + +/** + * __usePluginQuery__ + * + * To run a query within a React component, call `usePluginQuery` and pass it any options that fit your needs. + * When your component renders, `usePluginQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = usePluginQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function usePluginQuery(baseOptions: ApolloReactHooks.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useQuery(PluginDocument, options); + } +export function usePluginLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useLazyQuery(PluginDocument, options); + } +export type PluginQueryHookResult = ReturnType; +export type PluginLazyQueryHookResult = ReturnType; +export type PluginQueryResult = Apollo.QueryResult; export const FileUploadDocument = gql` mutation FileUpload($file: Upload!) { fileUpload(file: $file) { @@ -14233,139 +14366,6 @@ export function usePermissionGroupDetailsLazyQuery(baseOptions?: ApolloReactHook export type PermissionGroupDetailsQueryHookResult = ReturnType; export type PermissionGroupDetailsLazyQueryHookResult = ReturnType; export type PermissionGroupDetailsQueryResult = Apollo.QueryResult; -export const PluginUpdateDocument = gql` - mutation PluginUpdate($channelId: ID, $id: ID!, $input: PluginUpdateInput!) { - pluginUpdate(channelId: $channelId, id: $id, input: $input) { - errors { - ...PluginError - } - plugin { - ...PluginsDetails - } - } -} - ${PluginErrorFragmentDoc} -${PluginsDetailsFragmentDoc}`; -export type PluginUpdateMutationFn = Apollo.MutationFunction; - -/** - * __usePluginUpdateMutation__ - * - * To run a mutation, you first call `usePluginUpdateMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `usePluginUpdateMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [pluginUpdateMutation, { data, loading, error }] = usePluginUpdateMutation({ - * variables: { - * channelId: // value for 'channelId' - * id: // value for 'id' - * input: // value for 'input' - * }, - * }); - */ -export function usePluginUpdateMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useMutation(PluginUpdateDocument, options); - } -export type PluginUpdateMutationHookResult = ReturnType; -export type PluginUpdateMutationResult = Apollo.MutationResult; -export type PluginUpdateMutationOptions = Apollo.BaseMutationOptions; -export const PluginsDocument = gql` - query Plugins($first: Int, $after: String, $last: Int, $before: String, $filter: PluginFilterInput, $sort: PluginSortingInput) { - plugins( - before: $before - after: $after - first: $first - last: $last - filter: $filter - sortBy: $sort - ) { - edges { - node { - ...PluginBase - } - } - pageInfo { - hasPreviousPage - hasNextPage - startCursor - endCursor - } - } -} - ${PluginBaseFragmentDoc}`; - -/** - * __usePluginsQuery__ - * - * To run a query within a React component, call `usePluginsQuery` and pass it any options that fit your needs. - * When your component renders, `usePluginsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = usePluginsQuery({ - * variables: { - * first: // value for 'first' - * after: // value for 'after' - * last: // value for 'last' - * before: // value for 'before' - * filter: // value for 'filter' - * sort: // value for 'sort' - * }, - * }); - */ -export function usePluginsQuery(baseOptions?: ApolloReactHooks.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useQuery(PluginsDocument, options); - } -export function usePluginsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useLazyQuery(PluginsDocument, options); - } -export type PluginsQueryHookResult = ReturnType; -export type PluginsLazyQueryHookResult = ReturnType; -export type PluginsQueryResult = Apollo.QueryResult; -export const PluginDocument = gql` - query Plugin($id: ID!) { - plugin(id: $id) { - ...PluginsDetails - } -} - ${PluginsDetailsFragmentDoc}`; - -/** - * __usePluginQuery__ - * - * To run a query within a React component, call `usePluginQuery` and pass it any options that fit your needs. - * When your component renders, `usePluginQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = usePluginQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function usePluginQuery(baseOptions: ApolloReactHooks.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useQuery(PluginDocument, options); - } -export function usePluginLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useLazyQuery(PluginDocument, options); - } -export type PluginQueryHookResult = ReturnType; -export type PluginLazyQueryHookResult = ReturnType; -export type PluginQueryResult = Apollo.QueryResult; export const ProductTypeDeleteDocument = gql` mutation ProductTypeDelete($id: ID!) { productTypeDelete(id: $id) { diff --git a/src/graphql/types.generated.ts b/src/graphql/types.generated.ts index 6b903b59422..d38ab639108 100644 --- a/src/graphql/types.generated.ts +++ b/src/graphql/types.generated.ts @@ -9969,6 +9969,15 @@ export type WebhookDeleteMutationVariables = Exact<{ export type WebhookDeleteMutation = { __typename: 'Mutation', webhookDelete: { __typename: 'WebhookDelete', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }> } | null }; +export type PluginUpdateMutationVariables = Exact<{ + channelId?: InputMaybe; + id: Scalars['ID']; + input: PluginUpdateInput; +}>; + + +export type PluginUpdateMutation = { __typename: 'Mutation', pluginUpdate: { __typename: 'PluginUpdate', errors: Array<{ __typename: 'PluginError', code: PluginErrorCode, field: string | null, message: string | null }>, plugin: { __typename: 'Plugin', id: string, name: string, description: string, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }> } | null } | null }; + export type InstalledAppsQueryVariables = Exact<{ before?: InputMaybe; after?: InputMaybe; @@ -10017,6 +10026,25 @@ export type WebhookDetailsQueryVariables = Exact<{ export type WebhookDetailsQuery = { __typename: 'Query', webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, subscriptionQuery: string | null, customHeaders: any | null, id: string, name: string | null, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null }; +export type PluginsQueryVariables = Exact<{ + first?: InputMaybe; + after?: InputMaybe; + last?: InputMaybe; + before?: InputMaybe; + filter?: InputMaybe; + sort?: InputMaybe; +}>; + + +export type PluginsQuery = { __typename: 'Query', plugins: { __typename: 'PluginCountableConnection', edges: Array<{ __typename: 'PluginCountableEdge', node: { __typename: 'Plugin', id: string, name: string, description: string, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }>, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null } }>, pageInfo: { __typename: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor: string | null, endCursor: string | null } } | null }; + +export type PluginQueryVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type PluginQuery = { __typename: 'Query', plugin: { __typename: 'Plugin', id: string, name: string, description: string, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }> } | null }; + export type FileUploadMutationVariables = Exact<{ file: Scalars['Upload']; }>; @@ -11382,34 +11410,6 @@ export type PermissionGroupDetailsQueryVariables = Exact<{ export type PermissionGroupDetailsQuery = { __typename: 'Query', permissionGroup: { __typename: 'Group', restrictedAccessToChannels: boolean, id: string, name: string, userCanManage: boolean, accessibleChannels: Array<{ __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } }> | null, permissions: Array<{ __typename: 'Permission', code: PermissionEnum, name: string }> | null, users: Array<{ __typename: 'User', id: string, firstName: string, lastName: string, email: string, isActive: boolean, avatar: { __typename: 'Image', url: string } | null }> | null } | null, user: { __typename: 'User', editableGroups: Array<{ __typename: 'Group', id: string }> | null, userPermissions: Array<{ __typename: 'UserPermission', code: PermissionEnum, sourcePermissionGroups: Array<{ __typename: 'Group', id: string }> | null }> | null } | null }; -export type PluginUpdateMutationVariables = Exact<{ - channelId?: InputMaybe; - id: Scalars['ID']; - input: PluginUpdateInput; -}>; - - -export type PluginUpdateMutation = { __typename: 'Mutation', pluginUpdate: { __typename: 'PluginUpdate', errors: Array<{ __typename: 'PluginError', code: PluginErrorCode, field: string | null, message: string | null }>, plugin: { __typename: 'Plugin', id: string, name: string, description: string, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }> } | null } | null }; - -export type PluginsQueryVariables = Exact<{ - first?: InputMaybe; - after?: InputMaybe; - last?: InputMaybe; - before?: InputMaybe; - filter?: InputMaybe; - sort?: InputMaybe; -}>; - - -export type PluginsQuery = { __typename: 'Query', plugins: { __typename: 'PluginCountableConnection', edges: Array<{ __typename: 'PluginCountableEdge', node: { __typename: 'Plugin', id: string, name: string, description: string, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }>, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null } }>, pageInfo: { __typename: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor: string | null, endCursor: string | null } } | null }; - -export type PluginQueryVariables = Exact<{ - id: Scalars['ID']; -}>; - - -export type PluginQuery = { __typename: 'Query', plugin: { __typename: 'Plugin', id: string, name: string, description: string, globalConfiguration: { __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null } | null, channelConfigurations: Array<{ __typename: 'PluginConfiguration', active: boolean, configuration: Array<{ __typename: 'ConfigurationItem', name: string, value: string | null, type: ConfigurationTypeFieldEnum | null, helpText: string | null, label: string | null }> | null, channel: { __typename: 'Channel', id: string, name: string, slug: string } | null }> } | null }; - export type ProductTypeDeleteMutationVariables = Exact<{ id: Scalars['ID']; }>; diff --git a/src/plugins/mutations.ts b/src/plugins/mutations.ts deleted file mode 100644 index 399d976402c..00000000000 --- a/src/plugins/mutations.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { gql } from "@apollo/client"; - -export const pluginUpdate = gql` - mutation PluginUpdate($channelId: ID, $id: ID!, $input: PluginUpdateInput!) { - pluginUpdate(channelId: $channelId, id: $id, input: $input) { - errors { - ...PluginError - } - plugin { - ...PluginsDetails - } - } - } -`; diff --git a/src/plugins/queries.ts b/src/plugins/queries.ts deleted file mode 100644 index 3987a30cab9..00000000000 --- a/src/plugins/queries.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { gql } from "@apollo/client"; - -export const pluginsList = gql` - query Plugins( - $first: Int - $after: String - $last: Int - $before: String - $filter: PluginFilterInput - $sort: PluginSortingInput - ) { - plugins( - before: $before - after: $after - first: $first - last: $last - filter: $filter - sortBy: $sort - ) { - edges { - node { - ...PluginBase - } - } - pageInfo { - hasPreviousPage - hasNextPage - startCursor - endCursor - } - } - } -`; - -export const pluginsDetails = gql` - query Plugin($id: ID!) { - plugin(id: $id) { - ...PluginsDetails - } - } -`; diff --git a/src/plugins/urls.ts b/src/plugins/urls.ts deleted file mode 100644 index ad03bf683e5..00000000000 --- a/src/plugins/urls.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Dialog, SingleAction } from "../types"; - -type PluginUrlDialog = "clear" | "edit"; -export type PluginUrlQueryParams = Dialog & SingleAction; From 66837f995f59af14d969925986787f08297137bd Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Thu, 2 Oct 2025 08:24:51 +0200 Subject: [PATCH 6/9] moving files from apps to extenisons deleting files wip moving files wip wip clean queries fxies --- src/apps/apps-debug.ts | 4 - src/apps/appstore.types.ts | 45 - .../AppAdditionalInfo/AppAdditionalInfo.tsx | 52 - .../components/AppAdditionalInfo/messages.ts | 19 - .../AppAlerts/AppRowDisabledAlert.tsx | 55 - .../AppAlerts/AppRowWebhookIssueAlert.tsx | 72 - .../AppDeactivateDialog.test.tsx | 122 - .../AppDeactivateDialog.tsx | 65 - .../AppDeactivateDialog/messages.ts | 27 - src/apps/components/AppFrame/AppFrame.tsx | 111 - src/apps/components/AppFrame/AppIFrame.tsx | 53 - .../AppFrame/appActionsHandler.test.ts | 317 - .../components/AppFrame/appActionsHandler.ts | 236 - src/apps/components/AppFrame/styles.ts | 22 - src/apps/components/AppFrame/useAppActions.ts | 86 - .../AppFrame/useAppDashboardUpdates.ts | 57 - .../components/AppFrame/usePostToExtension.ts | 20 - .../components/AppFrame/useTokenRefresh.ts | 62 - .../AppFrame/useUpdateAppToken.test.ts | 70 - .../components/AppFrame/useUpdateAppToken.ts | 53 - .../AppInProgressDeleteDialog.test.tsx | 70 - .../AppInProgressDeleteDialog.tsx | 50 - .../AppInProgressDeleteDialog/messages.ts | 20 - .../AppListRow/AppListCardActions.tsx | 79 - .../AppListRow/AppListCardDescription.tsx | 39 - .../AppListRow/AppListCardInstallButton.tsx | 50 - .../AppListRow/AppListCardIntegrations.tsx | 56 - .../AppListRow/AppListCardLinks.tsx | 29 - .../components/AppListRow/AppListRow.test.tsx | 239 - src/apps/components/AppListRow/AppListRow.tsx | 89 - src/apps/components/AppListRow/AppLogo.tsx | 21 - .../AppListRow/ErrorInstallAction.tsx | 68 - src/apps/components/AppListRow/messages.ts | 24 - .../InstalledAppListRow/AppManifestUrl.tsx | 49 - .../InstalledAppListRow.test.tsx | 136 - .../InstalledAppListRow.tsx | 118 - .../InstalledAppListRow/messages.ts | 14 - .../NotInstalledAppListRow.test.tsx | 93 - .../NotInstalledAppListRow.tsx | 109 - .../NotInstalledAppListRow/styles.ts | 83 - src/apps/context.ts | 18 - src/apps/fixtures.ts | 221 - .../hooks/useActiveAppsInstallations.test.ts | 115 - src/apps/hooks/useActiveAppsInstallations.ts | 177 - src/apps/hooks/useAppstoreApps.test.ts | 58 - src/apps/hooks/useAppstoreApps.ts | 97 - .../useGetAvailableAppPermissions.test.ts | 95 - .../hooks/useGetAvailableAppPermissions.ts | 45 - src/apps/messages.ts | 42 - src/apps/mutations.ts | 175 - src/apps/queries.ts | 103 - src/apps/types.ts | 26 - src/apps/urls.ts | 120 - src/apps/utils.test.ts | 259 - src/apps/utils.ts | 93 - .../CollectionDetailsPage.tsx | 2 +- .../Sidebar/menu/hooks/useMenuStructure.tsx | 4 +- .../CustomerDetailsPage.tsx | 2 +- .../VoucherDetailsPage/VoucherDetailsPage.tsx | 2 +- src/extensions/appstore.types.ts | 43 - .../AppAlerts/AlertExclamationIcon.tsx | 0 .../AppAlerts/SidebarAppAlert.test.tsx | 0 .../components/AppAlerts/SidebarAppAlert.tsx | 2 +- .../components/AppAlerts/queries.ts | 0 .../components/AppAlerts/useAppsAlert.ts | 0 .../AppAlerts/useAppsFailedDeliveries.test.ts | 0 .../AppAlerts/useAppsFailedDeliveries.ts | 0 .../AppAlerts/useSidebarDotState.test.ts | 0 .../AppAlerts/useSidebarDotState.ts | 0 .../useSidebarWebhookAlertMetadata.test.ts | 0 .../useSidebarWebhookAlertMetadata.ts | 0 .../components/AppAlerts/utils.test.ts | 0 .../components/AppAlerts/utils.ts | 0 .../components/AppAvatar/AppAvatar.tsx | 3 +- .../AppWebhooksAttemptDetails.tsx | 0 .../EventDeliveriesList.test.tsx | 0 .../EventDeliveriesList.tsx | 0 .../EventDeliveriesStatus.tsx | 0 .../AppWebhooksDisplay/EventDeliveryItem.tsx | 0 .../AppWebhooksDisplay/utils.test.ts | 0 .../components/AppWebhooksDisplay/utils.ts | 0 .../components/AppWidgets/AppWidgets.tsx | 9 +- .../ExternalAppContext/ExternalAppContext.tsx | 2 +- .../components/ExternalAppContext/context.ts | 2 +- src/extensions/fixtures.ts | 247 +- .../getPermissionsDiff.test.ts | 0 .../getPermissionsDiff.ts | 1 - src/extensions/hooks/useExtensions.ts | 2 +- src/{apps => extensions}/isUrlAbsolute.ts | 1 - src/extensions/mutations.ts | 158 + src/extensions/queries.ts | 84 +- src/extensions/types.ts | 4 + src/{apps => extensions}/urls.test.ts | 2 +- src/extensions/urls.ts | 64 +- .../AppPermissionsDialog.tsx | 2 +- .../AppPermissionsDialogState.ts | 2 +- .../EditManifestExtensionPermissions.tsx | 4 +- .../IconsSection.tsx | 2 +- .../hooks/useActiveAppsInstallations.ts | 2 +- .../hooks/useInstalledExtensions.test.tsx | 2 +- .../hooks/useInstalledExtensions.tsx | 4 +- .../components/AppFrame/appActionsHandler.ts | 3 +- .../AppFrame/useAppDashboardUpdates.ts | 2 +- .../components/AppPage/AppPageNav.tsx | 4 +- .../GiftCardHistory/GiftCardTimelineEvent.tsx | 3 +- .../GiftCardUpdate/GiftCardUpdatePage.tsx | 2 +- src/graphql/hooks.generated.ts | 7220 ++++++++--------- src/graphql/types.generated.ts | 258 +- src/hooks/useLocationState.ts | 3 +- .../OrderDetailsPage/OrderDetailsPage.tsx | 2 +- .../OrderDraftPage/OrderDraftPage.tsx | 2 +- .../components/EventCreatedBy.test.tsx | 2 +- .../ProductUpdatePage/ProductUpdatePage.tsx | 2 +- src/taxes/components/TaxAppLabel.tsx | 2 +- 114 files changed, 4066 insertions(+), 8719 deletions(-) delete mode 100644 src/apps/apps-debug.ts delete mode 100644 src/apps/appstore.types.ts delete mode 100644 src/apps/components/AppAdditionalInfo/AppAdditionalInfo.tsx delete mode 100644 src/apps/components/AppAdditionalInfo/messages.ts delete mode 100644 src/apps/components/AppAlerts/AppRowDisabledAlert.tsx delete mode 100644 src/apps/components/AppAlerts/AppRowWebhookIssueAlert.tsx delete mode 100644 src/apps/components/AppDeactivateDialog/AppDeactivateDialog.test.tsx delete mode 100644 src/apps/components/AppDeactivateDialog/AppDeactivateDialog.tsx delete mode 100644 src/apps/components/AppDeactivateDialog/messages.ts delete mode 100644 src/apps/components/AppFrame/AppFrame.tsx delete mode 100644 src/apps/components/AppFrame/AppIFrame.tsx delete mode 100644 src/apps/components/AppFrame/appActionsHandler.test.ts delete mode 100644 src/apps/components/AppFrame/appActionsHandler.ts delete mode 100644 src/apps/components/AppFrame/styles.ts delete mode 100644 src/apps/components/AppFrame/useAppActions.ts delete mode 100644 src/apps/components/AppFrame/useAppDashboardUpdates.ts delete mode 100644 src/apps/components/AppFrame/usePostToExtension.ts delete mode 100644 src/apps/components/AppFrame/useTokenRefresh.ts delete mode 100644 src/apps/components/AppFrame/useUpdateAppToken.test.ts delete mode 100644 src/apps/components/AppFrame/useUpdateAppToken.ts delete mode 100644 src/apps/components/AppInProgressDeleteDialog/AppInProgressDeleteDialog.test.tsx delete mode 100644 src/apps/components/AppInProgressDeleteDialog/AppInProgressDeleteDialog.tsx delete mode 100644 src/apps/components/AppInProgressDeleteDialog/messages.ts delete mode 100644 src/apps/components/AppListRow/AppListCardActions.tsx delete mode 100644 src/apps/components/AppListRow/AppListCardDescription.tsx delete mode 100644 src/apps/components/AppListRow/AppListCardInstallButton.tsx delete mode 100644 src/apps/components/AppListRow/AppListCardIntegrations.tsx delete mode 100644 src/apps/components/AppListRow/AppListCardLinks.tsx delete mode 100644 src/apps/components/AppListRow/AppListRow.test.tsx delete mode 100644 src/apps/components/AppListRow/AppListRow.tsx delete mode 100644 src/apps/components/AppListRow/AppLogo.tsx delete mode 100644 src/apps/components/AppListRow/ErrorInstallAction.tsx delete mode 100644 src/apps/components/AppListRow/messages.ts delete mode 100644 src/apps/components/InstalledAppListRow/AppManifestUrl.tsx delete mode 100644 src/apps/components/InstalledAppListRow/InstalledAppListRow.test.tsx delete mode 100644 src/apps/components/InstalledAppListRow/InstalledAppListRow.tsx delete mode 100644 src/apps/components/InstalledAppListRow/messages.ts delete mode 100644 src/apps/components/NotInstalledAppListRow/NotInstalledAppListRow.test.tsx delete mode 100644 src/apps/components/NotInstalledAppListRow/NotInstalledAppListRow.tsx delete mode 100644 src/apps/components/NotInstalledAppListRow/styles.ts delete mode 100644 src/apps/context.ts delete mode 100644 src/apps/fixtures.ts delete mode 100644 src/apps/hooks/useActiveAppsInstallations.test.ts delete mode 100644 src/apps/hooks/useActiveAppsInstallations.ts delete mode 100644 src/apps/hooks/useAppstoreApps.test.ts delete mode 100644 src/apps/hooks/useAppstoreApps.ts delete mode 100644 src/apps/hooks/useGetAvailableAppPermissions.test.ts delete mode 100644 src/apps/hooks/useGetAvailableAppPermissions.ts delete mode 100644 src/apps/messages.ts delete mode 100644 src/apps/mutations.ts delete mode 100644 src/apps/queries.ts delete mode 100644 src/apps/types.ts delete mode 100644 src/apps/urls.ts delete mode 100644 src/apps/utils.test.ts delete mode 100644 src/apps/utils.ts delete mode 100644 src/extensions/appstore.types.ts rename src/{apps => extensions}/components/AppAlerts/AlertExclamationIcon.tsx (100%) rename src/{apps => extensions}/components/AppAlerts/SidebarAppAlert.test.tsx (100%) rename src/{apps => extensions}/components/AppAlerts/SidebarAppAlert.tsx (94%) rename src/{apps => extensions}/components/AppAlerts/queries.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useAppsAlert.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useAppsFailedDeliveries.test.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useAppsFailedDeliveries.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useSidebarDotState.test.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useSidebarDotState.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useSidebarWebhookAlertMetadata.test.ts (100%) rename src/{apps => extensions}/components/AppAlerts/useSidebarWebhookAlertMetadata.ts (100%) rename src/{apps => extensions}/components/AppAlerts/utils.test.ts (100%) rename src/{apps => extensions}/components/AppAlerts/utils.ts (100%) rename src/{apps => extensions}/components/AppAvatar/AppAvatar.tsx (89%) rename src/{apps => extensions}/components/AppWebhooksDisplay/AppWebhooksAttemptDetails.tsx (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/EventDeliveriesList.test.tsx (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/EventDeliveriesList.tsx (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/EventDeliveriesStatus.tsx (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/EventDeliveryItem.tsx (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/utils.test.ts (100%) rename src/{apps => extensions}/components/AppWebhooksDisplay/utils.ts (100%) rename src/{apps => extensions}/components/AppWidgets/AppWidgets.tsx (97%) rename src/{apps => extensions}/getPermissionsDiff.test.ts (100%) rename src/{apps => extensions}/getPermissionsDiff.ts (91%) rename src/{apps => extensions}/isUrlAbsolute.ts (73%) rename src/{apps => extensions}/urls.test.ts (97%) diff --git a/src/apps/apps-debug.ts b/src/apps/apps-debug.ts deleted file mode 100644 index 1572ac0fbb7..00000000000 --- a/src/apps/apps-debug.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { createDebug } from "@dashboard/debug"; - -/** @deprecated use utility from extensions/ */ -export const createAppsDebug = (namespace: string) => createDebug(`apps:${namespace}`); diff --git a/src/apps/appstore.types.ts b/src/apps/appstore.types.ts deleted file mode 100644 index 66585c94b3b..00000000000 --- a/src/apps/appstore.types.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Interfaces for shapes of data fetched from AppStore API. - * @deprecated This Appstore SDK is deprecated, and was replaced by Extensions endpoint - * It's now used in extensions/ - */ -// eslint-disable-next-line @typescript-eslint/no-namespace -export namespace AppstoreApi { - export interface SaleorAppBase { - name: { - en: string; - }; - description: { - en: string; - }; - logo: { - source: string | null; - color: string; - }; - integrations: Array<{ - name: string; - logo: { - light: { - source: string; - }; - dark: { - source: string; - }; - }; - }>; - } - - export type ReleasedSaleorApp = SaleorAppBase & { - repositoryUrl: string; - supportUrl: string; - privacyUrl: string; - manifestUrl: string | null; - githubForkUrl?: string; - }; - - export type ComingSoonSaleorApp = SaleorAppBase & { - releaseDate: string; - }; - - export type SaleorApp = ReleasedSaleorApp | ComingSoonSaleorApp; -} diff --git a/src/apps/components/AppAdditionalInfo/AppAdditionalInfo.tsx b/src/apps/components/AppAdditionalInfo/AppAdditionalInfo.tsx deleted file mode 100644 index dc83352bb7f..00000000000 --- a/src/apps/components/AppAdditionalInfo/AppAdditionalInfo.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { AppPermissionFragment } from "@dashboard/graphql"; -import { Box, InfoIcon, Text, Tooltip } from "@saleor/macaw-ui-next"; -import moment from "moment"; -import { PropsWithChildren } from "react"; -import { FormattedMessage } from "react-intl"; - -import { messages } from "./messages"; - -export const AppAdditionalInfo = ({ - permissions, - created, -}: PropsWithChildren<{ - permissions?: AppPermissionFragment[] | null; - created: string | null; -}>) => { - return ( - - - - - - - - - - - - - {permissions?.length ? ( - permissions?.map(permission => ( - - {permission.name} - - )) - ) : ( - - - - )} - - {created && ( - <> - - - - {moment(created).format("YYYY-MM-DD HH:mm")} - - )} - - - ); -}; diff --git a/src/apps/components/AppAdditionalInfo/messages.ts b/src/apps/components/AppAdditionalInfo/messages.ts deleted file mode 100644 index 72f97daf7e0..00000000000 --- a/src/apps/components/AppAdditionalInfo/messages.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { defineMessages } from "react-intl"; - -export const messages = defineMessages({ - appPermissions: { - id: "xNfh4L", - defaultMessage: "App permissions", - description: "app permissions tooltip header", - }, - noPermissions: { - id: "lSd5Zo", - defaultMessage: "None", - description: "app permissions label", - }, - createdAt: { - id: "wRvjoc", - defaultMessage: "Created at", - description: "app created at label", - }, -}); diff --git a/src/apps/components/AppAlerts/AppRowDisabledAlert.tsx b/src/apps/components/AppAlerts/AppRowDisabledAlert.tsx deleted file mode 100644 index ff793fcbe07..00000000000 --- a/src/apps/components/AppAlerts/AppRowDisabledAlert.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { AppPaths } from "@dashboard/apps/urls"; -import Link from "@dashboard/components/Link"; -import { AppListItemFragment } from "@dashboard/graphql"; -import { DisabledIcon } from "@dashboard/icons/Disabled"; -import { Box, Text, Tooltip } from "@saleor/macaw-ui-next"; -import { FormattedMessage } from "react-intl"; - -interface AppRowDisabledAlertProps { - app: AppListItemFragment; -} - -export const AppRowDisabledAlert = ({ app }: AppRowDisabledAlertProps) => { - if (app.isActive) { - return null; - } - - const detailsLink = AppPaths.resolveAppDetailsPath(app.id); - - return ( - - - - - - - - - - - - - - - - - - - - - - ), - }} - /> - - - - - - ); -}; diff --git a/src/apps/components/AppAlerts/AppRowWebhookIssueAlert.tsx b/src/apps/components/AppAlerts/AppRowWebhookIssueAlert.tsx deleted file mode 100644 index 869565413ef..00000000000 --- a/src/apps/components/AppAlerts/AppRowWebhookIssueAlert.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { AppPaths } from "@dashboard/apps/urls"; -import EventTime from "@dashboard/components/EventTime"; -import Link from "@dashboard/components/Link"; -import { AppListItemFragment } from "@dashboard/graphql"; -import { ExclamationIcon } from "@dashboard/icons/ExclamationIcon"; -import { Box, Text, Tooltip } from "@saleor/macaw-ui-next"; -import { useMemo } from "react"; -import { FormattedMessage } from "react-intl"; - -import { AlertExclamationIcon } from "../AppAlerts/AlertExclamationIcon"; -import { getLatestFailedAttemptFromWebhooks } from "./utils"; - -interface AppRowWebhookIssueAlertProps { - app: AppListItemFragment; -} - -export const AppRowWebhookIssueAlert = ({ app }: AppRowWebhookIssueAlertProps) => { - const latestFailedAttempt = useMemo( - () => app.webhooks && getLatestFailedAttemptFromWebhooks(app.webhooks), - [app], - ); - - if (!latestFailedAttempt) { - return null; - } - - const detailsLink = AppPaths.resolveAppDetailsPath(app.id); - - return ( - - - - - - - - - - - - - - - - - - - , - viewDetails: ( - - - - ), - break:
, - }} - /> -
-
-
-
-
- ); -}; diff --git a/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.test.tsx b/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.test.tsx deleted file mode 100644 index f363f60b6d3..00000000000 --- a/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.test.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import Wrapper from "@test/wrapper"; -import { render, screen } from "@testing-library/react"; - -import { AppDeactivateDialog } from "./AppDeactivateDialog"; -import msgs from "./messages"; - -describe("Apps AppDeactivateDialog", () => { - it("displays action text with app name when third-party app name passed", () => { - // Arrange - const name = "Test App"; - - render( - - - , - ); - - const dialogContent = screen.getByTestId("dialog-content"); - // Assert - const expectedActionText = msgs.deactivateNamedApp.defaultMessage.replace("{name}", name); - const expectedBillingWarning = msgs.deactivateAppBillingInfo.defaultMessage; - - expect(dialogContent).toHaveTextContent(expectedActionText); - expect(dialogContent).toHaveTextContent(expectedBillingWarning); - }); - it("displays action text without app name when third-party app name is empty", () => { - // Arrange - render( - - - , - ); - - const dialogContent = screen.getByTestId("dialog-content"); - // Assert - const expectedText = msgs.deactivateApp.defaultMessage; - const expectedBillingWarning = msgs.deactivateAppBillingInfo.defaultMessage; - - expect(dialogContent).toHaveTextContent(expectedText); - expect(dialogContent).toHaveTextContent(expectedBillingWarning); - }); - it("displays action text without app name when third-party app name is null", () => { - // Arrange - render( - - - , - ); - - const dialogContent = screen.getByTestId("dialog-content"); - // Assert - const expectedText = msgs.deactivateApp.defaultMessage; - const expectedBillingWarning = msgs.deactivateAppBillingInfo.defaultMessage; - - expect(dialogContent).toHaveTextContent(expectedText); - expect(dialogContent).toHaveTextContent(expectedBillingWarning); - }); - it("displays billing warning when app is marked explicitly as third-party", () => { - // Arrange - const name = "Test App"; - - render( - - - , - ); - - const dialogContent = screen.getByTestId("dialog-content"); - // Assert - const expectedBillingWarning = msgs.deactivateAppBillingInfo.defaultMessage; - - expect(dialogContent).toHaveTextContent(expectedBillingWarning); - }); - it("doesn't display billing warning when app is marked explicitly as not third-party", () => { - // Arrange - const name = "Test App"; - - render( - - - , - ); - - const dialogContent = screen.getByTestId("dialog-content"); - // Assert - const notExpectedBillingWarning = msgs.deactivateAppBillingInfo.defaultMessage; - - expect(dialogContent).not.toHaveTextContent(notExpectedBillingWarning); - }); -}); diff --git a/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.tsx b/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.tsx deleted file mode 100644 index 192e12d7190..00000000000 --- a/src/apps/components/AppDeactivateDialog/AppDeactivateDialog.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import ActionDialog from "@dashboard/components/ActionDialog"; -import { ConfirmButtonTransitionState } from "@dashboard/components/ConfirmButton"; -import { buttonMessages } from "@dashboard/intl"; -import { getStringOrPlaceholder } from "@dashboard/misc"; -import { Box } from "@saleor/macaw-ui-next"; -import { PropsWithChildren } from "react"; -import { FormattedMessage, useIntl } from "react-intl"; - -import msgs from "./messages"; - -/** @deprecated use component from extensions/ */ -interface AppDeactivateDialogProps { - confirmButtonState: ConfirmButtonTransitionState; - open: boolean; - name?: string | null; - thirdParty?: boolean; - onClose: () => void; - onConfirm: () => void; -} - -/** @deprecated use component from extensions/ */ -export const AppDeactivateDialog = ({ - confirmButtonState, - open, - name, - thirdParty = true, - onClose, - onConfirm, -}: PropsWithChildren) => { - const intl = useIntl(); - const isNameMissing = name === null || name === ""; - const getMainText = () => { - if (isNameMissing) { - return intl.formatMessage(msgs.deactivateApp); - } - - return intl.formatMessage(msgs.deactivateNamedApp, { - name: {getStringOrPlaceholder(name)}, - }); - }; - - return ( - - - {getMainText()} - {thirdParty && ( - <> - {" "} - - - )} - - - ); -}; - -AppDeactivateDialog.displayName = "AppDeactivateDialog"; diff --git a/src/apps/components/AppDeactivateDialog/messages.ts b/src/apps/components/AppDeactivateDialog/messages.ts deleted file mode 100644 index 60444320a36..00000000000 --- a/src/apps/components/AppDeactivateDialog/messages.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { defineMessages } from "react-intl"; - -/** @deprecated use messages from extensions/ */ -export default defineMessages({ - deactivateAppTitle: { - id: "0d6W6p", - defaultMessage: "Deactivate App", - description: "dialog header", - }, - deactivateApp: { - id: "Xu4ech", - defaultMessage: - "Are you sure you want to disable this app? Your data will be kept until you reactivate the app.", - description: "deactivate app", - }, - deactivateNamedApp: { - id: "O987DI", - defaultMessage: - "Are you sure you want to disable {name}? Your data will be kept until you reactivate the app.", - description: "deactivate named app", - }, - deactivateAppBillingInfo: { - id: "94oZR0", - defaultMessage: "You will be still billed for the app.", - description: "deactivate app billing info", - }, -}); diff --git a/src/apps/components/AppFrame/AppFrame.tsx b/src/apps/components/AppFrame/AppFrame.tsx deleted file mode 100644 index d99f693fb9b..00000000000 --- a/src/apps/components/AppFrame/AppFrame.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import { useAppDashboardUpdates } from "@dashboard/apps/components/AppFrame/useAppDashboardUpdates"; -import { useUpdateAppToken } from "@dashboard/apps/components/AppFrame/useUpdateAppToken"; -import { AppDetailsUrlQueryParams } from "@dashboard/apps/urls"; -import { useAllFlags } from "@dashboard/featureFlags"; -import { CircularProgress } from "@material-ui/core"; -import { DashboardEventFactory } from "@saleor/app-sdk/app-bridge"; -import clsx from "clsx"; -import { PropsWithChildren, useCallback, useRef } from "react"; - -import { AppIFrame } from "./AppIFrame"; -import { useStyles } from "./styles"; -import { useAppActions } from "./useAppActions"; -import { useTokenRefresh } from "./useTokenRefresh"; - -interface Props { - src: string; - appToken: string; - appId: string; - className?: string; - params?: AppDetailsUrlQueryParams; - refetch?: () => void; - dashboardVersion: string; - coreVersion?: string; - onError?: () => void; -} - -const getOrigin = (url: string) => new URL(url).origin; - -/** @deprecated Use component from extensions/ */ -export const AppFrame = ({ - src, - appToken, - appId, - className, - params, - onError, - refetch, - dashboardVersion, - coreVersion = "", -}: PropsWithChildren) => { - const frameRef = useRef(null); - const classes = useStyles(); - const appOrigin = getOrigin(src); - const flags = useAllFlags(); - /** - * React on messages from App - */ - const { postToExtension, handshakeDone, setHandshakeDone } = useAppActions( - frameRef.current, - appOrigin, - appId, - appToken, - { - core: coreVersion, - dashboard: dashboardVersion, - }, - ); - - /** - * Listen to Dashboard context like theme or locale and inform app about it - */ - useAppDashboardUpdates(frameRef.current, appOrigin, handshakeDone, appId); - useTokenRefresh(appToken, refetch); - - const handleLoad = useCallback(() => { - /** - * @deprecated - * - * Move handshake to notifyReady, so app is requesting token after it's ready to receive it - * Currently handshake it 2 times, for compatibility - */ - postToExtension( - DashboardEventFactory.createHandshakeEvent(appToken, 1, { - core: coreVersion, - dashboard: dashboardVersion, - }), - ); - setHandshakeDone(true); - }, [appToken, postToExtension, setHandshakeDone]); - - useUpdateAppToken({ - postToExtension, - appToken, - /** - * If app is not ready, ignore this flow - */ - enabled: handshakeDone, - }); - - return ( - <> - {!handshakeDone && ( -
- -
- )} - - - ); -}; diff --git a/src/apps/components/AppFrame/AppIFrame.tsx b/src/apps/components/AppFrame/AppIFrame.tsx deleted file mode 100644 index c2750d63ff7..00000000000 --- a/src/apps/components/AppFrame/AppIFrame.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { AppDetailsUrlQueryParams, AppUrls } from "@dashboard/apps/urls"; -import { FlagList } from "@dashboard/featureFlags"; -import { ThemeType } from "@saleor/app-sdk/app-bridge"; -import { useTheme } from "@saleor/macaw-ui"; -import isEqualWith from "lodash/isEqualWith"; -import { forwardRef, memo, useEffect, useRef } from "react"; - -interface AppIFrameProps { - appId: string; - src: string; - featureFlags: FlagList; - params?: AppDetailsUrlQueryParams; - onLoad: () => void; - onError?: () => void; - className: string; -} - -/** @deprecated Use component from extensions/ */ -const _AppIFrame = forwardRef( - ({ appId, src, featureFlags, params, onLoad, onError, className }, ref) => { - const themeRef = useRef(); - const { themeType } = useTheme(); - - // Ignore updates to themeType - iframe will be notified via events - // Otherwise this will cause reload of entire iframe - useEffect(() => { - themeRef.current = themeType; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - const iframeSrc = AppUrls.resolveAppIframeUrl(appId, src, { - ...params, - featureFlags, - theme: themeRef.current!, - }); - - return ( -