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 slug field to category, product, collection & page details #720

Merged
merged 38 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4efce14
Add weight to variant
dominik-zeglen Jul 9, 2020
e066d31
Add weight to simple products
dominik-zeglen Jul 9, 2020
1bbc7aa
Update snapshots
dominik-zeglen Jul 9, 2020
214dcae
Update changelog
dominik-zeglen Jul 9, 2020
8173624
Fix order note when no user was given
dominik-zeglen Jul 13, 2020
d5f6f27
Display correct weight unit
dominik-zeglen Jul 13, 2020
b34601b
Update messages
dominik-zeglen Jul 13, 2020
d90015a
Merge pull request #597 from mirumee/fix/minor-bugs
maarcingebala Jul 13, 2020
ff7a6ef
Fix weight based rate update
dominik-zeglen Jul 13, 2020
6b08630
Update changelog
dominik-zeglen Jul 13, 2020
973add1
Merge pull request #604 from mirumee/fix/weight-rate-update
maarcingebala Jul 13, 2020
0d9f866
Bump to 2.10.1
maarcingebala Jul 13, 2020
8a80f3d
Add slug field for page details wip
Sep 17, 2020
7631a7a
Merge branch 'master' into feat/add-slug-to-seo-form
Sep 18, 2020
d20b58d
fixes afer merge
Sep 18, 2020
52cf01e
update mutation and fixtures
Sep 21, 2020
6ae8fce
update product create mutation create handler
Sep 21, 2020
37e0ecc
add slug field to category update and create
Sep 21, 2020
77063de
fix seo form to work with null values from some props
Sep 21, 2020
0f4d0f1
fix types and lint
Sep 21, 2020
ca644c9
refactor
Sep 21, 2020
d8a770b
refactor
Sep 21, 2020
e69c705
fix lint
Sep 21, 2020
d033940
update messages
Sep 21, 2020
977fbce
update changelog
Sep 21, 2020
c7124ff
Merge branch 'master' into feat/add-slug-to-seo-form
bmigirl Sep 22, 2020
c20c84d
refactor
Sep 22, 2020
8093876
Merge branch 'master' into feat/add-slug-to-seo-form
bmigirl Sep 23, 2020
828e207
add error handling to seo form
Sep 24, 2020
4a8b8e3
Fix mutation for simple product update
Sep 24, 2020
2519ed9
add pattern matching for slug field not to use special characters
Sep 24, 2020
c0d02d6
refactor
Sep 24, 2020
cc166f4
refactor after review
Sep 25, 2020
c8e0681
Merge branch 'master' into feat/add-slug-to-seo-form
bmigirl Sep 25, 2020
fe2b15c
update messages
Sep 25, 2020
f956be3
refactor after review
Sep 25, 2020
8f43226
Merge branch 'master' into feat/add-slug-to-seo-form
Sep 25, 2020
70815b0
fixes
Sep 25, 2020
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ All notable, unreleased changes to this project will be documented in this file.
- Fix return to previous page on screen size change - #710 by @orzechdev
- Add variants reordering possibility - #716 by @orzechdev
- Fix avatar change button - #719 by @orzechdev
- Add slug field to product, collection, category & page details (update and create) - #720 by @mmarkusik
- Change plural form of "informations" to "information" strings across the app #722 by @mmarkusik


## 2.10.1

- Add weight field and fix warehouse country selection - #597 by @dominik-zeglen
Expand Down
13 changes: 3 additions & 10 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,9 @@
"src_dot_components_dot_SeoForm_dot_3468022343": {
"string": "Search Engine Preview"
},
"src_dot_components_dot_SeoForm_dot_3478065224": {
"string": "Slug"
},
"src_dot_components_dot_SeoForm_dot_3877274856": {
"context": "character limit",
"string": "{numberOfCharacters} of {maxCharacters} characters"
Expand Down Expand Up @@ -3564,16 +3567,6 @@
"context": "page status",
"string": "Not Published"
},
"src_dot_pages_dot_components_dot_PageSlug_dot_1324178587": {
"string": "URL"
},
"src_dot_pages_dot_components_dot_PageSlug_dot_3478065224": {
"context": "page internal name",
"string": "Slug"
},
"src_dot_pages_dot_components_dot_PageSlug_dot_4210828158": {
"string": "If empty, URL will be autogenerated from Page Name"
},
"src_dot_pages_dot_views_dot_1068617485": {
"context": "header",
"string": "Create Page"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import CategoryDetailsForm from "../../components/CategoryDetailsForm";
export interface FormData extends MetadataFormData {
description: RawDraftContentState;
name: string;
slug: string;
seoTitle: string;
seoDescription: string;
}
Expand All @@ -29,7 +30,8 @@ const initialData: FormData = {
name: "",
privateMetadata: [],
seoDescription: "",
seoTitle: ""
seoTitle: "",
slug: ""
};

export interface CategoryCreatePageProps {
Expand Down Expand Up @@ -81,6 +83,8 @@ export const CategoryCreatePage: React.FC<CategoryCreatePageProps> = ({
defaultMessage:
"Add search engine title and description to make this category easier to find"
})}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle}
titlePlaceholder={data.name}
description={data.seoDescription}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface FormData extends MetadataFormData {
backgroundImageAlt: string;
description: RawDraftContentState;
name: string;
slug: string;
seoTitle: string;
seoDescription: string;
}
Expand Down Expand Up @@ -118,7 +119,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
name: category.name || "",
privateMetadata: category?.privateMetadata?.map(mapMetadataItemToInput),
seoDescription: category.seoDescription || "",
seoTitle: category.seoTitle || ""
seoTitle: category.seoTitle || "",
slug: category?.slug || ""
}
: {
backgroundImageAlt: "",
Expand All @@ -127,7 +129,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
name: "",
privateMetadata: undefined,
seoDescription: "",
seoTitle: ""
seoTitle: "",
slug: ""
};

const handleSubmit = (data: FormData) => {
Expand Down Expand Up @@ -179,6 +182,8 @@ export const CategoryUpdatePage: React.FC<CategoryUpdatePageProps> = ({
titlePlaceholder={data.name}
description={data.seoDescription}
descriptionPlaceholder={data.name}
slug={data.slug}
slugPlaceholder={data.name}
loading={!category}
onChange={change}
disabled={disabled}
Expand Down
3 changes: 2 additions & 1 deletion src/categories/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ export const category: (
}
},
seoDescription: null,
seoTitle: null
seoTitle: null,
slug: "coffees"
});
export const errors = [
{
Expand Down
1 change: 1 addition & 0 deletions src/categories/types/CategoryCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface CategoryCreate_categoryCreate_category {
privateMetadata: (CategoryCreate_categoryCreate_category_privateMetadata | null)[];
backgroundImage: CategoryCreate_categoryCreate_category_backgroundImage | null;
name: string;
slug: string;
descriptionJson: any;
seoDescription: string | null;
seoTitle: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/categories/types/CategoryDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface CategoryDetails_category {
privateMetadata: (CategoryDetails_category_privateMetadata | null)[];
backgroundImage: CategoryDetails_category_backgroundImage | null;
name: string;
slug: string;
descriptionJson: any;
seoDescription: string | null;
seoTitle: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/categories/types/CategoryUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface CategoryUpdate_categoryUpdate_category {
privateMetadata: (CategoryUpdate_categoryUpdate_category_privateMetadata | null)[];
backgroundImage: CategoryUpdate_categoryUpdate_category_backgroundImage | null;
name: string;
slug: string;
descriptionJson: any;
seoDescription: string | null;
seoTitle: string | null;
Expand Down
3 changes: 2 additions & 1 deletion src/categories/views/CategoryCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const CategoryCreateView: React.FC<CategoryCreateViewProps> = ({
seo: {
description: formData.seoDescription,
title: formData.seoTitle
}
},
slug: formData.slug
},
parent: parentId || null
}
Expand Down
3 changes: 2 additions & 1 deletion src/categories/views/CategoryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
seo: {
description: formData.seoDescription,
title: formData.seoTitle
}
},
slug: formData.slug
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface CollectionCreatePageFormData extends MetadataFormData {
backgroundImageAlt: string;
description: RawDraftContentState;
name: string;
slug: string;
publicationDate: string;
isPublished: boolean;
seoDescription: string;
Expand Down Expand Up @@ -55,7 +56,8 @@ const initialForm: CollectionCreatePageFormData = {
privateMetadata: [],
publicationDate: "",
seoDescription: "",
seoTitle: ""
seoTitle: "",
slug: ""
};

const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
Expand Down Expand Up @@ -140,6 +142,8 @@ const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
defaultMessage:
"Add search engine title and description to make this collection easier to find"
})}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle}
titlePlaceholder={data.name}
onChange={change}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface CollectionDetailsPageFormData extends MetadataFormData {
backgroundImageAlt: string;
description: RawDraftContentState;
name: string;
slug: string;
publicationDate: string;
seoDescription: string;
seoTitle: string;
Expand Down Expand Up @@ -101,7 +102,8 @@ const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
),
publicationDate: maybe(() => collection.publicationDate, ""),
seoDescription: maybe(() => collection.seoDescription, ""),
seoTitle: maybe(() => collection.seoTitle, "")
seoTitle: maybe(() => collection.seoTitle, ""),
slug: collection?.slug || ""
}}
onSubmit={handleSubmit}
confirmLeave
Expand Down Expand Up @@ -149,6 +151,8 @@ const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
defaultMessage:
"Add search engine title and description to make this collection easier to find"
})}
slug={data.slug}
slugPlaceholder={data.name}
title={data.seoTitle}
titlePlaceholder={maybe(() => collection.name)}
onChange={change}
Expand Down
3 changes: 2 additions & 1 deletion src/collections/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,6 @@ export const collection: (
},
publicationDate: "2018-08-25T18:45:54.125Z",
seoDescription: "",
seoTitle: ""
seoTitle: "",
slug: "summer-collection"
});
1 change: 1 addition & 0 deletions src/collections/types/CollectionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface CollectionDetails_collection {
metadata: (CollectionDetails_collection_metadata | null)[];
privateMetadata: (CollectionDetails_collection_privateMetadata | null)[];
backgroundImage: CollectionDetails_collection_backgroundImage | null;
slug: string;
descriptionJson: any;
publicationDate: any | null;
seoDescription: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/collections/types/CollectionUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface CollectionUpdate_collectionUpdate_collection {
metadata: (CollectionUpdate_collectionUpdate_collection_metadata | null)[];
privateMetadata: (CollectionUpdate_collectionUpdate_collection_privateMetadata | null)[];
backgroundImage: CollectionUpdate_collectionUpdate_collection_backgroundImage | null;
slug: string;
descriptionJson: any;
publicationDate: any | null;
seoDescription: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/collections/types/CollectionUpdateWithHomepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface CollectionUpdateWithHomepage_collectionUpdate_collection {
metadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_metadata | null)[];
privateMetadata: (CollectionUpdateWithHomepage_collectionUpdate_collection_privateMetadata | null)[];
backgroundImage: CollectionUpdateWithHomepage_collectionUpdate_collection_backgroundImage | null;
slug: string;
descriptionJson: any;
publicationDate: any | null;
seoDescription: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/collections/types/CreateCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface CreateCollection_collectionCreate_collection {
metadata: (CreateCollection_collectionCreate_collection_metadata | null)[];
privateMetadata: (CreateCollection_collectionCreate_collection_privateMetadata | null)[];
backgroundImage: CreateCollection_collectionCreate_collection_backgroundImage | null;
slug: string;
descriptionJson: any;
publicationDate: any | null;
seoDescription: string | null;
Expand Down
3 changes: 2 additions & 1 deletion src/collections/views/CollectionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
seo: {
description: formData.seoDescription,
title: formData.seoTitle
}
},
slug: formData.slug
};
const isFeatured = data.shop.homepageCollection
? data.shop.homepageCollection.id === data.collection.id
Expand Down
48 changes: 43 additions & 5 deletions src/components/SeoForm/SeoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Typography from "@material-ui/core/Typography";
import classNames from "classnames";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import slugify from "slugify";

import CardTitle from "../CardTitle";
import FormSpacer from "../FormSpacer";
Expand Down Expand Up @@ -68,6 +69,8 @@ interface SeoFormProps {
loading?: boolean;
helperText?: string;
title: string;
slug: string;
slugPlaceholder?: string;
titlePlaceholder: string;
onChange(event: any);
onClick?();
Expand All @@ -81,6 +84,8 @@ const SeoForm: React.FC<SeoFormProps> = props => {
helperText,
loading,
title,
slug,
slugPlaceholder,
titlePlaceholder,
onChange
} = props;
Expand All @@ -89,6 +94,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
const intl = useIntl();
const [expanded, setExpansionStatus] = React.useState(false);
const toggleExpansion = () => setExpansionStatus(!expanded);
const shouldDisplayHelperText = helperText && !expanded;

return (
<Card>
Expand All @@ -106,7 +112,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
}
/>
<CardContent>
{helperText && (
{shouldDisplayHelperText && (
<Typography
className={classNames({ [classes.helperText]: expanded })}
>
Expand All @@ -115,14 +121,46 @@ const SeoForm: React.FC<SeoFormProps> = props => {
)}
{expanded && (
<div className={classes.container}>
<TextField
name="slug"
label={
<div className={classes.labelContainer}>
<div className={classes.label}>
<FormattedMessage defaultMessage="Slug" />
</div>
{slug?.length > 0 && (
<span>
<FormattedMessage
defaultMessage="{numberOfCharacters} of {maxCharacters} characters"
description="character limit"
values={{
maxCharacters: 70,
numberOfCharacters: slug?.length
}}
/>
</span>
)}
</div>
}
helperText={intl.formatMessage({
defaultMessage:
"If empty, the preview shows what will be autogenerated."
})}
value={slug?.slice(0, 69)}
disabled={loading || disabled}
placeholder={slug || slugify(slugPlaceholder, { lower: true })}
onChange={onChange}
fullWidth
/>
<FormSpacer />
<TextField
name="seoTitle"
label={
<div className={classes.labelContainer}>
<div className={classes.label}>
<FormattedMessage defaultMessage="Search engine title" />
</div>
{title.length > 0 && (
{title?.length > 0 && (
<span>
<FormattedMessage
defaultMessage="{numberOfCharacters} of {maxCharacters} characters"
Expand All @@ -140,7 +178,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
defaultMessage:
"If empty, the preview shows what will be autogenerated."
})}
value={title.slice(0, 69)}
value={title?.slice(0, 69)}
disabled={loading || disabled}
placeholder={titlePlaceholder}
onChange={onChange}
Expand All @@ -154,7 +192,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
<div className={classes.label}>
<FormattedMessage defaultMessage="Search engine description" />
</div>
{description.length > 0 && (
{description?.length > 0 && (
<span>
<FormattedMessage
defaultMessage="{numberOfCharacters} of {maxCharacters} characters"
Expand All @@ -172,7 +210,7 @@ const SeoForm: React.FC<SeoFormProps> = props => {
defaultMessage:
"If empty, the preview shows what will be autogenerated."
})}
value={description ? description.slice(0, 299) : undefined}
value={description?.slice(0, 299)}
onChange={onChange}
disabled={loading || disabled}
fullWidth
Expand Down
1 change: 1 addition & 0 deletions src/fragments/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const categoryDetailsFragment = gql`
url
}
name
slug
descriptionJson
seoDescription
seoTitle
Expand Down
1 change: 1 addition & 0 deletions src/fragments/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const collectionDetailsFragment = gql`
alt
url
}
slug
descriptionJson
publicationDate
seoDescription
Expand Down
Loading