-
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.
Generate news with future Admin Generator (#2661)
- Loading branch information
1 parent
47d40ae
commit 77f1889
Showing
9 changed files
with
275 additions
and
209 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
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,48 @@ | ||
import { future_FormConfig as FormConfig } from "@comet/cms-admin"; | ||
import { GQLNews } from "@src/graphql.generated"; | ||
|
||
export const NewsForm: FormConfig<GQLNews> = { | ||
type: "form", | ||
gqlType: "News", | ||
fragmentName: "NewsForm", | ||
fields: [ | ||
{ | ||
type: "text", | ||
name: "slug", | ||
label: "Slug", | ||
required: true, | ||
}, | ||
{ | ||
type: "text", | ||
name: "title", | ||
label: "Title", | ||
required: true, | ||
}, | ||
{ | ||
type: "date", | ||
name: "date", | ||
label: "Date", | ||
required: true, | ||
}, | ||
{ | ||
type: "staticSelect", | ||
name: "category", | ||
label: "Category", | ||
required: true, | ||
inputType: "radio", | ||
values: ["Events", "Company", "Awards"], | ||
}, | ||
{ | ||
type: "block", | ||
name: "image", | ||
label: "Image", | ||
block: { name: "DamImageBlock", import: "@comet/cms-admin" }, | ||
}, | ||
{ | ||
type: "block", | ||
name: "content", | ||
label: "Content", | ||
block: { name: "NewsContentBlock", import: "../blocks/NewsContentBlock" }, | ||
}, | ||
], | ||
}; |
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,38 @@ | ||
import { future_GridConfig as GridConfig } from "@comet/cms-admin"; | ||
import { GQLNews } from "@src/graphql.generated"; | ||
|
||
export const NewsGrid: GridConfig<GQLNews> = { | ||
type: "grid", | ||
gqlType: "News", | ||
fragmentName: "NewsGrid", | ||
columns: [ | ||
{ | ||
type: "text", | ||
name: "title", | ||
headerName: "Title", | ||
}, | ||
{ | ||
type: "date", | ||
name: "date", | ||
headerName: "Date", | ||
}, | ||
{ | ||
type: "staticSelect", | ||
name: "category", | ||
headerName: "Category", | ||
values: ["Events", "Company", "Awards"], | ||
}, | ||
{ | ||
type: "block", | ||
name: "image", | ||
headerName: "Image", | ||
block: { name: "DamImageBlock", import: "@comet/cms-admin" }, | ||
}, | ||
{ | ||
type: "block", | ||
name: "content", | ||
headerName: "Content", | ||
block: { name: "NewsContentBlock", import: "../blocks/NewsContentBlock" }, | ||
}, | ||
], | ||
}; |
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,65 @@ | ||
import { | ||
MainContent, | ||
SaveBoundary, | ||
SaveBoundarySaveButton, | ||
Stack, | ||
StackPage, | ||
StackSwitch, | ||
StackToolbar, | ||
ToolbarActions, | ||
ToolbarAutomaticTitleItem, | ||
ToolbarBackButton, | ||
ToolbarFillSpace, | ||
} from "@comet/admin"; | ||
import { ContentScopeIndicator } from "@comet/cms-admin"; | ||
import { useContentScope } from "@src/common/ContentScopeProvider"; | ||
import { useIntl } from "react-intl"; | ||
|
||
import { NewsForm } from "./generated/NewsForm"; | ||
import { NewsGrid } from "./generated/NewsGrid"; | ||
|
||
const FormToolbar = () => ( | ||
<StackToolbar scopeIndicator={<ContentScopeIndicator />}> | ||
<ToolbarBackButton /> | ||
<ToolbarAutomaticTitleItem /> | ||
<ToolbarFillSpace /> | ||
<ToolbarActions> | ||
<SaveBoundarySaveButton /> | ||
</ToolbarActions> | ||
</StackToolbar> | ||
); | ||
|
||
export function NewsPage() { | ||
const intl = useIntl(); | ||
const { scope } = useContentScope(); | ||
return ( | ||
<Stack topLevelTitle={intl.formatMessage({ id: "news.news", defaultMessage: "News" })}> | ||
<StackSwitch> | ||
<StackPage name="grid"> | ||
<StackToolbar scopeIndicator={<ContentScopeIndicator />} /> | ||
<MainContent fullHeight> | ||
<NewsGrid /> | ||
</MainContent> | ||
</StackPage> | ||
<StackPage name="edit" title={intl.formatMessage({ id: "news.news", defaultMessage: "Edit News" })}> | ||
{(selectedNewsId) => ( | ||
<SaveBoundary> | ||
<FormToolbar /> | ||
<MainContent> | ||
<NewsForm id={selectedNewsId} scope={scope} /> | ||
</MainContent> | ||
</SaveBoundary> | ||
)} | ||
</StackPage> | ||
<StackPage name="add" title={intl.formatMessage({ id: "news.news", defaultMessage: "Add News" })}> | ||
<SaveBoundary> | ||
<FormToolbar /> | ||
<MainContent> | ||
<NewsForm scope={scope} /> | ||
</MainContent> | ||
</SaveBoundary> | ||
</StackPage> | ||
</StackSwitch> | ||
</Stack> | ||
); | ||
} |
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
Oops, something went wrong.