fixes afer merge

This commit is contained in:
Magdalena Markusik 2020-09-18 16:40:48 +02:00
parent 7631a7a281
commit d20b58dd79
28 changed files with 64 additions and 14 deletions

View file

@ -19,6 +19,7 @@ import CategoryDetailsForm from "../../components/CategoryDetailsForm";
export interface FormData extends MetadataFormData { export interface FormData extends MetadataFormData {
description: RawDraftContentState; description: RawDraftContentState;
name: string; name: string;
slug: string;
seoTitle: string; seoTitle: string;
seoDescription: string; seoDescription: string;
} }
@ -29,7 +30,8 @@ const initialData: FormData = {
name: "", name: "",
privateMetadata: [], privateMetadata: [],
seoDescription: "", seoDescription: "",
seoTitle: "" seoTitle: "",
slug: ""
}; };
export interface CategoryCreatePageProps { export interface CategoryCreatePageProps {
@ -81,6 +83,8 @@ export const CategoryCreatePage: React.FC<CategoryCreatePageProps> = ({
defaultMessage: defaultMessage:
"Add search engine title and description to make this category easier to find" "Add search engine title and description to make this category easier to find"
})} })}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle} title={data.seoTitle}
titlePlaceholder={data.name} titlePlaceholder={data.name}
description={data.seoDescription} description={data.seoDescription}

View file

@ -118,7 +118,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
name: category.name || "", name: category.name || "",
privateMetadata: category?.privateMetadata?.map(mapMetadataItemToInput), privateMetadata: category?.privateMetadata?.map(mapMetadataItemToInput),
seoDescription: category.seoDescription || "", seoDescription: category.seoDescription || "",
seoTitle: category.seoTitle || "" seoTitle: category.seoTitle || "",
slug: category?.slug || ""
} }
: { : {
backgroundImageAlt: "", backgroundImageAlt: "",
@ -127,7 +128,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
name: "", name: "",
privateMetadata: undefined, privateMetadata: undefined,
seoDescription: "", seoDescription: "",
seoTitle: "" seoTitle: "",
slug: ""
}; };
const handleSubmit = (data: FormData) => { const handleSubmit = (data: FormData) => {
@ -179,6 +181,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
titlePlaceholder={data.name} titlePlaceholder={data.name}
description={data.seoDescription} description={data.seoDescription}
descriptionPlaceholder={data.name} descriptionPlaceholder={data.name}
slug={data.slug}
slugPlaceholder={data.name}
loading={!category} loading={!category}
onChange={change} onChange={change}
disabled={disabled} disabled={disabled}

View file

@ -38,6 +38,7 @@ export interface CategoryCreate_categoryCreate_category {
privateMetadata: (CategoryCreate_categoryCreate_category_privateMetadata | null)[]; privateMetadata: (CategoryCreate_categoryCreate_category_privateMetadata | null)[];
backgroundImage: CategoryCreate_categoryCreate_category_backgroundImage | null; backgroundImage: CategoryCreate_categoryCreate_category_backgroundImage | null;
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoDescription: string | null; seoDescription: string | null;
seoTitle: string | null; seoTitle: string | null;

View file

@ -147,6 +147,7 @@ export interface CategoryDetails_category {
privateMetadata: (CategoryDetails_category_privateMetadata | null)[]; privateMetadata: (CategoryDetails_category_privateMetadata | null)[];
backgroundImage: CategoryDetails_category_backgroundImage | null; backgroundImage: CategoryDetails_category_backgroundImage | null;
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoDescription: string | null; seoDescription: string | null;
seoTitle: string | null; seoTitle: string | null;

View file

@ -38,6 +38,7 @@ export interface CategoryUpdate_categoryUpdate_category {
privateMetadata: (CategoryUpdate_categoryUpdate_category_privateMetadata | null)[]; privateMetadata: (CategoryUpdate_categoryUpdate_category_privateMetadata | null)[];
backgroundImage: CategoryUpdate_categoryUpdate_category_backgroundImage | null; backgroundImage: CategoryUpdate_categoryUpdate_category_backgroundImage | null;
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoDescription: string | null; seoDescription: string | null;
seoTitle: string | null; seoTitle: string | null;

View file

@ -28,6 +28,7 @@ export interface CollectionCreatePageFormData extends MetadataFormData {
backgroundImageAlt: string; backgroundImageAlt: string;
description: RawDraftContentState; description: RawDraftContentState;
name: string; name: string;
slug: string;
publicationDate: string; publicationDate: string;
isPublished: boolean; isPublished: boolean;
seoDescription: string; seoDescription: string;
@ -55,7 +56,8 @@ const initialForm: CollectionCreatePageFormData = {
privateMetadata: [], privateMetadata: [],
publicationDate: "", publicationDate: "",
seoDescription: "", seoDescription: "",
seoTitle: "" seoTitle: "",
slug: ""
}; };
const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({ const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
@ -140,6 +142,8 @@ const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
defaultMessage: defaultMessage:
"Add search engine title and description to make this collection easier to find" "Add search engine title and description to make this collection easier to find"
})} })}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle} title={data.seoTitle}
titlePlaceholder={data.name} titlePlaceholder={data.name}
onChange={change} onChange={change}

View file

@ -33,6 +33,7 @@ export interface CollectionDetailsPageFormData extends MetadataFormData {
backgroundImageAlt: string; backgroundImageAlt: string;
description: RawDraftContentState; description: RawDraftContentState;
name: string; name: string;
slug: string;
publicationDate: string; publicationDate: string;
seoDescription: string; seoDescription: string;
seoTitle: string; seoTitle: string;
@ -101,7 +102,8 @@ const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
), ),
publicationDate: maybe(() => collection.publicationDate, ""), publicationDate: maybe(() => collection.publicationDate, ""),
seoDescription: maybe(() => collection.seoDescription, ""), seoDescription: maybe(() => collection.seoDescription, ""),
seoTitle: maybe(() => collection.seoTitle, "") seoTitle: maybe(() => collection.seoTitle, ""),
slug: collection.slug || ""
}} }}
onSubmit={handleSubmit} onSubmit={handleSubmit}
confirmLeave confirmLeave
@ -149,6 +151,8 @@ const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
defaultMessage: defaultMessage:
"Add search engine title and description to make this collection easier to find" "Add search engine title and description to make this collection easier to find"
})} })}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle} title={data.seoTitle}
titlePlaceholder={maybe(() => collection.name)} titlePlaceholder={maybe(() => collection.name)}
onChange={change} onChange={change}

View file

@ -71,6 +71,7 @@ export interface CollectionDetails_collection {
metadata: (CollectionDetails_collection_metadata | null)[]; metadata: (CollectionDetails_collection_metadata | null)[];
privateMetadata: (CollectionDetails_collection_privateMetadata | null)[]; privateMetadata: (CollectionDetails_collection_privateMetadata | null)[];
backgroundImage: CollectionDetails_collection_backgroundImage | null; backgroundImage: CollectionDetails_collection_backgroundImage | null;
slug: string;
descriptionJson: any; descriptionJson: any;
publicationDate: any | null; publicationDate: any | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -34,6 +34,7 @@ export interface CollectionUpdate_collectionUpdate_collection {
metadata: (CollectionUpdate_collectionUpdate_collection_metadata | null)[]; metadata: (CollectionUpdate_collectionUpdate_collection_metadata | null)[];
privateMetadata: (CollectionUpdate_collectionUpdate_collection_privateMetadata | null)[]; privateMetadata: (CollectionUpdate_collectionUpdate_collection_privateMetadata | null)[];
backgroundImage: CollectionUpdate_collectionUpdate_collection_backgroundImage | null; backgroundImage: CollectionUpdate_collectionUpdate_collection_backgroundImage | null;
slug: string;
descriptionJson: any; descriptionJson: any;
publicationDate: any | null; publicationDate: any | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -56,6 +56,7 @@ export interface CollectionUpdateWithHomepage_collectionUpdate_collection {
metadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_metadata | null)[]; metadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_metadata | null)[];
privateMetadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_privateMetadata | null)[]; privateMetadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_privateMetadata | null)[];
backgroundImage: CollectionUpdateWithHomepage_collectionUpdate_collection_backgroundImage | null; backgroundImage: CollectionUpdateWithHomepage_collectionUpdate_collection_backgroundImage | null;
slug: string;
descriptionJson: any; descriptionJson: any;
publicationDate: any | null; publicationDate: any | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -34,6 +34,7 @@ export interface CreateCollection_collectionCreate_collection {
metadata: (CreateCollection_collectionCreate_collection_metadata | null)[]; metadata: (CreateCollection_collectionCreate_collection_metadata | null)[];
privateMetadata: (CreateCollection_collectionCreate_collection_privateMetadata | null)[]; privateMetadata: (CreateCollection_collectionCreate_collection_privateMetadata | null)[];
backgroundImage: CreateCollection_collectionCreate_collection_backgroundImage | null; backgroundImage: CreateCollection_collectionCreate_collection_backgroundImage | null;
slug: string;
descriptionJson: any; descriptionJson: any;
publicationDate: any | null; publicationDate: any | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -7,6 +7,7 @@ import Typography from "@material-ui/core/Typography";
import classNames from "classnames"; import classNames from "classnames";
import React from "react"; import React from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import slugify from "slugify";
import CardTitle from "../CardTitle"; import CardTitle from "../CardTitle";
import FormSpacer from "../FormSpacer"; import FormSpacer from "../FormSpacer";
@ -68,6 +69,8 @@ interface SeoFormProps {
loading?: boolean; loading?: boolean;
helperText?: string; helperText?: string;
title: string; title: string;
slug: string;
slugPlaceholder?: string;
titlePlaceholder: string; titlePlaceholder: string;
onChange(event: any); onChange(event: any);
onClick?(); onClick?();
@ -75,13 +78,14 @@ interface SeoFormProps {
const SeoForm: React.FC<SeoFormProps> = props => { const SeoForm: React.FC<SeoFormProps> = props => {
const { const {
description, description = "",
descriptionPlaceholder, descriptionPlaceholder,
disabled, disabled,
helperText, helperText,
loading, loading,
title, title = "",
slug, slug,
slugPlaceholder = "",
titlePlaceholder, titlePlaceholder,
onChange onChange
} = props; } = props;
@ -90,7 +94,9 @@ const SeoForm: React.FC<SeoFormProps> = props => {
const intl = useIntl(); const intl = useIntl();
const [expanded, setExpansionStatus] = React.useState(false); const [expanded, setExpansionStatus] = React.useState(false);
const toggleExpansion = () => setExpansionStatus(!expanded); const toggleExpansion = () => setExpansionStatus(!expanded);
const shouldDisplayHelperText = () => helperText && !expanded;
console.log({ slug });
return ( return (
<Card> <Card>
<CardTitle <CardTitle
@ -107,7 +113,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
} }
/> />
<CardContent> <CardContent>
{helperText && ( {shouldDisplayHelperText() && (
<Typography <Typography
className={classNames({ [classes.helperText]: expanded })} className={classNames({ [classes.helperText]: expanded })}
> >
@ -123,14 +129,14 @@ const SeoForm: React.FC<SeoFormProps> = props => {
<div className={classes.label}> <div className={classes.label}>
<FormattedMessage defaultMessage="Slug" /> <FormattedMessage defaultMessage="Slug" />
</div> </div>
{title.length > 0 && ( {slug?.length > 0 && (
<span> <span>
<FormattedMessage <FormattedMessage
defaultMessage="{numberOfCharacters} of {maxCharacters} characters" defaultMessage="{numberOfCharacters} of {maxCharacters} characters"
description="character limit" description="character limit"
values={{ values={{
maxCharacters: 70, maxCharacters: 70,
numberOfCharacters: slug.length numberOfCharacters: slug?.length
}} }}
/> />
</span> </span>
@ -141,9 +147,9 @@ const SeoForm: React.FC<SeoFormProps> = props => {
defaultMessage: defaultMessage:
"If empty, the preview shows what will be autogenerated." "If empty, the preview shows what will be autogenerated."
})} })}
value={title.slice(0, 69)} value={slug.slice(0, 69)}
disabled={loading || disabled} disabled={loading || disabled}
placeholder="Slug" placeholder={slug || slugify(slugPlaceholder)}
onChange={onChange} onChange={onChange}
fullWidth fullWidth
/> />

View file

@ -24,6 +24,7 @@ export const categoryDetailsFragment = gql`
url url
} }
name name
slug
descriptionJson descriptionJson
seoDescription seoDescription
seoTitle seoTitle

View file

@ -20,6 +20,7 @@ export const collectionDetailsFragment = gql`
alt alt
url url
} }
slug
descriptionJson descriptionJson
publicationDate publicationDate
seoDescription seoDescription

View file

@ -111,6 +111,7 @@ export const productFragmentDetails = gql`
...ProductVariantAttributesFragment ...ProductVariantAttributesFragment
...MetadataFragment ...MetadataFragment
name name
slug
descriptionJson descriptionJson
seoTitle seoTitle
seoDescription seoDescription

View file

@ -36,6 +36,7 @@ export interface CategoryDetailsFragment {
privateMetadata: (CategoryDetailsFragment_privateMetadata | null)[]; privateMetadata: (CategoryDetailsFragment_privateMetadata | null)[];
backgroundImage: CategoryDetailsFragment_backgroundImage | null; backgroundImage: CategoryDetailsFragment_backgroundImage | null;
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoDescription: string | null; seoDescription: string | null;
seoTitle: string | null; seoTitle: string | null;

View file

@ -32,6 +32,7 @@ export interface CollectionDetailsFragment {
metadata: (CollectionDetailsFragment_metadata | null)[]; metadata: (CollectionDetailsFragment_metadata | null)[];
privateMetadata: (CollectionDetailsFragment_privateMetadata | null)[]; privateMetadata: (CollectionDetailsFragment_privateMetadata | null)[];
backgroundImage: CollectionDetailsFragment_backgroundImage | null; backgroundImage: CollectionDetailsFragment_backgroundImage | null;
slug: string;
descriptionJson: any; descriptionJson: any;
publicationDate: any | null; publicationDate: any | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -195,6 +195,7 @@ export interface Product {
metadata: (Product_metadata | null)[]; metadata: (Product_metadata | null)[];
privateMetadata: (Product_privateMetadata | null)[]; privateMetadata: (Product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -23,7 +23,6 @@ import { useIntl } from "react-intl";
import { maybe } from "../../../misc"; import { maybe } from "../../../misc";
import { PageDetails_page } from "../../types/PageDetails"; import { PageDetails_page } from "../../types/PageDetails";
import PageInfo from "../PageInfo"; import PageInfo from "../PageInfo";
import PageSlug from "../PageSlug";
export interface FormData { export interface FormData {
content: RawDraftContentState; content: RawDraftContentState;
@ -31,7 +30,6 @@ export interface FormData {
publicationDate: string; publicationDate: string;
seoDescription: string; seoDescription: string;
seoTitle: string; seoTitle: string;
seoSlug: string;
slug: string; slug: string;
title: string; title: string;
} }
@ -108,6 +106,8 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
"" ""
)} )}
onChange={change} onChange={change}
slug={data.slug}
slugPlaceholder={data.title}
title={data.seoTitle} title={data.seoTitle}
titlePlaceholder={data.title} titlePlaceholder={data.title}
helperText={intl.formatMessage({ helperText={intl.formatMessage({

View file

@ -59,6 +59,7 @@ interface FormData extends MetadataFormData {
isAvailableForPurchase: boolean; isAvailableForPurchase: boolean;
isPublished: boolean; isPublished: boolean;
name: string; name: string;
slug: string;
productType: string; productType: string;
seoDescription: string; seoDescription: string;
seoTitle: string; seoTitle: string;
@ -156,6 +157,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
isPublished: false, isPublished: false,
metadata: [], metadata: [],
name: "", name: "",
slug: "",
privateMetadata: [], privateMetadata: [],
productType: "", productType: "",
publicationDate: "", publicationDate: "",
@ -309,6 +311,8 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
"Add search engine title and description to make this product easier to find" "Add search engine title and description to make this product easier to find"
})} })}
title={data.seoTitle} title={data.seoTitle}
slug={data.slug}
slugPlaceholder={data.name}
titlePlaceholder={data.name} titlePlaceholder={data.name}
description={data.seoDescription} description={data.seoDescription}
descriptionPlaceholder={data.seoTitle} descriptionPlaceholder={data.seoTitle}

View file

@ -357,6 +357,8 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
.getPlainText() .getPlainText()
.slice(0, 300) .slice(0, 300)
)} )}
slug={data.slug}
slugPlaceholder={data.name}
loading={disabled} loading={disabled}
onClick={onSeoClick} onClick={onSeoClick}
onChange={change} onChange={change}

View file

@ -201,6 +201,7 @@ export interface ProductCreate_productCreate_product {
metadata: (ProductCreate_productCreate_product_metadata | null)[]; metadata: (ProductCreate_productCreate_product_metadata | null)[];
privateMetadata: (ProductCreate_productCreate_product_privateMetadata | null)[]; privateMetadata: (ProductCreate_productCreate_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -195,6 +195,7 @@ export interface ProductDetails_product {
metadata: (ProductDetails_product_metadata | null)[]; metadata: (ProductDetails_product_metadata | null)[];
privateMetadata: (ProductDetails_product_privateMetadata | null)[]; privateMetadata: (ProductDetails_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -201,6 +201,7 @@ export interface ProductImageCreate_productImageCreate_product {
metadata: (ProductImageCreate_productImageCreate_product_metadata | null)[]; metadata: (ProductImageCreate_productImageCreate_product_metadata | null)[];
privateMetadata: (ProductImageCreate_productImageCreate_product_privateMetadata | null)[]; privateMetadata: (ProductImageCreate_productImageCreate_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -201,6 +201,7 @@ export interface ProductImageUpdate_productImageUpdate_product {
metadata: (ProductImageUpdate_productImageUpdate_product_metadata | null)[]; metadata: (ProductImageUpdate_productImageUpdate_product_metadata | null)[];
privateMetadata: (ProductImageUpdate_productImageUpdate_product_privateMetadata | null)[]; privateMetadata: (ProductImageUpdate_productImageUpdate_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -201,6 +201,7 @@ export interface ProductUpdate_productUpdate_product {
metadata: (ProductUpdate_productUpdate_product_metadata | null)[]; metadata: (ProductUpdate_productUpdate_product_metadata | null)[];
privateMetadata: (ProductUpdate_productUpdate_product_privateMetadata | null)[]; privateMetadata: (ProductUpdate_productUpdate_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;
@ -236,6 +237,7 @@ export interface ProductUpdateVariables {
publicationDate?: any | null; publicationDate?: any | null;
category?: string | null; category?: string | null;
chargeTaxes: boolean; chargeTaxes: boolean;
slug?: string | null;
collections?: (string | null)[] | null; collections?: (string | null)[] | null;
descriptionJson?: any | null; descriptionJson?: any | null;
isPublished: boolean; isPublished: boolean;

View file

@ -201,6 +201,7 @@ export interface SimpleProductUpdate_productUpdate_product {
metadata: (SimpleProductUpdate_productUpdate_product_metadata | null)[]; metadata: (SimpleProductUpdate_productUpdate_product_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productUpdate_product_privateMetadata | null)[]; privateMetadata: (SimpleProductUpdate_productUpdate_product_privateMetadata | null)[];
name: string; name: string;
slug: string;
descriptionJson: any; descriptionJson: any;
seoTitle: string | null; seoTitle: string | null;
seoDescription: string | null; seoDescription: string | null;

View file

@ -181,6 +181,7 @@ export interface ProductUpdatePageFormData extends MetadataFormData {
isAvailable: boolean; isAvailable: boolean;
isPublished: boolean; isPublished: boolean;
name: string; name: string;
slug: string;
publicationDate: string; publicationDate: string;
seoDescription: string; seoDescription: string;
seoTitle: string; seoTitle: string;
@ -222,6 +223,7 @@ export function getProductUpdatePageFormData(
: undefined, : undefined,
"" ""
), ),
slug: product?.slug || "",
trackInventory: !!product?.variants[0]?.trackInventory, trackInventory: !!product?.variants[0]?.trackInventory,
visibleInListings: !!product?.visibleInListings, visibleInListings: !!product?.visibleInListings,
weight: product?.weight?.value.toString() || "" weight: product?.weight?.value.toString() || ""