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

feat(front): stacks #238

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 4 additions & 5 deletions targets/frontend/src/components/layout/auth.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Box, Flex, Heading, jsx } from "theme-ui";

import { Header } from "./header";
import { Nav } from "./Nav";
import { Stack } from "./Stack";

export function Layout({ children, title }) {
return (
Expand All @@ -19,10 +18,10 @@ export function Layout({ children, title }) {
<Flex sx={{ flexBasis: "100%" }}>
<Nav />
<Box as="main" sx={{ flex: "1 1 auto" }} padding="large">
<Stack>
<Heading as="h1">{title}</Heading>
{children}
</Stack>
<Heading sx={{ pb: "medium" }} as="h1">
{title}
</Heading>
{children}
</Box>
</Flex>
</Box>
Expand Down
144 changes: 73 additions & 71 deletions targets/frontend/src/pages/alerts/[[...params]].js
Original file line number Diff line number Diff line change
Expand Up @@ -107,86 +107,88 @@ export function AlertPage() {
// console.log(alerts);
return (
<Layout title="Gestion des alertes">
<AlertTabs repository={repository} activeStatus={activeStatus} />
{alerts.map((alert) => (
<Container sx={{ paddingTop: "large" }} key={`${alert.id}`}>
<Card>
<Stack>
<AlertTitle alertId={alert.id} info={alert.info}>
{getTitle(alert)}
</AlertTitle>
<Accordion collapsible multiple>
{alert.changes.added.length > 0 && (
<Stack>
<AlertTabs repository={repository} activeStatus={activeStatus} />
{alerts.map((alert) => (
<Container sx={{ paddingTop: "large" }} key={`${alert.id}`}>
<Card>
<Stack>
<AlertTitle alertId={alert.id} info={alert.info}>
{getTitle(alert)}
</AlertTitle>
<Accordion collapsible multiple>
{alert.changes.added.length > 0 && (
<ChangesGroup
changes={alert.changes.added}
label="Éléments ajoutés"
renderChange={(changes, i) =>
renderChange(
changes,
`${alert.id}-added-${i}`,
alert.info.type
)
}
/>
)}
{alert.changes.added.length > 0 &&
alert.changes.modified.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.added}
label="Éléments ajoutés"
changes={alert.changes.modified}
label="Éléments modifiés"
renderChange={(changes, i) =>
renderChange(
changes,
`${alert.id}-added-${i}`,
`${alert.id}-modified-${i}`,
alert.info.type
)
}
/>
)}
{alert.changes.added.length > 0 &&
alert.changes.modified.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.modified}
label="Éléments modifiés"
renderChange={(changes, i) =>
renderChange(
changes,
`${alert.id}-modified-${i}`,
alert.info.type
)
}
/>
{alert.changes.removed.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.removed}
label="Éléments supprimés"
renderChange={(changes, i) =>
renderChange(
changes,
`${alert.id}-removed-${i}`,
alert.info.type
)
}
/>
{alert.changes.documents?.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.documents}
label="Contenus liés"
renderChange={(item, i) => {
const [title, anchor] = item.document.title.split("#");
{alert.changes.removed.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.removed}
label="Éléments supprimés"
renderChange={(changes, i) =>
renderChange(
changes,
`${alert.id}-removed-${i}`,
alert.info.type
)
}
/>
{alert.changes.documents?.length > 0 && <Divider />}
<ChangesGroup
changes={alert.changes.documents}
label="Contenus liés"
renderChange={(item, i) => {
const [title, anchor] = item.document.title.split("#");

return (
<li key={`${alert.id}-documents-${i}`}>
<a
target="_blank"
rel="noopener noreferrer"
key={item.document.id}
href={`https://code.travail.gouv.fr/${getRouteBySource(
item.document.source
)}/${slugify(title)}${anchor ? `#${anchor}` : ``}`}
>
{title}
</a>
</li>
);
}}
/>
</Accordion>
</Stack>
</Card>
</Container>
))}
<Pagination
count={alerts_aggregate.aggregate.count}
currentPage={currentPage}
pageSize={pageSize}
/>
return (
<li key={`${alert.id}-documents-${i}`}>
<a
target="_blank"
rel="noopener noreferrer"
key={item.document.id}
href={`https://code.travail.gouv.fr/${getRouteBySource(
item.document.source
)}/${slugify(title)}${anchor ? `#${anchor}` : ``}`}
>
{title}
</a>
</li>
);
}}
/>
</Accordion>
</Stack>
</Card>
</Container>
))}
<Pagination
count={alerts_aggregate.aggregate.count}
currentPage={currentPage}
pageSize={pageSize}
/>
</Stack>
</Layout>
);
}
Expand Down
67 changes: 35 additions & 32 deletions targets/frontend/src/pages/contenus/create/[[...source]].js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getLabelBySource, SOURCES } from "@socialgouv/cdtn-sources";
import { useRouter } from "next/router";
import { EditorialContentForm } from "src/components/editorialContent/Form";
import { Layout } from "src/components/layout/auth.layout";
import { Stack } from "src/components/layout/Stack";
import { withCustomUrqlClient } from "src/hoc/CustomUrqlClient";
import { withUserProvider } from "src/hoc/UserProvider";
import { jsx, Label, Select } from "theme-ui";
Expand Down Expand Up @@ -62,39 +63,41 @@ export function CreateDocumentPage() {

return (
<Layout title="Créer un contenu">
<form>
<Label htmlFor="source">
Quel type de document souhaitez vous créer&nbsp;?
</Label>
<Select
name="source"
id="source"
defaultValue={source}
onChange={(event) => {
router.replace(
`/contenus/create/${event.target.value}`,
undefined,
{ shallow: true }
);
}}
>
<option disabled value="">
...
</option>
{CREATABLE_SOURCES.map((item) => (
<option key={item} value={item}>
{getLabelBySource(item)}
<Stack>
<form>
<Label htmlFor="source">
Quel type de document souhaitez vous créer&nbsp;?
</Label>
<Select
name="source"
id="source"
defaultValue={source}
onChange={(event) => {
router.replace(
`/contenus/create/${event.target.value}`,
undefined,
{ shallow: true }
);
}}
>
<option disabled value="">
...
</option>
))}
</Select>
</form>
{source === SOURCES.EDITORIAL_CONTENT && (
<EditorialContentForm
loading={createResult.fetching}
onSubmit={onSubmit}
/>
)}
{source === SOURCES.THEMATIC_FILES && <strong>soon</strong>}
{CREATABLE_SOURCES.map((item) => (
<option key={item} value={item}>
{getLabelBySource(item)}
</option>
))}
</Select>
</form>
{source === SOURCES.EDITORIAL_CONTENT && (
<EditorialContentForm
loading={createResult.fetching}
onSubmit={onSubmit}
/>
)}
{source === SOURCES.THEMATIC_FILES && <strong>soon</strong>}
</Stack>
</Layout>
);
}
Expand Down
109 changes: 56 additions & 53 deletions targets/frontend/src/pages/contenus/edit/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Dialog } from "src/components/dialog";
import { EditorialContentForm } from "src/components/editorialContent/Form";
import { Layout } from "src/components/layout/auth.layout";
import { Inline } from "src/components/layout/Inline";
import { Stack } from "src/components/layout/Stack";
import { withCustomUrqlClient } from "src/hoc/CustomUrqlClient";
import { withUserProvider } from "src/hoc/UserProvider";
import { jsx, Spinner } from "theme-ui";
Expand Down Expand Up @@ -95,62 +96,64 @@ export function EditInformationPage() {

return (
<Layout title="Éditer le contenu">
{fetching ? (
<Spinner />
) : (
<>
<Dialog
isOpen={showDeleteConfirmation}
onDismiss={() => setShowDeleteConfirmation(false)}
aria-label="Supprimer"
>
<>
<span>Êtes-vous sûr de vouloir supprimer ce contenu ?</span>
<Inline>
<Button onClick={onDelete}>Confirmer</Button>
<Button
variant="link"
onClick={() => setShowDeleteConfirmation(false)}
>
Annuler
</Button>
</Inline>
</>
</Dialog>
{editorialContent?.cdtnId && (
<>
<div
sx={{
display: "flex",
justifyContent: "flex-end",
mb: "small",
}}
>
<Button
type="button"
onClick={() => {
setShowDeleteConfirmation(true);
<Stack>
{fetching ? (
<Spinner />
) : (
<>
<Dialog
isOpen={showDeleteConfirmation}
onDismiss={() => setShowDeleteConfirmation(false)}
aria-label="Supprimer"
>
<>
<span>Êtes-vous sûr de vouloir supprimer ce contenu ?</span>
<Inline>
<Button onClick={onDelete}>Confirmer</Button>
<Button
variant="link"
onClick={() => setShowDeleteConfirmation(false)}
>
Annuler
</Button>
</Inline>
</>
</Dialog>
{editorialContent?.cdtnId && (
<>
<div
sx={{
display: "flex",
justifyContent: "flex-end",
mb: "small",
}}
>
<IoMdTrash
sx={{
height: "iconSmall",
mr: "xsmall",
width: "iconSmall",
<Button
type="button"
onClick={() => {
setShowDeleteConfirmation(true);
}}
/>
Supprimer le contenu
</Button>
</div>
</>
)}
<EditorialContentForm
editorialContent={editorialContent}
loading={editResult.fetching || deleteResult.fetching}
onSubmit={onSubmit}
/>
</>
)}
>
<IoMdTrash
sx={{
height: "iconSmall",
mr: "xsmall",
width: "iconSmall",
}}
/>
Supprimer le contenu
</Button>
</div>
</>
)}
<EditorialContentForm
editorialContent={editorialContent}
loading={editResult.fetching || deleteResult.fetching}
onSubmit={onSubmit}
/>
</>
)}
</Stack>
</Layout>
);
}
Expand Down
Loading