Skip to content

Commit

Permalink
feat: page builder translations #4269
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 authored Oct 1, 2024
2 parents 4f7dd91 + 9ecdcb1 commit 91b712f
Show file tree
Hide file tree
Showing 240 changed files with 4,423 additions and 2,232 deletions.
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

0 comments on commit 91b712f

Please sign in to comment.