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

chore: update demo to latest comet starter #2899

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4eb2b6f
chore: update demo to latest comet starter
piotrgulbis Dec 9, 2024
9674713
fix richtextblock imports
piotrgulbis Dec 9, 2024
14a4d74
fix media block
piotrgulbis Dec 9, 2024
136bb22
fix media block and theme
piotrgulbis Dec 9, 2024
9a6d665
fix footer api fields
piotrgulbis Dec 9, 2024
c14f64e
add starter blocks to admin
piotrgulbis Dec 9, 2024
9a17879
add missing media aspect ratios util
piotrgulbis Dec 9, 2024
408153c
add missing block meta changes
piotrgulbis Dec 9, 2024
41c6a4e
add missing key facts in block meta
piotrgulbis Dec 9, 2024
be11f6c
remove older blocks, update blocks from site in comet starter
piotrgulbis Dec 10, 2024
41f1930
update app loader
piotrgulbis Dec 10, 2024
8c22f2a
update site-pages to removed blocks
piotrgulbis Dec 10, 2024
607fb6c
fix media gallery and call to action blocks
piotrgulbis Dec 11, 2024
b60cd7c
remove mediagalleryblock
piotrgulbis Dec 11, 2024
9c53872
split link list block with additional fields into new block
piotrgulbis Dec 11, 2024
b567ab6
revert graphql client changes
piotrgulbis Dec 11, 2024
42a456e
use new graphql client in page
piotrgulbis Dec 11, 2024
c5e8c1f
update site folder structure
piotrgulbis Dec 11, 2024
a2a1e7a
fix imports after folder rename
piotrgulbis Dec 11, 2024
dcad8e6
update footer permissions
piotrgulbis Dec 12, 2024
dc094be
restore code removed, adjusted components based on comments
piotrgulbis Dec 12, 2024
33962b1
restore layout block, rename headline field to heading, add additiona…
piotrgulbis Dec 12, 2024
a31ca11
chore: remove link list block with additional fields block
piotrgulbis Dec 13, 2024
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
136 changes: 62 additions & 74 deletions demo/admin/src/App.tsx
piotrgulbis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import "@fontsource-variable/roboto-flex/full.css";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to remove this font?

import "material-design-icons/iconfont/material-icons.css";
import "typeface-open-sans";
import "@src/polyfills";

import { ApolloProvider } from "@apollo/client";
import { ErrorDialogHandler, MasterLayout, MuiThemeProvider, RouterBrowserRouter, SnackbarProvider } from "@comet/admin";
import {
BuildInformationProvider,
CmsBlockContextProvider,
ContentScopeInterface,
createDamFileDependency,
createHttpClient,
CurrentUserProvider,
Expand All @@ -19,26 +16,24 @@ import {
SitesConfigProvider,
} from "@comet/cms-admin";
import { css, Global } from "@emotion/react";
import { createApolloClient } from "@src/common/apollo/createApolloClient";
import ContentScopeProvider, { ContentScope } from "@src/common/ContentScopeProvider";
import { additionalPageTreeNodeFieldsFragment } from "@src/common/EditPageNode";
import { ConfigProvider, createConfig } from "@src/config";
import { ImportFromUnsplash } from "@src/dam/ImportFromUnsplash";
import { pageTreeCategories } from "@src/pageTree/pageTreeCategories";
import { getMessages } from "@src/lang";
import { theme } from "@src/theme";
import { HTML5toTouch } from "rdndmb-html5-to-touch";
import { Component, Fragment } from "react";
import { Fragment } from "react";
import { DndProvider } from "react-dnd-multi-backend";
import * as ReactDOM from "react-dom";
import { FormattedMessage, IntlProvider } from "react-intl";
import { Route, Switch } from "react-router-dom";
import { Route, Switch } from "react-router";

import { createApolloClient } from "./common/apollo/createApolloClient";
import { ContentScopeProvider } from "./common/ContentScopeProvider";
import { additionalPageTreeNodeFieldsFragment } from "./common/EditPageNode";
import MasterHeader from "./common/MasterHeader";
import MasterMenu, { masterMenuData, pageTreeDocumentTypes } from "./common/MasterMenu";
import { getMessages } from "./lang";
import { Link } from "./links/Link";
import { AppMasterMenu, masterMenuData, pageTreeCategories, pageTreeDocumentTypes } from "./common/MasterMenu";
import { ConfigProvider, createConfig } from "./config";
import { ImportFromUnsplash } from "./dam/ImportFromUnsplash";
import { Link } from "./documents/links/Link";
import { Page } from "./documents/pages/Page";
import { NewsDependency } from "./news/dependencies/NewsDependency";
import { Page } from "./pages/Page";

const GlobalStyle = () => (
<Global
Expand All @@ -49,34 +44,29 @@ const GlobalStyle = () => (
`}
/>
);

const config = createConfig();
const apolloClient = createApolloClient(config.apiUrl);
const apiClient = createHttpClient(config.apiUrl);

class App extends Component {
public static render(baseEl: Element): void {
ReactDOM.render(<App />, baseEl);
}

public render(): JSX.Element {
return (
<ConfigProvider config={config}>
<ApolloProvider client={apolloClient}>
export function App() {
return (
<ConfigProvider config={config}>
<ApolloProvider client={apolloClient}>
<BuildInformationProvider value={{ date: config.buildDate, number: config.buildNumber, commitHash: config.commitSha }}>
<SitesConfigProvider
value={{
configs: [...config.sitesConfig],
configs: config.sitesConfig,
resolveSiteConfigForScope: (configs, scope) => {
const siteConfig = configs.find((config) => config.scope.domain === scope.domain);
const siteConfig = configs.find((config) => {
return config.scope.domain === scope.domain;
});

if (!siteConfig) throw new Error(`siteConfig not found for domain ${scope.domain}`);
return {
url: siteConfig.url,
preloginEnabled: siteConfig.preloginEnabled || false,
blockPreviewBaseUrl:
siteConfig.scope.domain === "secondary"
? `${siteConfig.url}/block-preview`
: `${siteConfig.url}/block-preview/${scope.domain}/${scope.language}`,
sitePreviewApiUrl: `${siteConfig.url}/api/site-preview`,
blockPreviewBaseUrl: `${config.previewUrl}/block-preview/${scope.domain}/${scope.language}`,
sitePreviewApiUrl: `${config.previewUrl}/api/site-preview`,
};
},
}}
Expand Down Expand Up @@ -105,7 +95,7 @@ class App extends Component {
}}
>
<IntlProvider locale="en" messages={getMessages()}>
<LocaleProvider resolveLocaleForScope={(scope: ContentScope) => scope.domain}>
<LocaleProvider resolveLocaleForScope={(scope) => scope.domain}>
<MuiThemeProvider theme={theme}>
<ErrorDialogHandler />
<CurrentUserProvider>
Expand All @@ -124,40 +114,39 @@ class App extends Component {
pageTreeDocumentTypes={pageTreeDocumentTypes}
additionalPageTreeNodeFragment={additionalPageTreeNodeFieldsFragment}
>
<Fragment>
<GlobalStyle />
<ContentScopeProvider>
{({ match }) => (
<Switch>
{/* @TODO: add preview to contentScope once site is capable of contentScope */}
<Route
path={`${match.path}/preview`}
render={(props) => (
<SitePreview
resolvePath={(
path: string,
scope: ContentScopeInterface,
) => {
return `/${scope.language}${path}`;
}}
{...props}
/>
)}
/>
<Route
render={() => (
<MasterLayout
headerComponent={MasterHeader}
menuComponent={MasterMenu}
>
<MasterMenuRoutes menu={masterMenuData} />
</MasterLayout>
)}
/>
</Switch>
)}
</ContentScopeProvider>
</Fragment>
<ErrorDialogHandler />
<CurrentUserProvider>
<Fragment>
<GlobalStyle />
<ContentScopeProvider>
{({ match }) => (
<Switch>
<Route
path={`${match.path}/preview`}
render={(props) => (
<SitePreview
resolvePath={(path: string, scope) => {
return `/${scope.language}${path}`;
}}
{...props}
/>
)}
/>
<Route
render={() => (
<MasterLayout
headerComponent={MasterHeader}
menuComponent={AppMasterMenu}
>
<MasterMenuRoutes menu={masterMenuData} />
</MasterLayout>
)}
/>
</Switch>
)}
</ContentScopeProvider>
</Fragment>
</CurrentUserProvider>
</CmsBlockContextProvider>
</SnackbarProvider>
</DndProvider>
Expand All @@ -169,9 +158,8 @@ class App extends Component {
</DependenciesConfigProvider>
</DamConfigProvider>
</SitesConfigProvider>
</ApolloProvider>
</ConfigProvider>
);
}
</BuildInformationProvider>
</ApolloProvider>
</ConfigProvider>
);
}
export default App;
17 changes: 4 additions & 13 deletions demo/admin/src/common/ContentScopeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,21 @@ import {
useContentScopeConfig as useContentScopeConfigLibrary,
useCurrentUser,
} from "@comet/cms-admin";
import { ContentScope } from "@src/site-configs";

type Domain = "main" | "secondary" | string;
type Language = "en" | string;
export interface ContentScope {
domain: Domain;
language: Language;
}

// convenince wrapper for app (Bind Generic)
// convenience wrapper for app (Bind Generic)
export function useContentScope(): UseContentScopeApi<ContentScope> {
return useContentScopeLibrary<ContentScope>();
}

// @TODO (maybe): make factory in library to statically create Provider

export function useContentScopeConfig(p: ContentScopeConfigProps): void {
return useContentScopeConfigLibrary(p);
}

const ContentScopeProvider = ({ children }: Pick<ContentScopeProviderProps, "children">) => {
export const ContentScopeProvider = ({ children }: Pick<ContentScopeProviderProps, "children">) => {
const user = useCurrentUser();

// TODO in COMET: filter already in API, avoid type cast, support labels
const userContentScopes = user.allowedContentScopes.filter(
(value, index, self) => self.map((x) => JSON.stringify(x)).indexOf(JSON.stringify(value)) == index,
) as ContentScope[];
Expand All @@ -45,5 +38,3 @@ const ContentScopeProvider = ({ children }: Pick<ContentScopeProviderProps, "chi
</ContentScopeProviderLibrary>
);
};

export default ContentScopeProvider;
Loading