Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add user avatar management #4030

Merged
merged 16 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Ensure adding to quantities in checkout is respecting the limits set both in storefront 1.0 and in the API - #4005 by @NyanKiyoshi
- Fix price_range_as_dict function - #3999 by @zodiacfireworks
- Remove unused decorator - #4036 by @maarcingebala
- Add user avatar management - #4030 by @benekex2


## 2.5.0
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"generate-component": "plop --plopfile .plop/plopfile.js",
"heroku-postbuild": "npm run build-assets && npm run build-emails",
"lint": "tslint 'saleor/static/dashboard-next/**/*.{ts,tsx}'",
"lint-fix": "tslint 'saleor/static/dashboard-next/**/*.{ts,tsx}' --fix",
"start": "webpack -d --watch",
"build-emails": "mjml --config.beautify false -l skip \"templates/templated_email/source/*.mjml\" -o templates/templated_email/compiled",
"storybook": "start-storybook -p 3000 -c saleor/static/dashboard-next/storybook/",
Expand Down
20 changes: 10 additions & 10 deletions saleor/static/dashboard-next/categories/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyMQ==",
Expand All @@ -116,7 +116,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyMg==",
Expand All @@ -140,7 +140,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyMw==",
Expand All @@ -164,7 +164,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyNA==",
Expand All @@ -188,7 +188,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyNQ==",
Expand All @@ -212,7 +212,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyNg==",
Expand All @@ -236,7 +236,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyNw==",
Expand All @@ -260,7 +260,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyOA==",
Expand All @@ -284,7 +284,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDoyOQ==",
Expand All @@ -308,7 +308,7 @@ export const category: (
node: {
__typename: "Product",
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: true
},
id: "UHJvZHVjdDozMA==",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface CategoryDetails_category_products_pageInfo {
}

export interface CategoryDetails_category_products_edges_node_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
}

Expand Down
2 changes: 1 addition & 1 deletion saleor/static/dashboard-next/products/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const product: (
}
],
availability: {
__typename: "ProductAvailability",
__typename: "ProductPricingInfo",
available: false,
priceRange: {
__typename: "TaxedMoneyRange",
Expand Down
2 changes: 1 addition & 1 deletion saleor/static/dashboard-next/products/types/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface Product_availability_priceRange {
}

export interface Product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: Product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface ProductCreate_productCreate_product_availability_priceRange {
}

export interface ProductCreate_productCreate_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: ProductCreate_productCreate_product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface ProductDetails_product_availability_priceRange {
}

export interface ProductDetails_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: ProductDetails_product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ProductFragment_thumbnail {
}

export interface ProductFragment_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface ProductImageCreate_productImageCreate_product_availability_pric
}

export interface ProductImageCreate_productImageCreate_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: ProductImageCreate_productImageCreate_product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface ProductImageUpdate_productImageUpdate_product_availability_pric
}

export interface ProductImageUpdate_productImageUpdate_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: ProductImageUpdate_productImageUpdate_product_availability_priceRange | null;
}
Expand Down
2 changes: 1 addition & 1 deletion saleor/static/dashboard-next/products/types/ProductList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ProductList_products_edges_node_thumbnail {
}

export interface ProductList_products_edges_node_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface ProductUpdate_productUpdate_product_availability_priceRange {
}

export interface ProductUpdate_productUpdate_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: ProductUpdate_productUpdate_product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface SimpleProductUpdate_productUpdate_product_availability_priceRan
}

export interface SimpleProductUpdate_productUpdate_product_availability {
__typename: "ProductAvailability";
__typename: "ProductPricingInfo";
available: boolean | null;
priceRange: SimpleProductUpdate_productUpdate_product_availability_priceRange | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface FormData {
}

export interface StaffDetailsPageProps {
canEditAvatar: boolean;
canEditStatus: boolean;
canRemove: boolean;
disabled: boolean;
Expand All @@ -37,10 +38,13 @@ export interface StaffDetailsPageProps {
staffMember: StaffMemberDetails_user;
onBack: () => void;
onDelete: () => void;
onImageDelete: () => void;
onSubmit: (data: FormData) => void;
onImageUpload(file: File);
}

const StaffDetailsPage: React.StatelessComponent<StaffDetailsPageProps> = ({
canEditAvatar,
canEditStatus,
canRemove,
disabled,
Expand All @@ -49,6 +53,8 @@ const StaffDetailsPage: React.StatelessComponent<StaffDetailsPageProps> = ({
staffMember,
onBack,
onDelete,
onImageDelete,
onImageUpload,
onSubmit
}: StaffDetailsPageProps) => {
const initialForm: FormData = {
Expand Down Expand Up @@ -79,8 +85,11 @@ const StaffDetailsPage: React.StatelessComponent<StaffDetailsPageProps> = ({
<StaffProperties
data={data}
disabled={disabled}
canEditAvatar={canEditAvatar}
staffMember={staffMember}
onChange={change}
onImageUpload={onImageUpload}
onImageDelete={onImageDelete}
/>
</div>
{canEditStatus && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import * as React from "react";
import Skeleton from "../../../components/Skeleton";
import TablePagination from "../../../components/TablePagination";
import i18n from "../../../i18n";
import { getUserName, maybe, renderCollection } from "../../../misc";
import {
getUserInitials,
getUserName,
maybe,
renderCollection
} from "../../../misc";
import { ListProps } from "../../../types";
import { StaffList_staffUsers_edges_node } from "../../types/StaffList";

Expand All @@ -32,7 +37,18 @@ const styles = (theme: Theme) =>
height: 47,
justifyContent: "center",
marginRight: theme.spacing.unit * 1 + "px",
width: 37
overflow: "hidden",
width: 47
},
avatarDefault: {
"& p": {
color: "#fff",
lineHeight: "47px"
},
background: theme.palette.primary.main,
height: 47,
textAlign: "center",
width: 47
},
avatarImage: {
pointerEvents: "none",
Expand Down Expand Up @@ -104,10 +120,16 @@ const StaffList = withStyles(styles, { name: "StaffList" })(
>
<TableCell>
<div className={classes.avatar}>
<img
className={classes.avatarImage}
src={maybe(() => staffMember.avatar.url)}
/>
{maybe(() => staffMember.avatar.url) ? (
<img
className={classes.avatarImage}
src={maybe(() => staffMember.avatar.url)}
/>
) : (
<div className={classes.avatarDefault}>
<Typography>{getUserInitials(staffMember)}</Typography>
</div>
)}
</div>
<Typography>
{getUserName(staffMember) || <Skeleton />}
Expand Down
Loading