-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linking from block preview to block admin for non-trivial composi…
…te/list block combinations (#1569) fix issue from #1507 --------- Co-authored-by: Johannes Obermair <[email protected]>
- Loading branch information
1 parent
3ee4ce0
commit 76f85ab
Showing
14 changed files
with
214 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@comet/blocks-admin": patch | ||
--- | ||
|
||
Fix linking from block preview to block admin for non-trivial composite/list block combinations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { BlockCategory, createCompositeBlock } from "@comet/blocks-admin"; | ||
import { DamImageBlock } from "@comet/cms-admin"; | ||
import { HeadlineBlock } from "@src/common/blocks/HeadlineBlock"; | ||
import { LinkListBlock } from "@src/common/blocks/LinkListBlock"; | ||
import React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
const TeaserBlock = createCompositeBlock( | ||
{ | ||
name: "Teaser", | ||
displayName: <FormattedMessage id="blocks.teaser" defaultMessage="Teaser" />, | ||
blocks: { | ||
// Normal | ||
headline: { | ||
block: HeadlineBlock, | ||
title: <FormattedMessage id="blocks.teaser.headline" defaultMessage="Headline" />, | ||
}, | ||
// Nested | ||
image: { | ||
block: DamImageBlock, | ||
title: <FormattedMessage id="blocks.teaser.image" defaultMessage="Image" />, | ||
nested: true, | ||
}, | ||
// Subroutes | ||
links: { | ||
block: LinkListBlock, | ||
title: <FormattedMessage id="blocks.teaser.links" defaultMessage="Links" />, | ||
}, | ||
// Nested inner subroutes | ||
buttons: { | ||
block: LinkListBlock, | ||
title: <FormattedMessage id="blocks.teaser.buttons" defaultMessage="Buttons" />, | ||
nested: true, | ||
}, | ||
}, | ||
}, | ||
(block) => { | ||
block.category = BlockCategory.Teaser; | ||
return block; | ||
}, | ||
); | ||
|
||
export { TeaserBlock }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
BlockData, | ||
BlockDataInterface, | ||
BlockInput, | ||
ChildBlock, | ||
ChildBlockInput, | ||
createBlock, | ||
ExtractBlockData, | ||
ExtractBlockInput, | ||
inputToData, | ||
} from "@comet/blocks-api"; | ||
import { DamImageBlock } from "@comet/cms-api"; | ||
import { LinkListBlock } from "@src/common/blocks/link-list.block"; | ||
|
||
import { HeadlineBlock } from "./headline.block"; | ||
|
||
class TeaserBlockData extends BlockData { | ||
@ChildBlock(HeadlineBlock) | ||
headline: ExtractBlockData<typeof HeadlineBlock>; | ||
|
||
@ChildBlock(DamImageBlock) | ||
image: ExtractBlockData<typeof DamImageBlock>; | ||
|
||
@ChildBlock(LinkListBlock) | ||
links: ExtractBlockData<typeof LinkListBlock>; | ||
|
||
@ChildBlock(LinkListBlock) | ||
buttons: ExtractBlockData<typeof LinkListBlock>; | ||
} | ||
|
||
class TeaserBlockInput extends BlockInput { | ||
@ChildBlockInput(HeadlineBlock) | ||
headline: ExtractBlockInput<typeof HeadlineBlock>; | ||
|
||
@ChildBlockInput(DamImageBlock) | ||
image: ExtractBlockInput<typeof DamImageBlock>; | ||
|
||
@ChildBlockInput(LinkListBlock) | ||
links: ExtractBlockInput<typeof LinkListBlock>; | ||
|
||
@ChildBlockInput(LinkListBlock) | ||
buttons: ExtractBlockInput<typeof LinkListBlock>; | ||
|
||
transformToBlockData(): BlockDataInterface { | ||
return inputToData(TeaserBlockData, this); | ||
} | ||
} | ||
|
||
const TeaserBlock = createBlock(TeaserBlockData, TeaserBlockInput, "Teaser"); | ||
|
||
export { TeaserBlock }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { PropsWithData, withPreview } from "@comet/cms-site"; | ||
import { TeaserBlockData } from "@src/blocks.generated"; | ||
import { DamImageBlock } from "@src/blocks/DamImageBlock"; | ||
import { HeadlineBlock } from "@src/blocks/HeadlineBlock"; | ||
import { LinkListBlock } from "@src/blocks/LinkListBlock"; | ||
import styled from "styled-components"; | ||
|
||
const TeaserBlock = withPreview( | ||
({ data: { headline, image, links, buttons } }: PropsWithData<TeaserBlockData>) => { | ||
return ( | ||
<Root> | ||
<HeadlineBlock data={headline} /> | ||
<DamImageBlock data={image} /> | ||
<LinkListBlock data={links} /> | ||
<LinkListBlock data={buttons} /> | ||
</Root> | ||
); | ||
}, | ||
{ label: "Teaser" }, | ||
); | ||
|
||
const Root = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 1rem; | ||
`; | ||
|
||
export { TeaserBlock }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters