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

Merge @comet/blocks-admin into @comet/cms-admin #3049

Merged
merged 24 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
307791c
Merge `@comet/blocks-admin` into `@comet/cms-admin`
johnnyomair Jan 8, 2025
e55a000
Remove nested blocks/ folder
johnnyomair Jan 14, 2025
3b51b6a
Remove `CannotPasteBlockDialog` export
johnnyomair Jan 14, 2025
6e809c9
Remove `ClipboardContent` export
johnnyomair Jan 14, 2025
f351baa
Remove `useBlockClipboard` export
johnnyomair Jan 14, 2025
d53aaeb
Remove `Collapsible` export
johnnyomair Jan 14, 2025
aad13e2
Remove `CollapsibleSwitchButtonHeader` export
johnnyomair Jan 14, 2025
39dda7d
Remove `usePromise` export
johnnyomair Jan 14, 2025
8c4201a
Use named export for `decomposeUpdateStateAction`
johnnyomair Jan 14, 2025
e9fe77f
Rename `createCompositeSetting` to `createCompositeBlockField`
johnnyomair Jan 14, 2025
9ad7b2d
Rename `createCompositeSettings` to `createCompositeBlockFields`
johnnyomair Jan 14, 2025
73a5fba
Rename `IPreviewContext` to `BlockPreviewContext`
johnnyomair Jan 14, 2025
89c0e1a
Rename `PreviewStateInterface` to `BlockPreviewStateInterface`
johnnyomair Jan 14, 2025
15a2778
Add changeset
johnnyomair Jan 14, 2025
5c1fa4b
Fix test by using Jest config from `@comet/blocks-admin`
johnnyomair Jan 14, 2025
a1a4907
Remove `DispatchSetStateAction`, `SetStateAction` and `SetStateFn`
johnnyomair Feb 3, 2025
adc565f
Merge branch 'next' into merge-blocks-admin-into-cms-admin
johnnyomair Feb 3, 2025
52fafb5
Add section to migration guide
johnnyomair Feb 3, 2025
fcc2b7f
Remove clipboard helpers
johnnyomair Feb 4, 2025
3366329
Add "Block" prefix to all AdminComponent components
johnnyomair Feb 4, 2025
36500ec
Move story into cms-admin folder
johnnyomair Feb 4, 2025
97378b5
Merge branch 'next' into merge-blocks-admin-into-cms-admin
johnnyomair Feb 4, 2025
c0dd3c5
Merge branch 'next' into merge-blocks-admin-into-cms-admin
johnnyomair Feb 5, 2025
6222d8b
Merge branch 'next' into merge-blocks-admin-into-cms-admin
johnnyomair Feb 11, 2025
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
7 changes: 7 additions & 0 deletions .changeset/fast-plums-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@comet/cms-admin": major
---

Remove deprecated `readClipboard` and `writeClipboard` helpers

Use `readClipboardText` and `writeClipboardText` from `@comet/admin` instead.
2 changes: 1 addition & 1 deletion .changeset/four-cobras-mate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@comet/blocks-admin": major
"@comet/cms-admin": major
---

Remove `BindBlockAdminComponent` from public API
1 change: 0 additions & 1 deletion .changeset/perfect-mangos-greet.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
"@comet/admin-color-picker": major
"@comet/admin-date-time": major
"@comet/blocks-admin": major
"@comet/admin-icons": major
"@comet/admin-theme": major
"@comet/admin-rte": major
Expand Down
2 changes: 1 addition & 1 deletion .changeset/polite-chairs-join.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@comet/blocks-admin": minor
"@comet/cms-admin": minor
---

Add an `override` argument to all block factories to follow `createCompositeBlock`'s pattern
48 changes: 48 additions & 0 deletions .changeset/six-suns-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
"@comet/cms-admin": major
---

Merge `@comet/blocks-admin` into `@comet/cms-admin`

The dedicated `@comet/blocks-admin` package was originally introduced to support projects without CMS parts.
It turned out that this is never the case, so the separation doesn't make sense anymore.
Therefore, the `@comet/blocks-admin` is merged into this package.

**Breaking changes**

- The `@comet/blocks-admin` package doesn't exist anymore
- Multiple exports that shouldn't be used have been removed from the public API
- `CannotPasteBlockDialog`
- `ClipboardContent`
- `useBlockClipboard`
- `Collapsible`
- `CollapsibleSwitchButtonHeader`
- `usePromise`
- `DispatchSetStateAction` (use `Dispatch<SetStateAction<T>>` from `react` instead)
- `SetStateAction`
- `SetStateFn`
- Multiple exports that were too generic have been renamed
- `createCompositeSetting` -> `createCompositeBlockField`
- `createCompositeSettings` -> `createCompositeBlockFields`
- `IPreviewContext` -> `BlockPreviewContext`
- `PreviewStateInterface` -> `BlockPreviewStateInterface`
- `AdminComponentPart` -> `BlockAdminComponentPart`
- `AdminComponentButton`-> `BlockAdminComponentButton`
- `AdminComponentNestedButton`-> `BlockAdminComponentNestedButton`
- `AdminComponentPaper`->`BlockAdminComponentPaper`
- `useAdminComponentPaper`-> `useBlockAdminComponentPaper`
- `AdminComponentRoot`-> `BlockAdminComponentRoot`
- `AdminComponentSection`-> `BlockAdminComponentSection`
- `AdminComponentSectionGroup`-> `BlockAdminComponentSectionGroup`
- `AdminTabLabel`-> `BlockAdminTabLabel`
- `AdminTabsProps`-> `BlockAdminTabsProps`
- `AdminTabs`-> `BlockAdminTabs`

**How to upgrade**

To upgrade, perform the following changes:

1. Uninstall the `@comet/blocks-admin` package
2. Update all your imports from `@comet/blocks-admin` to `@comet/cms-admin`
3. Remove usages of removed exports
4. Update imports that have been renamed
1 change: 0 additions & 1 deletion .changeset/thirty-moles-invite.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@comet/admin-rte": minor
"@comet/admin-theme": minor
"@comet/admin": minor
"@comet/blocks-admin": minor
"@comet/cms-admin": minor
---

Expand Down
2 changes: 1 addition & 1 deletion .changeset/two-humans-decide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@comet/blocks-admin": major
"@comet/cms-admin": major
---

Make fields full-width by default when using `createCompositeBlockTextField` or `createCompositeBlockSelectField`
2 changes: 1 addition & 1 deletion .changeset/wicked-coins-work.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@comet/blocks-admin": patch
"@comet/cms-admin": patch
---

Add `BlocksBlockOutput`, `ListBlockOutput`, `OneOfBlockOutput`, `OneOfBlockPreviewState`, and `OptionalBlockOutput` to the public API
1 change: 0 additions & 1 deletion copy-schema-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const fs = require("fs");
(async () => {
await Promise.all([
fs.promises.copyFile("packages/api/cms-api/schema.gql", "packages/admin/cms-admin/schema.gql"),
fs.promises.copyFile("packages/api/cms-api/block-meta.json", "packages/admin/blocks-admin/block-meta.json"),
fs.promises.copyFile("packages/api/cms-api/block-meta.json", "packages/admin/cms-admin/block-meta.json"),
fs.promises.copyFile("packages/api/cms-api/block-meta.json", "packages/site/cms-site/block-meta.json"),

Expand Down
1 change: 0 additions & 1 deletion demo/admin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ fragmentTypes.json
lang
lang-extracted
lang-compiled
/blocks-admin-lang
graphql.generated.ts
block-meta.json
src/blocks.generated.ts
Expand Down
9 changes: 0 additions & 9 deletions demo/admin/lint-staged.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion demo/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@comet/admin-date-time": "workspace:*",
"@comet/admin-icons": "workspace:*",
"@comet/admin-theme": "workspace:*",
"@comet/blocks-admin": "workspace:*",
"@comet/cms-admin": "workspace:*",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
Expand Down
86 changes: 44 additions & 42 deletions demo/admin/src/common/ComponentDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
Snips,
} from "@comet/admin-icons";
import {
AdminComponentButton,
AdminComponentNestedButton,
AdminComponentPaper,
AdminComponentSection,
AdminComponentSectionGroup,
BlockAdminComponentButton,
BlockAdminComponentNestedButton,
BlockAdminComponentPaper,
BlockAdminComponentSection,
BlockAdminComponentSectionGroup,
BlocksFinalForm,
ColumnsLayoutPreview,
ColumnsLayoutPreviewContent,
Expand All @@ -38,9 +38,11 @@ import {
createFinalFormBlock,
createListBlock,
createOptionalBlock,
DamImageBlock,
FinalFormToggleButtonGroup,
PixelImageBlock,
resolveNewState,
} from "@comet/blocks-admin";
import { DamImageBlock, FinalFormToggleButtonGroup, PixelImageBlock } from "@comet/cms-admin";
} from "@comet/cms-admin";
import { Box, Grid, MenuItem, Typography } from "@mui/material";
import { type ReactNode, useState } from "react";

Expand Down Expand Up @@ -115,22 +117,22 @@ export function ComponentDemo() {
Basic Blocks
</Typography>

<AdminComponentSectionGroup title="Grouped Section Headline">
<AdminComponentSection>
<BlockAdminComponentSectionGroup title="Grouped Section Headline">
<BlockAdminComponentSection>
<Typography variant="subtitle1">Label</Typography>
</AdminComponentSection>
</BlockAdminComponentSection>

<AdminComponentSection>
<BlockAdminComponentSection>
<Typography variant="caption">
Infotext/Caption Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
Aenean massa.
</Typography>
</AdminComponentSection>
</BlockAdminComponentSection>

<AdminComponentSection>
<AdminComponentPaper>Card with any content</AdminComponentPaper>
</AdminComponentSection>
</AdminComponentSectionGroup>
<BlockAdminComponentSection>
<BlockAdminComponentPaper>Card with any content</BlockAdminComponentPaper>
</BlockAdminComponentSection>
</BlockAdminComponentSectionGroup>

<FinalForm
mode="add"
Expand Down Expand Up @@ -305,74 +307,74 @@ export function ComponentDemo() {
Action Blocks
</Typography>

<AdminComponentSection>
<BlockAdminComponentSection>
<OptionalRichTextBlock.AdminComponent
state={optionalBlockState}
updateState={(setStateAction) => setOptionalBlockState((prevState) => resolveNewState({ prevState, setStateAction }))}
/>
</AdminComponentSection>
</BlockAdminComponentSection>

<AdminComponentSection>
<AdminComponentNestedButton displayName="Nested" preview="Lorem impsum dolor" />
</AdminComponentSection>
<BlockAdminComponentSection>
<BlockAdminComponentNestedButton displayName="Nested" preview="Lorem impsum dolor" />
</BlockAdminComponentSection>

<AdminComponentSection>
<AdminComponentButton startIcon={<Add />} variant="primary">
<BlockAdminComponentSection>
<BlockAdminComponentButton startIcon={<Add />} variant="primary">
Action Primary
</AdminComponentButton>
</AdminComponentSection>
</BlockAdminComponentButton>
</BlockAdminComponentSection>

<AdminComponentSection>
<AdminComponentButton startIcon={<Add />}>Action Default</AdminComponentButton>
</AdminComponentSection>
<BlockAdminComponentSection>
<BlockAdminComponentButton startIcon={<Add />}>Action Default</BlockAdminComponentButton>
</BlockAdminComponentSection>

<AdminComponentSection>
<BlockAdminComponentSection>
<PixelImageBlock.AdminComponent
state={pixelImageBlockState}
updateState={(setStateAction) =>
setPixelImageBlockState((prevState) => resolveNewState({ prevState, setStateAction }))
}
/>
</AdminComponentSection>
</BlockAdminComponentSection>

<Typography variant="h2" gutterBottom>
Collection Blocks
</Typography>

<AdminComponentSection title="List Block">
<BlockAdminComponentSection title="List Block">
<ListBlock.AdminComponent
state={listBlockState}
updateState={(setStateAction) => setListBlockState((prevState) => resolveNewState({ prevState, setStateAction }))}
/>
</AdminComponentSection>
<AdminComponentSection title="Blocks Block">
</BlockAdminComponentSection>
<BlockAdminComponentSection title="Blocks Block">
<BlocksBlock.AdminComponent
state={blocksBlockState}
updateState={(setStateAction) => setBlocksBlockState((prevState) => resolveNewState({ prevState, setStateAction }))}
/>
</AdminComponentSection>
<AdminComponentSection title="Columns Block">
</BlockAdminComponentSection>
<BlockAdminComponentSection title="Columns Block">
<ColumnsBlock.AdminComponent
state={columnsBlockState}
updateState={(setStateAction) => setColumnsBlockState((prevState) => resolveNewState({ prevState, setStateAction }))}
/>
</AdminComponentSection>
</BlockAdminComponentSection>
</Grid>
<Grid item xs={3}>
<Typography variant="h2" gutterBottom>
Compounds
</Typography>

<AdminComponentSection>
<AdminComponentPaper disablePadding>
<BlockAdminComponentSection>
<BlockAdminComponentPaper disablePadding>
<DamImageBlock.AdminComponent
state={imageBlockState}
updateState={(setStateAction) =>
setImageBlockState((prevState) => resolveNewState({ prevState, setStateAction }))
}
/>
</AdminComponentPaper>
<AdminComponentPaper>
</BlockAdminComponentPaper>
<BlockAdminComponentPaper>
<BlocksFinalForm
onSubmit={() => {
// noop
Expand All @@ -391,8 +393,8 @@ export function ComponentDemo() {

<SwitchField name="shadow" fieldLabel="Shadow" />
</BlocksFinalForm>
</AdminComponentPaper>
</AdminComponentSection>
</BlockAdminComponentPaper>
</BlockAdminComponentSection>
</Grid>
</Grid>
</MainContent>
Expand Down
2 changes: 1 addition & 1 deletion demo/admin/src/common/blocks/AccordionBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createListBlock } from "@comet/blocks-admin";
import { createListBlock } from "@comet/cms-admin";
import { AccordionItemBlock } from "@src/common/blocks/AccordionItemBlock";
import { FormattedMessage } from "react-intl";

Expand Down
6 changes: 3 additions & 3 deletions demo/admin/src/common/blocks/AccordionItemBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
BlocksFinalForm,
createBlocksBlock,
createCompositeBlock,
createCompositeBlockField,
createCompositeBlockTextField,
createCompositeSetting,
} from "@comet/blocks-admin";
} from "@comet/cms-admin";
import { type AccordionItemBlockData } from "@src/blocks.generated";
import { RichTextBlock } from "@src/common/blocks/RichTextBlock";
import { SpaceBlock } from "@src/common/blocks/SpaceBlock";
Expand Down Expand Up @@ -40,7 +40,7 @@ export const AccordionItemBlock = createCompositeBlock(
title: <FormattedMessage id="accordionBlock.accordionItem.content" defaultMessage="Content" />,
},
openByDefault: {
block: createCompositeSetting<AccordionItemBlockData["openByDefault"]>({
block: createCompositeBlockField<AccordionItemBlockData["openByDefault"]>({
defaultValue: false,
AdminComponent: ({ state, updateState }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion demo/admin/src/common/blocks/CallToActionBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockCategory, createCompositeBlock, createCompositeBlockSelectField } from "@comet/blocks-admin";
import { BlockCategory, createCompositeBlock, createCompositeBlockSelectField } from "@comet/cms-admin";
import { type CallToActionBlockData } from "@src/blocks.generated";
import { FormattedMessage } from "react-intl";

Expand Down
2 changes: 1 addition & 1 deletion demo/admin/src/common/blocks/CallToActionListBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createListBlock } from "@comet/blocks-admin";
import { createListBlock } from "@comet/cms-admin";
import { CallToActionBlock } from "@src/common/blocks/CallToActionBlock";
import { FormattedMessage } from "react-intl";

Expand Down
3 changes: 1 addition & 2 deletions demo/admin/src/common/blocks/HeadingBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockCategory, createCompositeBlock, createCompositeBlockSelectField } from "@comet/blocks-admin";
import { createRichTextBlock } from "@comet/cms-admin";
import { BlockCategory, createCompositeBlock, createCompositeBlockSelectField, createRichTextBlock } from "@comet/cms-admin";
import { type HeadingBlockData } from "@src/blocks.generated";
import { FormattedMessage } from "react-intl";

Expand Down
6 changes: 3 additions & 3 deletions demo/admin/src/common/blocks/LayoutBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
ColumnsLayoutPreviewContent,
ColumnsLayoutPreviewSpacing,
createCompositeBlock,
createCompositeSetting,
createCompositeBlockField,
FinalFormLayoutSelect,
} from "@comet/blocks-admin";
} from "@comet/cms-admin";
import { type LayoutBlockData } from "@src/blocks.generated";
import { RichTextBlock } from "@src/common/blocks/RichTextBlock";
import { FormattedMessage } from "react-intl";
Expand Down Expand Up @@ -124,7 +124,7 @@ export const LayoutBlock = createCompositeBlock(
visibleOrderedBlocksForState: (state: LayoutBlockData) => layoutOptions.find((option) => option.name === state.layout)?.visibleBlocks,
blocks: {
layout: {
block: createCompositeSetting<LayoutBlockData["layout"]>({
block: createCompositeBlockField<LayoutBlockData["layout"]>({
defaultValue: "layout1",
AdminComponent: ({ state, updateState }) => (
<BlocksFinalForm<{ layout: ColumnsBlockLayout }>
Expand Down
2 changes: 1 addition & 1 deletion demo/admin/src/common/blocks/LinkListBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createListBlock } from "@comet/blocks-admin";
import { createListBlock } from "@comet/cms-admin";
import { TextLinkBlock } from "@src/common/blocks/TextLinkBlock";
import { userGroupAdditionalItemFields } from "@src/userGroups/userGroupAdditionalItemFields";
import { UserGroupChip } from "@src/userGroups/UserGroupChip";
Expand Down
11 changes: 9 additions & 2 deletions demo/admin/src/common/blocks/MediaBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { BlockCategory, type BlockInterface, createOneOfBlock } from "@comet/blocks-admin";
import { DamImageBlock, DamVideoBlock, VimeoVideoBlock, YouTubeVideoBlock } from "@comet/cms-admin";
import {
BlockCategory,
type BlockInterface,
createOneOfBlock,
DamImageBlock,
DamVideoBlock,
VimeoVideoBlock,
YouTubeVideoBlock,
} from "@comet/cms-admin";
import { FormattedMessage } from "react-intl";

export const MediaBlock: BlockInterface = createOneOfBlock({
Expand Down
Loading