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

Page Builder Translations #4269

Merged
merged 29 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cb56b3a
WIP: PB translations
Pavel910 Jul 2, 2024
cabef39
wip: translations API
Pavel910 Aug 20, 2024
01b49fa
wip: translations API
Pavel910 Aug 20, 2024
d34a647
Merge branch 'refs/heads/next' into pavel/r&d/pb-translations
Pavel910 Aug 20, 2024
077e96a
wip: translations API
Pavel910 Aug 21, 2024
d48f2a8
wip: translations GraphQL API
Pavel910 Sep 3, 2024
ac9a5ef
fix(react-router): remove custom router context
Pavel910 Sep 14, 2024
fb02a23
fix(lexical-theme): change link color to Webiny primary color
Pavel910 Sep 14, 2024
4227fa4
fix(lexical-editor-pb-element): support placeholder and children prop
Pavel910 Sep 14, 2024
c68e889
fix(lexical-editor): increase z-index on floating toolbar
Pavel910 Sep 14, 2024
f8520f3
fix(lexical-editor): ensure heading editor always has a heading node
Pavel910 Sep 14, 2024
b0cda7d
feat(lexical-editor): make initial value generation configurable
Pavel910 Sep 14, 2024
8b1ae25
fix(cli-plugin-deploy-pulumi): exclude lambda@edge functions from watch
Pavel910 Sep 14, 2024
cf017d8
feat(app-website): move data preloading to a decoratable react component
Pavel910 Sep 14, 2024
3112d77
chore(cwp-template-aws): remove old linkPreload plugin from template
Pavel910 Sep 14, 2024
c764f63
feat(app-page-builder-elements): add support for element inputs
Pavel910 Sep 14, 2024
8b11fe8
feat(app-page-builder): add translations features
Pavel910 Sep 14, 2024
53d4601
fix(app-admin): move createGenericContext to app package
Pavel910 Sep 14, 2024
70c249d
feat(api-page-builder): add basic translations features
Pavel910 Sep 14, 2024
5d15934
feat(api-headless-cms): improve input types
Pavel910 Sep 14, 2024
2992a76
chore: remove obsolete plugins from website app
Pavel910 Sep 14, 2024
eca5bc9
chore: restore admin app entry point
Pavel910 Sep 14, 2024
0b341f5
chore: dependency cleanup and eslint fixes
Pavel910 Sep 14, 2024
d311fa3
fix(api-page-builder): rename PbCreatedBy to PbIdentity
Pavel910 Sep 14, 2024
9e5a1d1
Merge branch 'refs/heads/pavel/r&d/pb-translations' into pavel/feat/p…
Pavel910 Sep 14, 2024
48f6af7
fix(app-page-builder): improve types for TS 4.9.5
Pavel910 Sep 14, 2024
d87f3e3
fix(react-composition): improve types for TS 4.9.5
Pavel910 Sep 14, 2024
bbaec4d
fix(app-page-builder): move page unlinking to the client side
Pavel910 Sep 15, 2024
9ecdcb1
Merge branch 'refs/heads/next' into pavel/feat/pb-translations
Pavel910 Oct 1, 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
2 changes: 0 additions & 2 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
"@webiny/cli": "0.0.0",
"@webiny/plugins": "0.0.0",
"@webiny/project-utils": "0.0.0",
"@webiny/react-router": "0.0.0",
"@webiny/serverless-cms-aws": "0.0.0",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"core-js": "^3.0.1",
"cross-fetch": "^3.0.4",
"graphql": "^15.7.2",
"graphql-tag": "^2.12.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"regenerator-runtime": "^0.13.5",
Expand Down
59 changes: 0 additions & 59 deletions apps/website/src/plugins/linkPreload.ts

This file was deleted.

2 changes: 0 additions & 2 deletions apps/website/src/plugins/pageBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Plugins specific to the "website" app.
*/
import linkPreload from "./linkPreload";

/**
* Ensures GraphQL's PbPage and PbPageListItem types are correctly cached.
Expand Down Expand Up @@ -66,7 +65,6 @@ import accordionItemSettings from "@webiny/app-page-builder/editor/plugins/eleme
import responsiveMode from "@webiny/app-page-builder/render/plugins/responsiveMode";

export default [
linkPreload(),
apolloCacheObjectId,

// Page elements
Expand Down
3 changes: 2 additions & 1 deletion packages/api-headless-cms-ddb-es/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from "~/plugins";
import { createFilterPlugins } from "~/operations/entry/elasticsearch/filtering/plugins";
import { CmsEntryFilterPlugin } from "~/plugins/CmsEntryFilterPlugin";
import { StorageOperationsCmsModelPlugin } from "@webiny/api-headless-cms";
import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";
import { createElasticsearchIndexesOnLocaleAfterCreate } from "~/operations/system/indexes";
import { createIndexTaskPluginTest } from "~/tasks/createIndexTaskPlugin";

Expand Down Expand Up @@ -157,6 +157,7 @@ export const createStorageOperations: StorageOperationsFactory = params => {
CmsEntryElasticsearchSortModifierPlugin.type,
CmsElasticsearchModelFieldPlugin.type,
StorageOperationsCmsModelPlugin.type,
StorageTransformPlugin.type,
CmsEntryElasticsearchValuesModifier.type
];
for (const type of types) {
Expand Down
5 changes: 3 additions & 2 deletions packages/api-headless-cms-ddb/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
CmsFieldFilterValueTransformPlugin
} from "~/plugins";
import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
import { StorageOperationsCmsModelPlugin } from "@webiny/api-headless-cms";
import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";

export * from "./plugins";

Expand Down Expand Up @@ -89,7 +89,8 @@ export const createStorageOperations: StorageOperationsFactory = params => {
CmsEntryFieldFilterPlugin.type,
CmsEntryFieldSortingPlugin.type,
ValueFilterPlugin.type,
StorageOperationsCmsModelPlugin.type
StorageOperationsCmsModelPlugin.type,
StorageTransformPlugin.type
];
/**
* Collect all required plugins from parent context.
Expand Down
15 changes: 8 additions & 7 deletions packages/api-headless-cms-ddb/src/operations/entry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,17 @@ export const createEntriesStorageOperations = (
entity
});

const storageTransformPlugins = plugins
.byType<StorageTransformPlugin>(StorageTransformPlugin.type)
.reduce((collection, plugin) => {
collection[plugin.fieldType] = plugin;
return collection;
}, {} as Record<string, StorageTransformPlugin>);

const createStorageTransformCallable = (
model: StorageOperationsCmsModel
): FilterItemFromStorage => {
// Cache StorageTransformPlugin to optimize execution.
const storageTransformPlugins = plugins
.byType<StorageTransformPlugin>(StorageTransformPlugin.type)
.reduce((collection, plugin) => {
collection[plugin.fieldType] = plugin;
return collection;
}, {} as Record<string, StorageTransformPlugin>);

return (field, value) => {
const plugin: StorageTransformPlugin = storageTransformPlugins[field.type];
if (!plugin) {
Expand Down
24 changes: 19 additions & 5 deletions packages/api-headless-cms/src/crud/contentEntry.crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import {
CmsContext,
CmsEntry,
CmsEntryContext,
CmsEntryGetParams,
CmsEntryListParams,
CmsEntryListWhere,
CmsEntryMeta,
CmsEntryValues,
CmsModel,
CmsStorageEntry,
CreateCmsEntryInput,
CreateCmsEntryOptionsInput,
EntryBeforeListTopicParams,
HeadlessCmsStorageOperations,
OnEntryAfterCreateTopicParams,
Expand Down Expand Up @@ -378,7 +381,11 @@ export const createContentEntryCrud = (params: CreateContentEntryCrudParams): Cm
}
return entry;
};
const createEntry: CmsEntryContext["createEntry"] = async (model, rawInput, options) => {
const createEntry: CmsEntryContext["createEntry"] = async <T = CmsEntryValues>(
model: CmsModel,
rawInput: CreateCmsEntryInput,
options?: CreateCmsEntryOptionsInput
): Promise<CmsEntry<T>> => {
await accessControl.ensureCanAccessEntry({ model, rwd: "w" });

const { entry, input } = await createEntryData({
Expand Down Expand Up @@ -416,7 +423,7 @@ export const createContentEntryCrud = (params: CreateContentEntryCrudParams): Cm
input
});

return entry;
return entry as CmsEntry<T>;
} catch (ex) {
await onEntryCreateError.publish({
error: ex,
Expand Down Expand Up @@ -1304,9 +1311,12 @@ export const createContentEntryCrud = (params: CreateContentEntryCrudParams): Cm
/**
* @internal
*/
async getEntry(model, params) {
async getEntry<T = CmsEntryValues>(
model: CmsModel,
params: CmsEntryGetParams
): Promise<CmsEntry<T>> {
return context.benchmark.measure("headlessCms.crud.entries.getEntry", async () => {
return await getEntryUseCase.execute(model, params);
return (await getEntryUseCase.execute(model, params)) as CmsEntry<T>;
});
},
/**
Expand Down Expand Up @@ -1355,7 +1365,11 @@ export const createContentEntryCrud = (params: CreateContentEntryCrudParams): Cm
}
);
},
async createEntry(model, input, options) {
async createEntry<T extends CmsEntryValues = CmsEntryValues>(
model: CmsModel,
input: CreateCmsEntryInput<T>,
options?: CreateCmsEntryOptionsInput
): Promise<CmsEntry<T>> {
return context.benchmark.measure("headlessCms.crud.entries.createEntry", async () => {
return createEntry(model, input, options);
});
Expand Down
15 changes: 9 additions & 6 deletions packages/api-headless-cms/src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export interface CmsEntryContext {
/**
* Get a single content entry for a model.
*/
getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry>;
getEntry: <T = CmsEntryValues>(
model: CmsModel,
params: CmsEntryGetParams
) => Promise<CmsEntry<T>>;
/**
* Get a list of entries for a model by a given ID (revision).
*/
Expand Down Expand Up @@ -115,11 +118,11 @@ export interface CmsEntryContext {
/**
* Create a new content entry.
*/
createEntry: (
createEntry: <T extends CmsEntryValues = CmsEntryValues>(
model: CmsModel,
input: CreateCmsEntryInput,
input: CreateCmsEntryInput<T>,
options?: CreateCmsEntryOptionsInput
) => Promise<CmsEntry>;
) => Promise<CmsEntry<T>>;
/**
* Create a new entry from already existing entry.
*/
Expand All @@ -132,10 +135,10 @@ export interface CmsEntryContext {
/**
* Update existing entry.
*/
updateEntry: (
updateEntry: <TInput = CmsEntryValues>(
model: CmsModel,
id: string,
input: UpdateCmsEntryInput,
input: UpdateCmsEntryInput<TInput>,
meta?: Record<string, any>,
options?: UpdateCmsEntryOptionsInput
) => Promise<CmsEntry>;
Expand Down
12 changes: 4 additions & 8 deletions packages/api-headless-cms/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ export interface EntryBeforeListTopicParams {
* @category Context
* @category CmsEntry
*/
export interface CreateCmsEntryInput {
export type CreateCmsEntryInput<TValues = CmsEntryValues> = TValues & {
id?: string;
status?: CmsEntryStatus;

Expand Down Expand Up @@ -1447,9 +1447,7 @@ export interface CreateCmsEntryInput {
wbyAco_location?: {
folderId?: string | null;
};

[key: string]: any;
}
};

export interface CreateCmsEntryOptionsInput {
skipValidators?: string[];
Expand Down Expand Up @@ -1499,7 +1497,7 @@ export interface CreateRevisionCmsEntryOptionsInput {
* @category Context
* @category CmsEntry
*/
export interface UpdateCmsEntryInput {
export type UpdateCmsEntryInput<TValues = CmsEntryValues> = TValues & {
/**
* Revision-level meta fields. 👇
*/
Expand Down Expand Up @@ -1539,9 +1537,7 @@ export interface UpdateCmsEntryInput {
wbyAco_location?: {
folderId?: string | null;
};

[key: string]: any;
}
};

export interface UpdateCmsEntryOptionsInput {
skipValidators?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const plugin: GraphQLSchemaPlugin<PbImportExportContext> = {
type PbImportExportTask {
id: ID
createdOn: DateTime
createdBy: PbCreatedBy
createdBy: PbIdentity
status: PbImportExportTaskStatus
data: JSON
stats: PbImportExportTaskStats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const plugin: GraphQLSchemaPlugin<PbImportExportContext> = {
type PbExportPagesTask {
id: ID!
createdOn: DateTime!
createdBy: PbCreatedBy!
createdBy: PbIdentity!
status: PbImportExportPagesTaskStatus!
data: PbExportPagesTaskData!
stats: PbImportExportPagesTaskStats!
Expand All @@ -54,7 +54,7 @@ const plugin: GraphQLSchemaPlugin<PbImportExportContext> = {
type PbImportPagesTask {
id: ID!
createdOn: DateTime!
createdBy: PbCreatedBy!
createdBy: PbIdentity!
status: PbImportExportPagesTaskStatus!
stats: PbImportExportPagesTaskStats!
data: PbImportExportPagesTaskData!
Expand Down
Loading
Loading