Add permissions to shipping settings
This commit is contained in:
parent
5a17d4dc4c
commit
05ca8effd5
2 changed files with 30 additions and 9 deletions
|
@ -5,14 +5,20 @@ import AppHeader from "@saleor/components/AppHeader";
|
|||
import Container from "@saleor/components/Container";
|
||||
import Grid from "@saleor/components/Grid";
|
||||
import PageHeader from "@saleor/components/PageHeader";
|
||||
import RequirePermissions, {
|
||||
hasPermissions
|
||||
} from "@saleor/components/RequirePermissions";
|
||||
import { sectionNames } from "@saleor/intl";
|
||||
import { ListActions, PageListProps } from "@saleor/types";
|
||||
import { WeightUnitsEnum } from "@saleor/types/globalTypes";
|
||||
import { ListActions, PageListProps, UserPermissionProps } from "@saleor/types";
|
||||
import { PermissionEnum, WeightUnitsEnum } from "@saleor/types/globalTypes";
|
||||
import { ShippingZoneFragment } from "../../types/ShippingZoneFragment";
|
||||
import ShippingWeightUnitForm from "../ShippingWeightUnitForm";
|
||||
import ShippingZonesList from "../ShippingZonesList";
|
||||
|
||||
export interface ShippingZonesListPageProps extends PageListProps, ListActions {
|
||||
export interface ShippingZonesListPageProps
|
||||
extends PageListProps,
|
||||
ListActions,
|
||||
UserPermissionProps {
|
||||
defaultWeightUnit: WeightUnitsEnum;
|
||||
shippingZones: ShippingZoneFragment[];
|
||||
onBack: () => void;
|
||||
|
@ -22,7 +28,14 @@ export interface ShippingZonesListPageProps extends PageListProps, ListActions {
|
|||
|
||||
const ShippingZonesListPage: React.StatelessComponent<
|
||||
ShippingZonesListPageProps
|
||||
> = ({ defaultWeightUnit, disabled, onBack, onSubmit, ...listProps }) => {
|
||||
> = ({
|
||||
defaultWeightUnit,
|
||||
disabled,
|
||||
userPermissions,
|
||||
onBack,
|
||||
onSubmit,
|
||||
...listProps
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
return (
|
||||
|
@ -41,11 +54,16 @@ const ShippingZonesListPage: React.StatelessComponent<
|
|||
<ShippingZonesList disabled={disabled} {...listProps} />
|
||||
</div>
|
||||
<div>
|
||||
<ShippingWeightUnitForm
|
||||
defaultWeightUnit={defaultWeightUnit}
|
||||
disabled={disabled}
|
||||
onSubmit={onSubmit}
|
||||
/>
|
||||
<RequirePermissions
|
||||
userPermissions={userPermissions}
|
||||
requiredPermissions={[PermissionEnum.MANAGE_SETTINGS]}
|
||||
>
|
||||
<ShippingWeightUnitForm
|
||||
defaultWeightUnit={defaultWeightUnit}
|
||||
disabled={disabled}
|
||||
onSubmit={onSubmit}
|
||||
/>
|
||||
</RequirePermissions>
|
||||
</div>
|
||||
</Grid>
|
||||
</Container>
|
||||
|
|
|
@ -14,6 +14,7 @@ import usePaginator, {
|
|||
createPaginationState
|
||||
} from "@saleor/hooks/usePaginator";
|
||||
import useShop from "@saleor/hooks/useShop";
|
||||
import useUser from "@saleor/hooks/useUser";
|
||||
import { commonMessages } from "@saleor/intl";
|
||||
import { getMutationState, maybe } from "@saleor/misc";
|
||||
import { ListViews } from "@saleor/types";
|
||||
|
@ -45,6 +46,7 @@ export const ShippingZonesList: React.StatelessComponent<
|
|||
const notify = useNotifier();
|
||||
const paginate = usePaginator();
|
||||
const shop = useShop();
|
||||
const { user } = useUser();
|
||||
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
|
||||
params.ids
|
||||
);
|
||||
|
@ -195,6 +197,7 @@ export const ShippingZonesList: React.StatelessComponent<
|
|||
<DeleteIcon />
|
||||
</IconButton>
|
||||
}
|
||||
userPermissions={maybe(() => user.permissions, [])}
|
||||
/>
|
||||
|
||||
<ActionDialog
|
||||
|
|
Loading…
Reference in a new issue