Skip to content

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

Add page views titles

dominik-zeglen91404ad4935f
diff --git a/saleor/static/dashboard-next/pages/index.tsx b/saleor/static/dashboard-next/pages/index.tsx
index 959221b921..b743fbc3d8 100644
--- a/saleor/static/dashboard-next/pages/index.tsx
+++ b/saleor/static/dashboard-next/pages/index.tsx
@@ -2,6 +2,8 @@ import { parse as parseQs } from "qs";
import * as React from "react";
import { Route, RouteComponentProps, Switch } from "react-router-dom";
+import { WindowTitle } from "../components/WindowTitle";
+import i18n from "../i18n";
import PageCreate from "./views/PageCreate";
import PageDetailsComponent from "./views/PageDetails";
import PageListComponent, { PageListQueryParams } from "./views/PageList";
@@ -23,11 +25,14 @@ const PageDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
};
const Component = ({ match }) => (
- <Switch>
- <Route exact path={match.url} component={PageList} />
- <Route exact path={`${match.url}/add/`} component={PageCreate} />
- <Route exact path={`${match.url}/:id/`} component={PageDetails} />
- </Switch>
+ <>
+ <WindowTitle title={i18n.t("Pages")} />
+ <Switch>
+ <Route exact path={match.url} component={PageList} />
+ <Route exact path={`${match.url}/add/`} component={PageCreate} />
+ <Route exact path={`${match.url}/:id/`} component={PageDetails} />
+ </Switch>
+ </>
);
export function pageEditUrl(id: string) {
diff --git a/saleor/static/dashboard-next/pages/views/PageCreate.tsx b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
index 7952126352..1a6f6dde17 100644
--- a/saleor/static/dashboard-next/pages/views/PageCreate.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
@@ -3,6 +3,7 @@ import { Redirect } from "react-router";
import { pageListUrl } from "..";
import { NavigatorLink } from "../../components/Navigator";
+import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
import PageDetailsPage from "../../pages/components/PageDetailsPage";
import { TypedPageCreateMutation } from "../mutations";
@@ -16,23 +17,26 @@ export const PageCreateForm: React.StatelessComponent = () => (
return (
<NavigatorLink to={pageListUrl}>
{handleCancel => (
- <PageDetailsPage
- disabled={loading}
- page={{
- availableOn: "",
- content: "",
- isVisible: false,
- slug: "",
- title: ""
- }}
- onBack={handleCancel}
- onSubmit={data =>
- createPage({
- variables: data
- })
- }
- title={i18n.t("Add page", { context: "title" })}
- />
+ <>
+ <WindowTitle title={i18n.t("Create page")} />
+ <PageDetailsPage
+ disabled={loading}
+ page={{
+ availableOn: "",
+ content: "",
+ isVisible: false,
+ slug: "",
+ title: ""
+ }}
+ onBack={handleCancel}
+ onSubmit={data =>
+ createPage({
+ variables: data
+ })
+ }
+ title={i18n.t("Add page", { context: "title" })}
+ />
+ </>
)}
</NavigatorLink>
);
diff --git a/saleor/static/dashboard-next/pages/views/PageDetails.tsx b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
index dd8d21fa6e..2caeda57fb 100644
--- a/saleor/static/dashboard-next/pages/views/PageDetails.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
@@ -4,7 +4,9 @@ import { Redirect } from "react-router";
import { pageListUrl } from "..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import { NavigatorLink } from "../../components/Navigator";
+import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
+import { maybe } from "../../misc";
import PageDetailsPage from "../components/PageDetailsPage";
import { TypedPageDeleteMutation, TypedPageUpdateMutation } from "../mutations";
import { pageDetailsQuery, TypedPageDetailsQuery } from "../queries";
@@ -88,28 +90,35 @@ export class PageUpdateForm extends React.Component<
return (
<NavigatorLink to={pageListUrl}>
{handleCancel => (
- <PageDetailsPage
- onBack={handleCancel}
- page={loading ? undefined : detailsResult.page}
- onSubmit={data =>
- updatePage({
- variables: { id, ...data }
- })
- }
- errors={
- updateResult
- ? updateResult.pageUpdate.errors
- : []
- }
- title={
- detailsResult && detailsResult.page
- ? detailsResult.page.title
- : undefined
- }
- disabled={
- loading || deleteInProgress || updateInProgress
- }
- />
+ <>
+ <WindowTitle
+ title={maybe(() => detailsResult.page.title)}
+ />
+ <PageDetailsPage
+ onBack={handleCancel}
+ page={loading ? undefined : detailsResult.page}
+ onSubmit={data =>
+ updatePage({
+ variables: { id, ...data }
+ })
+ }
+ errors={
+ updateResult
+ ? updateResult.pageUpdate.errors
+ : []
+ }
+ title={
+ detailsResult && detailsResult.page
+ ? detailsResult.page.title
+ : undefined
+ }
+ disabled={
+ loading ||
+ deleteInProgress ||
+ updateInProgress
+ }
+ />
+ </>
)}
</NavigatorLink>
);