Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Allow user to change only yours avatar
Krzysztof Bialoglowicza18266fda9d3
diff --git a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsxindex dfa9837874..2c8be02f99 100644--- a/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffDetailsPage/StaffDetailsPage.tsx@@ -29,6 +29,7 @@ interface FormData {}export interface StaffDetailsPageProps {+ canEditAvatar: boolean;canEditStatus: boolean;canRemove: boolean;disabled: boolean;@@ -43,6 +44,7 @@ export interface StaffDetailsPageProps {}const StaffDetailsPage: React.StatelessComponent<StaffDetailsPageProps> = ({+ canEditAvatar,canEditStatus,canRemove,disabled,@@ -83,6 +85,7 @@ const StaffDetailsPage: React.StatelessComponent<StaffDetailsPageProps> = ({<StaffPropertiesdata={data}disabled={disabled}+ canEditAvatar={canEditAvatar}staffMember={staffMember}onChange={change}onImageUpload={onImageUpload}diff --git a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsxindex af87587138..8266158826 100644--- a/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx+++ b/saleor/static/dashboard-next/staff/components/StaffProperties/StaffProperties.tsx@@ -13,7 +13,7 @@ import SVG from "react-inlinesvg";import CardTitle from "../../../components/CardTitle";import i18n from "../../../i18n";-import { maybe, getUserInitials } from "../../../misc";+import { getUserInitials, maybe } from "../../../misc";import { StaffMemberDetails_user } from "../../types/StaffMemberDetails";import * as photoIcon from "../../../../images/photo-icon.svg";@@ -96,6 +96,7 @@ const styles = (theme: Theme) =>});interface StaffPropertiesProps extends WithStyles<typeof styles> {+ canEditAvatar: boolean;className?: string;data: {email: string;@@ -111,6 +112,7 @@ interface StaffPropertiesProps extends WithStyles<typeof styles> {const StaffProperties = withStyles(styles, { name: "StaffProperties" })(({+ canEditAvatar,classes,className,data,@@ -138,22 +140,24 @@ const StaffProperties = withStyles(styles, { name: "StaffProperties" })(<Typography>{getUserInitials(data)}</Typography></div>)}- <div className={classes.avatarHover}>- <SVG src={photoIcon} />- <Typography onClick={clickImgInput}>- {i18n.t("Change photo")}- </Typography>- <Typography onClick={onImageDelete}>- {i18n.t("Delete photo")}- </Typography>- <input- className={classes.fileField}- id="fileUpload"- onChange={event => onImageUpload(event.target.files[0])}- type="file"- ref={imgInputAnchor}- />- </div>+ {canEditAvatar && (+ <div className={classes.avatarHover}>+ <SVG src={photoIcon} />+ <Typography onClick={clickImgInput}>+ {i18n.t("Change photo")}+ </Typography>+ <Typography onClick={onImageDelete}>+ {i18n.t("Delete photo")}+ </Typography>+ <input+ className={classes.fileField}+ id="fileUpload"+ onChange={event => onImageUpload(event.target.files[0])}+ type="file"+ ref={imgInputAnchor}+ />+ </div>+ )}</div></div><div>diff --git a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx b/saleor/static/dashboard-next/staff/views/StaffDetails.tsxindex 43702415ae..f90affe3e5 100644--- a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx+++ b/saleor/static/dashboard-next/staff/views/StaffDetails.tsx@@ -122,6 +122,7 @@ export const StaffDetails: React.StatelessComponent<OrderListProps> = ({title={maybe(() => data.user.email)}/><StaffDetailsPage+ canEditAvatar={isUserSameAsViewer}canEditStatus={!isUserSameAsViewer}canRemove={!isUserSameAsViewer}disabled={loading}diff --git a/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsxindex 4e74dda319..8de348dc9b 100644--- a/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/staff/StaffDetailsPage.tsx@@ -9,6 +9,7 @@ import { permissions, staffMember } from "../../../staff/fixtures";import Decorator from "../../Decorator";const props: Omit<StaffDetailsPageProps, "classes"> = {+ canEditAvatar: true,canEditStatus: true,canRemove: true,disabled: false,