Skip to content

Commit

Permalink
Merge branch 'main' into merx-1259-new-home-page-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch authored Nov 19, 2024
2 parents d608749 + 163d0a2 commit 9d7d480
Show file tree
Hide file tree
Showing 35 changed files with 209 additions and 159 deletions.
5 changes: 0 additions & 5 deletions .changeset/chilly-hotels-melt.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/cuddly-spiders-wave.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/grumpy-worms-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

List item links are no longer rendered outside of cursor. This means you can now copy the item's URL with mouse right click or use middle click to open page in new tab.
5 changes: 0 additions & 5 deletions .changeset/nasty-grapes-attend.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/rare-mirrors-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

The "Save" button in Change Password form now submits the form data to Saleor.
5 changes: 5 additions & 0 deletions .changeset/soft-bears-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now select attribute value from dropdown in datagrid cell
5 changes: 0 additions & 5 deletions .changeset/wicked-meals-change.md

This file was deleted.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@material-ui/styles": "^4.11.4",
"@reach/auto-id": "^0.16.0",
"@saleor/macaw-ui": "npm:@saleor/[email protected]",
"@saleor/macaw-ui-next": "npm:@saleor/[email protected].12",
"@saleor/macaw-ui-next": "npm:@saleor/[email protected].15",
"@saleor/sdk": "0.6.0",
"@sentry/react": "^8.21.0",
"@sentry/vite-plugin": "^2.21.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "@dashboard/components/Datagrid/hooks/useDatagridChange";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { AttributeFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useNavigator from "@dashboard/hooks/useNavigator";
import { ListProps, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
Expand Down Expand Up @@ -69,9 +70,7 @@ export const AttributeListDatagrid = ({

if (rowData) {
navigate(attributeUrl(rowData.id), {
state: {
prevLocation: location,
},
state: getPrevLocationState(location),
});
}
},
Expand Down Expand Up @@ -120,6 +119,7 @@ export const AttributeListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "@dashboard/components/Datagrid/hooks/useDatagridChange";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { CategoryFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { PageListProps, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
import { Box } from "@saleor/macaw-ui-next";
Expand Down Expand Up @@ -105,11 +106,7 @@ export const CategoryListDatagrid = ({
staticColumns={staticColumns}
/>
)}
navigatorOpts={{
state: {
prevLocation: location,
},
}}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@dashboard/components/Datagrid/hooks/useDatagridChange";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { commonTooltipMessages } from "@dashboard/components/TooltipTableCellHeader/messages";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { ListProps, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
import { Box, useTheme } from "@saleor/macaw-ui-next";
Expand Down Expand Up @@ -157,6 +158,7 @@ export const CollectionListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DashboardCard } from "@dashboard/components/Card";
import { getByName } from "@dashboard/components/Filter/utils";
import { FilterPresetsSelect } from "@dashboard/components/FilterPresetsSelect";
import { ListPageLayout } from "@dashboard/components/Layouts";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useNavigator from "@dashboard/hooks/useNavigator";
import { sectionNames } from "@dashboard/intl";
import { FilterPageProps, PageListProps, SortPage } from "@dashboard/types";
Expand Down Expand Up @@ -143,9 +144,7 @@ const CollectionListPage: React.FC<CollectionListPageProps> = ({
filterDependency={filterDependency}
onRowClick={id => {
navigate(collectionUrl(id), {
state: {
prevLocation: location,
},
state: getPrevLocationState(location),
});
}}
hasRowHover={!isFilterPresetOpen}
Expand Down
9 changes: 1 addition & 8 deletions src/components/Card/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ export const Root: React.FC<PropsWithBox<{ children: React.ReactNode }>> = ({
children,
...rest
}) => (
<Box
display="flex"
flexDirection="column"
gap={5}
position="relative"
backgroundColor="default1"
{...rest}
>
<Box display="flex" flexDirection="column" gap={5} backgroundColor="default1" {...rest}>
{children}
</Box>
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TablePaginationWithContext } from "@dashboard/components/TablePaginatio
import { Customer, Customers } from "@dashboard/customers/types";
import { CustomerListUrlSortField } from "@dashboard/customers/urls";
import { PermissionEnum } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { ListProps, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
import { Box } from "@saleor/macaw-ui-next";
Expand Down Expand Up @@ -137,11 +138,7 @@ export const CustomerListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{
state: {
prevLocation: location,
},
}}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useEmptyColumn } from "@dashboard/components/Datagrid/hooks/useEmptyCol
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { DiscountListUrlSortField, discountUrl } from "@dashboard/discounts/discountsUrls";
import { PromotionFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { ListProps, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
import { Box } from "@saleor/macaw-ui-next";
Expand Down Expand Up @@ -121,6 +122,7 @@ export const DiscountListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
discountUrl,
} from "@dashboard/discounts/discountsUrls";
import { PromotionFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useNavigator from "@dashboard/hooks/useNavigator";
import { commonMessages } from "@dashboard/intl";
import { FilterPresetsProps, PageListProps, SortPage } from "@dashboard/types";
Expand Down Expand Up @@ -50,9 +51,7 @@ const DiscountListPage: React.FC<DiscountListPageProps> = ({
const [isFilterPresetOpen, setFilterPresetOpen] = useState(false);
const handleRowClick = (id: string) => {
navigation(discountUrl(id), {
state: {
prevLocation: location,
},
state: getPrevLocationState(location),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TablePaginationWithContext } from "@dashboard/components/TablePaginatio
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";
Expand Down Expand Up @@ -141,6 +142,7 @@ export const SaleListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
5 changes: 2 additions & 3 deletions src/discounts/components/SaleListPage/SaleListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FilterPresetsSelect } from "@dashboard/components/FilterPresetsSelect";
import { ListPageLayout } from "@dashboard/components/Layouts";
import { saleAddUrl, SaleListUrlSortField, saleUrl } from "@dashboard/discounts/urls";
import { SaleFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useNavigator from "@dashboard/hooks/useNavigator";
import { commonMessages } from "@dashboard/intl";
import {
Expand Down Expand Up @@ -60,9 +61,7 @@ const SaleListPage: React.FC<SaleListPageProps> = ({
const filterDependency = structure.find(getByName("channel"));
const handleRowClick = (id: string) => {
navigation(saleUrl(id), {
state: {
prevLocation: location,
},
state: getPrevLocationState(location),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { commonTooltipMessages } from "@dashboard/components/TooltipTableCellHea
import { VoucherListUrlSortField, voucherUrl } from "@dashboard/discounts/urls";
import { canBeSorted } from "@dashboard/discounts/views/VoucherList/sort";
import { VoucherFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useLocale from "@dashboard/hooks/useLocale";
import useNavigator from "@dashboard/hooks/useNavigator";
import { ChannelProps, ListProps, SortPage } from "@dashboard/types";
Expand Down Expand Up @@ -80,9 +81,7 @@ export const VoucherListDatagrid = ({

if (rowData) {
navigate(voucherUrl(rowData.id), {
state: {
prevLocation: location,
},
state: getPrevLocationState(location),
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
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";
import useNavigator from "@dashboard/hooks/useNavigator";
import usePaginator from "@dashboard/hooks/usePaginator";
import { Item } from "@glideapps/glide-data-grid";
Expand Down Expand Up @@ -171,11 +172,7 @@ export const GiftCardsListDatagrid = () => {
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{
state: {
prevLocation: location,
},
}}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/useBackLinkWithState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import { useEffect, useState } from "react";
import { useLocation } from "react-router";
import urljoin from "url-join";

type LocationData = Pick<Location, "pathname" | "search">;

type LocationWithState = Location & {
state?: {
prevLocation?: Location;
prevLocation?: LocationData;
};
};

export const getPrevLocationState = (location: LocationData) => ({
prevLocation: {
pathname: location.pathname,
search: location.search,
},
});

const getPreviousUrl = (location: LocationWithState) => {
if (!location.state?.prevLocation) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useDatagridChangeState,
} from "@dashboard/components/Datagrid/hooks/useDatagridChange";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import useLocale from "@dashboard/hooks/useLocale";
import { OrderDraft } from "@dashboard/orders/types";
import { OrderDraftListUrlSortField, orderUrl } from "@dashboard/orders/urls";
Expand Down Expand Up @@ -125,11 +126,7 @@ export const OrderDraftListDatagrid = ({
onToggle={handlers.onToggle}
/>
)}
navigatorOpts={{
state: {
prevLocation: location,
},
}}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
7 changes: 2 additions & 5 deletions src/orders/components/OrderListDatagrid/OrderListDatagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { useEmptyColumn } from "@dashboard/components/Datagrid/hooks/useEmptyColumn";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import { OrderListQuery } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { OrderListUrlSortField } from "@dashboard/orders/urls";
import { ListProps, RelayToFlat, SortPage } from "@dashboard/types";
import { Item } from "@glideapps/glide-data-grid";
Expand Down Expand Up @@ -129,11 +130,7 @@ export const OrderListDatagrid: React.FC<OrderListDatagridProps> = ({
)}
onRowClick={handleRowClick}
rowAnchor={handleRowAnchor}
navigatorOpts={{
state: {
prevLocation: location,
},
}}
navigatorOpts={{ state: getPrevLocationState(location) }}
/>

<Box paddingX={6}>
Expand Down
3 changes: 2 additions & 1 deletion src/pageTypes/components/PageTypeList/PageTypeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TableHead from "@dashboard/components/TableHead";
import { TablePaginationWithContext } from "@dashboard/components/TablePagination";
import TableRowLink from "@dashboard/components/TableRowLink";
import { PageTypeFragment } from "@dashboard/graphql";
import { getPrevLocationState } from "@dashboard/hooks/useBackLinkWithState";
import { PageTypeListUrlSortField, pageTypeUrl } from "@dashboard/pageTypes/urls";
import { getArrowDirection } from "@dashboard/utils/sort";
import { TableBody, TableCell, TableFooter } from "@material-ui/core";
Expand Down Expand Up @@ -86,7 +87,7 @@ const PageTypeList: React.FC<PageTypeListProps> = props => {
pageType
? {
pathname: pageTypeUrl(pageType.id),
state: { prevLocation: location },
state: getPrevLocationState(location),
}
: undefined
}
Expand Down
Loading

0 comments on commit 9d7d480

Please sign in to comment.