Skip to content

Commit

Permalink
Merge pull request #294 from vivid-planet/next
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyomair authored Jul 15, 2024
2 parents a1a9355 + 7d8410f commit dd81c1e
Show file tree
Hide file tree
Showing 126 changed files with 21,865 additions and 7,676 deletions.
10 changes: 2 additions & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ IMGPROXY_USE_S3=false

# dam
DAM_SECRET=6a9e8a185b513363bc89ec0b96eed8f70c759bc86b97319f60365c4b7f8593dc
DAM_CDN_ENABLED="false"
DAM_CDN_DOMAIN=
DAM_CDN_ORIGIN_HEADER=

# api
API_PORT=4000
Expand All @@ -50,18 +47,15 @@ BLOB_STORAGE_DIRECTORY_PREFIX="starter"
# admin
ADMIN_PORT=8000
ADMIN_URL=http://${DEV_DOMAIN:-localhost}:${ADMIN_PORT}
SITES_CONFIG='{"main": {"url": "$SITE_URL", "previewUrl": "$SITE_URL/preview/main", "preloginEnabled": false}, "secondary": {"url": "$SITE_URL", "previewUrl": "$SITE_URL/preview/secondary", "preloginEnabled": false}}'
PREVIEW_URL=http://${DEV_DOMAIN:-localhost}:${SITE_PORT}

# site
SITE_PORT=3000
SITE_URL=http://${DEV_DOMAIN:-localhost}:${SITE_PORT}
# no gtm in dev mode
NEXT_PUBLIC_GTM_ID=
NEXT_PUBLIC_SITE_URL=$SITE_URL
NEXT_PUBLIC_SITE_DOMAIN=main
NEXT_PUBLIC_SITE_LANGUAGES=en,de
NEXT_PUBLIC_SITE_DEFAULT_LANGUAGE=en
NEXT_PUBLIC_SITE_IS_PREVIEW=false
NEXT_PUBLIC_API_URL=$API_URL

# jaegertracing
JAEGER_UI_PORT=16686
Expand Down
3 changes: 3 additions & 0 deletions .env.site-configs.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PRIVATE_SITE_CONFIGS='{{ site://configs/private/local }}'
PUBLIC_SITE_CONFIGS='{{ site://configs/public/local }}'
NEXT_PUBLIC_SITE_CONFIGS=$PUBLIC_SITE_CONFIGS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules

.env.local
.env.secrets
.env.site-configs
2 changes: 2 additions & 0 deletions admin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.env
.env.local
.env.secrets
.env.site-configs

/node_modules

Expand All @@ -16,5 +17,6 @@ fragmentTypes.json
**/*.generated.ts
/block-meta.json
src/comet-config.json
src/site-configs.d.ts

.swc/
4,082 changes: 2,435 additions & 1,647 deletions admin/package-lock.json

Large diffs are not rendered by default.

30 changes: 13 additions & 17 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"scripts": {
"postinstall": "cd server && npm install",
"serve": "cd server && npm run serve",
"start": "npm run intl:compile && run-p gql:types generate-block-types && dotenv -c secrets -- vite",
"build": "npm run intl:compile && run-p gql:types generate-block-types && NODE_ENV=production dotenv -c secrets -- vite build",
"start": "npm run intl:compile && run-p gql:types generate-block-types && dotenv -e .env.secrets -e .env.site-configs -- vite",
"build": "npm run intl:compile && run-p gql:types generate-block-types && NODE_ENV=production vite build",
"preview": "npm run build && vite preview",
"gql:types": "graphql-codegen",
"gql:watch": "graphql-codegen --watch",
Expand All @@ -22,36 +22,32 @@
"intl:compile": "run-p intl:compile:starter-admin intl:compile:comet",
"generate-block-types": "comet generate-block-types --inputs",
"generate-block-types:watch": "chokidar -s \"**/block-meta.json\" -c \"npm run generate-block-types\"",
"admin-generator": "rimraf 'src/*/generated' && comet-admin-generator generate crud-generator-config.ts"
"admin-generator": "rimraf 'src/*/generated' && comet-admin-generator generate crud-generator-config.ts && comet-admin-generator future-generate"
},
"dependencies": {
"@apollo/client": "^3.2.5",
"@comet/admin": "^6.14.1",
"@comet/admin-icons": "^6.14.1",
"@comet/admin-rte": "^6.14.1",
"@comet/admin-theme": "^6.14.1",
"@comet/blocks-admin": "^6.14.1",
"@comet/cms-admin": "^6.14.1",
"@comet/admin": "7.0.0-beta.4",
"@comet/admin-date-time": "7.0.0-beta.4",
"@comet/admin-icons": "7.0.0-beta.4",
"@comet/admin-rte": "7.0.0-beta.4",
"@comet/admin-theme": "7.0.0-beta.4",
"@comet/blocks-admin": "7.0.0-beta.4",
"@comet/cms-admin": "7.0.0-beta.4",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@fontsource/roboto": "^4.5.8",
"@mui/lab": "^5.0.0-alpha.88",
"@mui/material": "^5.8.6",
"@mui/styles": "^5.8.6",
"@mui/system": "^5.8.6",
"@mui/x-data-grid": "^5.17.26",
"@mui/x-data-grid-pro": "^5.17.26",
"axios": "^0.21.0",
"change-case": "^5.3.0",
"date-fns": "^2.28.0",
"exceljs": "^3.4.0",
"file-saver": "^2.0.2",
"final-form": "^4.16.1",
"graphql": "^15.4.0",
"graphql-anywhere": "^4.2.8",
"history": "^4.10.0",
"lodash.isequal": "^4.0.0",
"material-design-icons": "^3.0.1",
"rdndmb-html5-to-touch": "^8.0.3",
"react": "^17.0.0",
"react-app-polyfill": "^2.0.0",
Expand All @@ -65,8 +61,9 @@
"react-router-dom": "^5.1.2"
},
"devDependencies": {
"@comet/cli": "^6.14.1",
"@comet/eslint-config": "^6.14.1",
"@comet/cli": "7.0.0-beta.4",
"@comet/eslint-config": "7.0.0-beta.4",
"@comet/eslint-plugin": "7.0.0-beta.4",
"@formatjs/cli": "^6.0.0",
"@graphql-codegen/add": "^3.0.0",
"@graphql-codegen/cli": "^2.0.0",
Expand All @@ -77,7 +74,6 @@
"@graphql-codegen/typescript": "^2.0.0",
"@graphql-codegen/typescript-operations": "^2.0.0",
"@swc/plugin-emotion": "^2.5.121",
"@types/lodash.isequal": "^4.0.0",
"@types/node": "^20.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
Expand Down
100 changes: 50 additions & 50 deletions admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "@fontsource/roboto/300.css";
import "@fontsource/roboto/400.css";
import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";
import "material-design-icons/iconfont/material-icons.css";
import "@src/polyfills";

import { ApolloProvider } from "@apollo/client";
Expand All @@ -17,12 +16,10 @@ import {
LocaleProvider,
MasterMenu,
MasterMenuRoutes,
SiteConfig,
SitePreview,
SitesConfigProvider,
} from "@comet/cms-admin";
import { css, Global } from "@emotion/react";
import { ContentScope } from "@src/common/ContentScopeProvider";
import { getMessages } from "@src/lang";
import { theme } from "@src/theme";
import { HTML5toTouch } from "rdndmb-html5-to-touch";
Expand All @@ -34,7 +31,7 @@ import { createApolloClient } from "./common/apollo/createApolloClient";
import { ContentScopeProvider } from "./common/ContentScopeProvider";
import { MasterHeader } from "./common/MasterHeader";
import { masterMenuData, pageTreeCategories, pageTreeDocumentTypes } from "./common/masterMenuData";
import { ConfigProvider, createConfig } from "./config";
import { ConfigProvider, ContentScope, createConfig } from "./config";
import { Link } from "./documents/links/Link";
import { Page } from "./documents/pages/Page";

Expand All @@ -55,43 +52,47 @@ export function App() {
return (
<ConfigProvider config={config}>
<ApolloProvider client={apolloClient}>
<CurrentUserProvider>
<BuildInformationProvider value={{ date: config.buildDate, number: config.buildNumber, commitHash: config.commitSha }}>
<SitesConfigProvider
value={{
configs: config.sitesConfig,
resolveSiteConfigForScope: (configs: Record<string, SiteConfig>, scope: ContentScope) => {
const siteConfig = configs[scope.domain];
return {
...siteConfig,
previewUrl: `${siteConfig.previewUrl}/${scope.language}`,
};
},
<BuildInformationProvider value={{ date: config.buildDate, number: config.buildNumber, commitHash: config.commitSha }}>
<SitesConfigProvider
value={{
configs: config.sitesConfig,
resolveSiteConfigForScope: (configs, scope: ContentScope) => {
const siteConfig = configs.find((config) => config.contentScope.domain === scope.domain);
if (!siteConfig) throw new Error(`siteConfig not found for domain ${scope.domain}`);
return {
url: siteConfig.url,
preloginEnabled: siteConfig.preloginEnabled || false,
blockPreviewBaseUrl: `${config.previewUrl}/block-preview`,
sitePreviewApiUrl: `${config.previewUrl}/api/site-preview`,
};
},
}}
>
<DependenciesConfigProvider
entityDependencyMap={{
Page,
Link,
DamFile: createDamFileDependency(),
}}
>
<DependenciesConfigProvider
entityDependencyMap={{
Page,
Link,
DamFile: createDamFileDependency(),
}}
>
<IntlProvider locale="en" messages={getMessages()}>
<LocaleProvider resolveLocaleForScope={(scope: ContentScope) => scope.domain}>
<MuiThemeProvider theme={theme}>
<DndProvider options={HTML5toTouch}>
<SnackbarProvider>
<CmsBlockContextProvider
damConfig={{
apiUrl: config.apiUrl,
apiClient,
maxFileSize: config.dam.uploadsMaxFileSize,
maxSrcResolution: config.imgproxy.maxSrcResolution,
allowedImageAspectRatios: config.dam.allowedImageAspectRatios,
}}
pageTreeCategories={pageTreeCategories}
pageTreeDocumentTypes={pageTreeDocumentTypes}
>
<IntlProvider locale="en" messages={getMessages()}>
<LocaleProvider resolveLocaleForScope={(scope: ContentScope) => scope.domain}>
<MuiThemeProvider theme={theme}>
<DndProvider options={HTML5toTouch}>
<SnackbarProvider>
<CmsBlockContextProvider
damConfig={{
apiUrl: config.apiUrl,
apiClient,
maxFileSize: config.dam.uploadsMaxFileSize,
maxSrcResolution: config.imgproxy.maxSrcResolution,
allowedImageAspectRatios: config.dam.allowedImageAspectRatios,
}}
pageTreeCategories={pageTreeCategories}
pageTreeDocumentTypes={pageTreeDocumentTypes}
>
<ErrorDialogHandler />
<CurrentUserProvider>
<RouterBrowserRouter>
<GlobalStyle />
<ContentScopeProvider>
Expand All @@ -114,18 +115,17 @@ export function App() {
</Switch>
)}
</ContentScopeProvider>
<ErrorDialogHandler />
</RouterBrowserRouter>
</CmsBlockContextProvider>
</SnackbarProvider>
</DndProvider>
</MuiThemeProvider>
</LocaleProvider>
</IntlProvider>
</DependenciesConfigProvider>
</SitesConfigProvider>
</BuildInformationProvider>
</CurrentUserProvider>
</CurrentUserProvider>
</CmsBlockContextProvider>
</SnackbarProvider>
</DndProvider>
</MuiThemeProvider>
</LocaleProvider>
</IntlProvider>
</DependenciesConfigProvider>
</SitesConfigProvider>
</BuildInformationProvider>
</ApolloProvider>
</ConfigProvider>
);
Expand Down
49 changes: 9 additions & 40 deletions admin/src/common/ContentScopeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,67 +1,36 @@
import { Domain as DomainIcon, Language as LanguageIcon } from "@comet/admin-icons";
import {
ContentScopeConfigProps,
ContentScopeControls as ContentScopeControlsLibrary,
ContentScopeControlsConfig,
ContentScopeProvider as ContentScopeProviderLibrary,
ContentScopeProviderProps,
ContentScopeValues,
useContentScope as useContentScopeLibrary,
UseContentScopeApi,
useContentScopeConfig as useContentScopeConfigLibrary,
useCurrentUser,
useSitesConfig,
} from "@comet/cms-admin";
import { SitesConfig } from "@src/config";

type Domain = "main" | "secondary" | string;
type Language = "en" | string;
export interface ContentScope {
domain: Domain;
language: Language;
}
import { ContentScope } from "@src/config";

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

const controlsConfig: ContentScopeControlsConfig<ContentScope> = {
domain: {
label: "Domain",
icon: DomainIcon,
},
language: {
label: "Language",
icon: LanguageIcon,
},
};

// convenince wrapper for app (Bind config and Generic)
export function ContentScopeControls() {
return <ContentScopeControlsLibrary<ContentScope> config={controlsConfig} />;
}

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

export const ContentScopeProvider: React.FC<Pick<ContentScopeProviderProps, "children">> = ({ children }) => {
const sitesConfig = useSitesConfig<SitesConfig>();
const user = useCurrentUser();

const allowedUserDomains = user.allowedContentScopes.map((contentScope) => contentScope.domain);
// 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[];

const allowedSiteConfigs = Object.fromEntries(
Object.entries(sitesConfig.configs).filter(([siteKey, _siteConfig]) => allowedUserDomains.includes(siteKey)),
);
const values: ContentScopeValues<ContentScope> = {
domain: Object.keys(allowedSiteConfigs).map((key) => ({ value: key })),
language: [
{ label: "English", value: "en" },
{ label: "German", value: "de" },
],
};
const values: ContentScopeValues<ContentScope> = userContentScopes.map((contentScope) => ({
domain: { value: contentScope.domain },
language: { value: contentScope.language, label: contentScope.language.toUpperCase() },
}));

return (
<ContentScopeProviderLibrary<ContentScope> values={values} defaultValue={{ domain: "main", language: "en" }}>
Expand Down
4 changes: 1 addition & 3 deletions admin/src/common/MasterHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { BuildEntry, Header, UserHeaderItem } from "@comet/cms-admin";

import { ContentScopeControls } from "./ContentScopeProvider";
import { BuildEntry, ContentScopeControls, Header, UserHeaderItem } from "@comet/cms-admin";

export function MasterHeader() {
return (
Expand Down
12 changes: 12 additions & 0 deletions admin/src/common/blocks/MediaBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BlockCategory, BlockInterface, createOneOfBlock } from "@comet/blocks-admin";
import { DamImageBlock, DamVideoBlock, YouTubeVideoBlock } from "@comet/cms-admin";
import { FormattedMessage } from "react-intl";

export const MediaBlock: BlockInterface = createOneOfBlock({
supportedBlocks: { image: DamImageBlock, damVideo: DamVideoBlock, youTubeVideo: YouTubeVideoBlock },
name: "Media",
displayName: <FormattedMessage id="mediaBlock.displayName" defaultMessage="Media" />,
allowEmpty: false,
variant: "toggle",
category: BlockCategory.Media,
});
Loading

0 comments on commit dd81c1e

Please sign in to comment.