Skip to content

Commit

Permalink
Merge pull request #1528 from vivid-planet/merge-main-into-next
Browse files Browse the repository at this point in the history
Merge main into next
  • Loading branch information
thomasdax98 authored Dec 22, 2023
2 parents 0787562 + 0200926 commit a37ebde
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 15 deletions.
23 changes: 23 additions & 0 deletions .changeset/smart-weeks-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@comet/admin": minor
---

Add `Alert` component

**Example:**

```tsx
import { Alert, OkayButton, SaveButton } from "@comet/admin";

<Alert
severity="warning"
title="Title"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
>
Notification Text
</Alert>
```
5 changes: 5 additions & 0 deletions .changeset/tricky-adults-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-admin": minor
---

Make all DAM license fields optional if `LicenseType` is `ROYALTY_FREE` even if `requireLicense` is true in `DamConfig`
6 changes: 6 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
addAssignees: author

addReviewers: true

reviewers:
- johnnyomair
22 changes: 21 additions & 1 deletion demo/api/src/db/fixtures/fixtures.console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { PageTreeNodeCategory } from "@src/page-tree/page-tree-node-category";
import { PageContentBlock } from "@src/pages/blocks/PageContentBlock";
import { PageInput } from "@src/pages/dto/page.input";
import { Page } from "@src/pages/entities/page.entity";
import { UserGroup } from "@src/user-groups/user-group";
import faker from "faker";
import { Command, Console } from "nestjs-console";
import slugify from "slugify";
Expand Down Expand Up @@ -104,6 +105,8 @@ export class FixturesConsole {
id: attachedDocumentIds[0],
type: "Page",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand All @@ -113,7 +116,14 @@ export class FixturesConsole {
await this.pageTreeService.updateNodeVisibility(node.id, PageTreeNodeVisibility.Published);

node = await this.pageTreeService.createNode(
{ name: "Sub", slug: "sub", parentId: node.id, attachedDocument: { id: attachedDocumentIds[1], type: "Page" } },
{
name: "Sub",
slug: "sub",
parentId: node.id,
attachedDocument: { id: attachedDocumentIds[1], type: "Page" },
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
);
Expand All @@ -129,6 +139,8 @@ export class FixturesConsole {
id: attachedDocumentIds[2],
type: "Page",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand All @@ -144,6 +156,8 @@ export class FixturesConsole {
attachedDocument: {
type: "Page",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand All @@ -160,6 +174,8 @@ export class FixturesConsole {
id: attachedDocumentIds[3],
type: "Link",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand All @@ -176,6 +192,8 @@ export class FixturesConsole {
id: attachedDocumentIds[4],
type: "Page",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand Down Expand Up @@ -226,6 +244,8 @@ export class FixturesConsole {
slug: slugify(name),
parentId: level > 0 ? faker.random.arrayElement(pages[level - 1]).id : undefined,
attachedDocument: { type: "Page" },
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class ManyImagesTestPageGenerator {
id: uuidDocument,
type: "Page",
},
// @ts-expect-error Typing of PageTreeService is wrong https://github.com/vivid-planet/comet/pull/1515#issue-2042001589
userGroup: UserGroup.All,
},
PageTreeNodeCategory.MainNavigation,
scope,
Expand Down
152 changes: 152 additions & 0 deletions packages/admin/admin-stories/src/admin/alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { Alert, OkayButton, SaveButton } from "@comet/admin";
import { ArrowRight } from "@comet/admin-icons";
import { Button, Card, CardContent, Typography } from "@mui/material";
import { Stack } from "@mui/system";
import { storiesOf } from "@storybook/react";
import React from "react";

function Story() {
return (
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 50 }}>
<Card variant="outlined">
<CardContent>
<Typography variant="h4" marginBottom={4}>
With Title
</Typography>
<Stack spacing={4} direction="column">
<Alert
severity="info"
title="Title"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
<Alert
severity="warning"
title="Title"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
onClose={() => {
// noop
}}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vel vehicula est. Nunc congue velit sem, ac porttitor
massa semper nec. Proin quis volutpat magna. Mauris eget libero et mi imperdiet ultrices. Donec eget interdum odio.
Maecenas blandit ipsum et eros tempus porttitor. Aliquam erat volutpat.
</Alert>
<Alert
severity="error"
title="Title"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
<Alert
severity="success"
title="Title"
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
</Stack>
</CardContent>
</Card>

<Card>
<CardContent>
<Typography variant="h4" marginBottom={4}>
Without Title
</Typography>
<Stack spacing={4} marginBottom={6}>
<Alert
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
<Alert
severity="warning"
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
<Alert
severity="error"
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
<Alert
severity="success"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
onClose={() => {
// noop
}}
>
Notification Text
</Alert>
</Stack>
</CardContent>
</Card>

<Card>
<CardContent>
<Stack spacing={4}>
<Typography variant="h4">Without Close Button</Typography>
<Alert title="Title">
<Typography>Notification Text</Typography>
</Alert>
<Alert severity="warning">
<Typography>Notification Text</Typography>
</Alert>
<Alert
severity="warning"
action={
<Button variant="text" startIcon={<ArrowRight />}>
Action Text
</Button>
}
>
<Typography>Notification Text</Typography>
</Alert>
<Typography variant="h4">Other Actions</Typography>
<Alert title="Title" action={<SaveButton />}>
Text
</Alert>
<Alert severity="warning" action={<OkayButton />} />
</Stack>
</CardContent>
</Card>
</div>
);
}

storiesOf("@comet/admin/alert/Alert", module).add("Alerts", () => <Story />);
45 changes: 45 additions & 0 deletions packages/admin/admin-theme/src/componentsTheme/MuiAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Check, Error, Info, Warning } from "@comet/admin-icons";
import React from "react";

import { mergeOverrideStyles } from "../utils/mergeOverrideStyles";
import { GetMuiComponentTheme } from "./getComponentsTheme";

export const getMuiAlert: GetMuiComponentTheme<"MuiAlert"> = (component, { palette }) => ({
...component,
defaultProps: {
variant: "outlined",

iconMapping: {
info: <Info color="info" />,
success: <Check color="success" />,
error: <Error color="error" />,
warning: <Warning color="warning" />,
},
...component?.defaultProps,
},
styleOverrides: mergeOverrideStyles<"MuiAlert">(component?.styleOverrides, {
root: {},
outlined: {
borderLeftWidth: 5,
backgroundColor: "#fff",
borderRadius: 4,
color: palette.grey[800],
},
outlinedSuccess: {
borderColor: "#14CC33",
},
outlinedInfo: {
borderColor: "#29B6F6",
},
outlinedWarning: {
borderColor: "#FFB31A",
},
outlinedError: {
borderColor: "#D11700",
},
icon: {
marginRight: 0,
padding: 0,
},
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ZIndex } from "@mui/material/styles/zIndex";
import { Spacing } from "@mui/system";

import { getMuiAccordion } from "./MuiAccordion";
import { getMuiAlert } from "./MuiAlert";
import { getMuiAppBar } from "./MuiAppBar";
import { getMuiAutocomplete } from "./MuiAutocomplete";
import { getMuiButton } from "./MuiButton";
Expand Down Expand Up @@ -101,4 +102,5 @@ export const getComponentsTheme = (components: Components, themeData: ThemeData)
MuiToggleButtonGroup: getMuiToggleButtonGroup(components.MuiToggleButtonGroup, themeData),
MuiTooltip: getMuiTooltip(components.MuiTooltip, themeData),
MuiTypography: getMuiTypography(components.MuiTypography, themeData),
MuiAlert: getMuiAlert(components.MuiAlert, themeData),
});
Loading

0 comments on commit a37ebde

Please sign in to comment.