Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update Page.availableOn field

Krzysztof Bialoglowiczadbda01ef65b
diff --git a/saleor/static/dashboard-next/pages/components/PageAvailability/PageAvailability.tsx b/saleor/static/dashboard-next/pages/components/PageAvailability/PageAvailability.tsx
index 328aa25ce5..14d9360f60 100644
--- a/saleor/static/dashboard-next/pages/components/PageAvailability/PageAvailability.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageAvailability/PageAvailability.tsx
@@ -15,13 +15,14 @@ import { FormData } from "../PageDetailsPage";
export interface PageAvailabilityProps {
data: FormData;
disabled: boolean;
- errors: Partial<Record<"availableOn", string>>;
+ errors: Partial<Record<"publicationDate", string>>;
onChange: (event: React.ChangeEvent<any>, cb?: () => void) => void;
}
function isAvailable(data: FormData): boolean {
return (
- (data.availableOn === "" || data.availableOn === null) && data.isVisible
+ (data.publicationDate === "" || data.publicationDate === null) &&
+ data.isVisible
);
}
@@ -40,16 +41,16 @@ const PageAvailability: React.StatelessComponent<PageAvailabilityProps> = ({
checked={isAvailable(data)}
disabled={disabled}
label={
- data.isVisible && !data.availableOn ? (
+ data.isVisible && !data.publicationDate ? (
i18n.t("Published")
) : (
<>
{i18n.t("Hidden")}
- {data.availableOn && (
+ {data.publicationDate && (
<Typography variant="caption">
{i18n.t("Will become visible on {{ date }}", {
context: "page",
- date: moment(data.availableOn)
+ date: moment(data.publicationDate)
.locale(locale)
.format("ll")
})}
@@ -66,7 +67,7 @@ const PageAvailability: React.StatelessComponent<PageAvailabilityProps> = ({
event.target.value &&
onChange({
target: {
- name: "availableOn",
+ name: "publicationDate",
value: ""
}
} as any)
@@ -78,13 +79,13 @@ const PageAvailability: React.StatelessComponent<PageAvailabilityProps> = ({
<FormSpacer />
<TextField
disabled={disabled}
- error={!!errors.availableOn}
+ error={!!errors.publicationDate}
fullWidth
- helperText={errors.availableOn}
+ helperText={errors.publicationDate}
label={i18n.t("Publish page on")}
- name={"availableOn" as keyof FormData}
+ name={"publicationDate" as keyof FormData}
type="date"
- value={data.availableOn}
+ value={data.publicationDate}
onChange={onChange}
/>
</>
diff --git a/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
index 3e0629b8ae..b014c93b1d 100644
--- a/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
@@ -24,9 +24,9 @@ import PageInfo from "../PageInfo";
import PageSlug from "../PageSlug";
export interface FormData {
- availableOn: string;
content: RawDraftContentState;
isVisible: boolean;
+ publicationDate: string;
seoDescription: string;
seoTitle: string;
slug: string;
@@ -53,12 +53,12 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
onSubmit
}) => {
const initialForm: FormData = {
- availableOn: maybe(() => page.availableOn, ""),
content: maybe(
() => JSON.parse(page.contentJson),
convertToRaw(ContentState.createFromText(""))
),
isVisible: maybe(() => page.isVisible, false),
+ publicationDate: maybe(() => page.publicationDate, ""),
seoDescription: maybe(() => page.seoDescription || "", ""),
seoTitle: maybe(() => page.seoTitle || "", ""),
slug: maybe(() => page.slug, ""),
diff --git a/saleor/static/dashboard-next/pages/fixtures.ts b/saleor/static/dashboard-next/pages/fixtures.ts
index 62eefb6b49..37e72cb8fd 100644
--- a/saleor/static/dashboard-next/pages/fixtures.ts
+++ b/saleor/static/dashboard-next/pages/fixtures.ts
@@ -34,10 +34,10 @@ export const pageList: PageList_pages_edges_node[] = [
];
export const page: PageDetails_page = {
__typename: "Page",
- availableOn: "",
contentJson: JSON.stringify(content),
id: "Kzx152sEm==",
isVisible: false,
+ publicationDate: "",
seoDescription: "About",
seoTitle: "About",
slug: "about",
diff --git a/saleor/static/dashboard-next/pages/queries.ts b/saleor/static/dashboard-next/pages/queries.ts
index abd6928568..e66b434f4b 100644
--- a/saleor/static/dashboard-next/pages/queries.ts
+++ b/saleor/static/dashboard-next/pages/queries.ts
@@ -20,7 +20,7 @@ export const pageDetailsFragment = gql`
contentJson
seoTitle
seoDescription
- availableOn
+ publicationDate
}
`;
diff --git a/saleor/static/dashboard-next/pages/types/PageCreate.ts b/saleor/static/dashboard-next/pages/types/PageCreate.ts
index cb1b07b18d..95da055a3e 100644
--- a/saleor/static/dashboard-next/pages/types/PageCreate.ts
+++ b/saleor/static/dashboard-next/pages/types/PageCreate.ts
@@ -23,7 +23,7 @@ export interface PageCreate_pageCreate_page {
contentJson: any;
seoTitle: string | null;
seoDescription: string | null;
- availableOn: any | null;
+ publicationDate: any | null;
}
export interface PageCreate_pageCreate {
diff --git a/saleor/static/dashboard-next/pages/types/PageDetails.ts b/saleor/static/dashboard-next/pages/types/PageDetails.ts
index 54a9f6854c..a923787298 100644
--- a/saleor/static/dashboard-next/pages/types/PageDetails.ts
+++ b/saleor/static/dashboard-next/pages/types/PageDetails.ts
@@ -15,7 +15,7 @@ export interface PageDetails_page {
contentJson: any;
seoTitle: string | null;
seoDescription: string | null;
- availableOn: any | null;
+ publicationDate: any | null;
}
export interface PageDetails {
diff --git a/saleor/static/dashboard-next/pages/types/PageDetailsFragment.ts b/saleor/static/dashboard-next/pages/types/PageDetailsFragment.ts
index 7b98ac58df..db48fc1418 100644
--- a/saleor/static/dashboard-next/pages/types/PageDetailsFragment.ts
+++ b/saleor/static/dashboard-next/pages/types/PageDetailsFragment.ts
@@ -15,5 +15,5 @@ export interface PageDetailsFragment {
contentJson: any;
seoTitle: string | null;
seoDescription: string | null;
- availableOn: any | null;
+ publicationDate: any | null;
}
diff --git a/saleor/static/dashboard-next/pages/types/PageUpdate.ts b/saleor/static/dashboard-next/pages/types/PageUpdate.ts
index c411a4ec92..8bad60ecc6 100644
--- a/saleor/static/dashboard-next/pages/types/PageUpdate.ts
+++ b/saleor/static/dashboard-next/pages/types/PageUpdate.ts
@@ -23,7 +23,7 @@ export interface PageUpdate_pageUpdate_page {
contentJson: any;
seoTitle: string | null;
seoDescription: string | null;
- availableOn: any | null;
+ publicationDate: any | null;
}
export interface PageUpdate_pageUpdate {
diff --git a/saleor/static/dashboard-next/pages/views/PageCreate.tsx b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
index e198fd257d..74fadfacb4 100644
--- a/saleor/static/dashboard-next/pages/views/PageCreate.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
@@ -55,14 +55,14 @@ export const PageCreate: React.StatelessComponent<PageCreateProps> = () => {
contentJson: JSON.stringify(formData.content),
isPublished: formData.isVisible
? true
- : formData.availableOn === ""
+ : formData.publicationDate === ""
? false
: true,
publicationDate: formData.isVisible
? null
- : formData.availableOn === ""
+ : formData.publicationDate === ""
? null
- : formData.availableOn,
+ : formData.publicationDate,
seo: {
description: formData.seoDescription,
title: formData.seoTitle
diff --git a/saleor/static/dashboard-next/pages/views/PageDetails.tsx b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
index 286e44704b..a9827e6a1b 100644
--- a/saleor/static/dashboard-next/pages/views/PageDetails.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
@@ -23,14 +23,14 @@ const createPageInput = (data: FormData): PageInput => ({
contentJson: JSON.stringify(data.content),
isPublished: data.isVisible
? true
- : data.availableOn === "" || data.availableOn === null
+ : data.publicationDate === "" || data.publicationDate === null
? false
: true,
publicationDate: data.isVisible
? null
- : data.availableOn === ""
+ : data.publicationDate === ""
? null
- : data.availableOn,
+ : data.publicationDate,
seo: {
description: data.seoDescription,
title: data.seoTitle
diff --git a/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx
index 33df9c96c1..f21c0ab88d 100644
--- a/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/pages/PageDetailsPage.tsx
@@ -32,7 +32,7 @@ storiesOf("Views / Pages / Page details", module)
"title",
"slug",
"content",
- "availableOn",
+ "publicationDate",
"isVisible",
"seoDescription",
"seoTitle"