Removed recorders bio + other fixes

This commit is contained in:
DrMint 2024-04-05 07:41:42 +02:00
parent 609bbe5866
commit a62709e66e
9 changed files with 19 additions and 91 deletions

View File

@ -695,8 +695,10 @@ export const Collectibles = buildVersionedCollectionConfig({
labels: { singular: "Other", plural: "Others" },
fields: [
translatedFields({
admin: { className: "no-label" },
name: "translations",
admin: { className: "no-label" },
required: true,
minRows: 1,
fields: [
{
name: "note",

View File

@ -5,9 +5,7 @@ import { QuickFilters } from "../../components/QuickFilters";
import { CollectionGroups, Collections, RecordersRoles } from "../../constants";
import { imageField } from "../../fields/imageField/imageField";
import { rowField } from "../../fields/rowField/rowField";
import { translatedFields } from "../../fields/translatedFields/translatedFields";
import { buildCollectionConfig } from "../../utils/collectionConfig";
import { createEditor } from "../../utils/editor";
import { getAllEndpoint } from "./endpoints/getAllEndpoint";
import { importFromStrapi } from "./endpoints/importFromStrapi";
import { beforeLoginMustHaveAtLeastOneRole } from "./hooks/beforeLoginMustHaveAtLeastOneRole";
@ -102,23 +100,6 @@ export const Recorders = buildCollectionConfig({
description: "List of language(s) that this recorder is familiar with",
},
},
translatedFields({
name: fields.biographies,
interfaceName: "RecorderBiographies",
admin: {
// TODO: Reenable when we can use rich text as titles useAsTitle: fields.biography,
description:
"A short personal description about you or your involvement with this project or the franchise",
},
fields: [
{
name: fields.biography,
required: true,
type: "richText",
editor: createEditor({ inlines: true, lists: true, links: true }),
},
],
}),
{
name: fields.role,
type: "select",

View File

@ -2,7 +2,7 @@ import payload from "payload";
import { Collections } from "../../../constants";
import { EndpointRecorder } from "../../../sdk";
import { CollectionEndpoint } from "../../../types/payload";
import { isPayloadArrayType, isPayloadType, isValidPayloadImage } from "../../../utils/asserts";
import { isPayloadArrayType, isValidPayloadImage } from "../../../utils/asserts";
export const getAllEndpoint: CollectionEndpoint = {
method: "get",
@ -27,16 +27,11 @@ export const getAllEndpoint: CollectionEndpoint = {
).docs;
const result: EndpointRecorder[] = recorders.map(
({ anonymize, id, username, avatar, biographies, languages }) => ({
({ anonymize, id, username, avatar, languages }) => ({
id,
username: anonymize ? `Recorder#${id.substring(0, 5)}` : username,
...(isValidPayloadImage(avatar) ? { avatar } : {}),
languages: isPayloadArrayType(languages) ? languages.map(({ id }) => id) : [],
biographies:
biographies?.map(({ biography, language }) => ({
language: isPayloadType(language) ? language.id : language,
biography,
})) ?? [],
})
);

View File

@ -3,9 +3,8 @@ import { Collections } from "../../../constants";
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
import { Recorder } from "../../../types/collections";
import { StrapiImage, StrapiLanguage } from "../../../types/strapi";
import { isDefined, isUndefined } from "../../../utils/asserts";
import { isDefined } from "../../../utils/asserts";
import { uploadStrapiImage } from "../../../utils/localApi";
import { plainTextToLexical } from "../../../utils/string";
type StrapiRecorder = {
username: string;
@ -25,7 +24,7 @@ export const importFromStrapi = createStrapiImportEndpoint<StrapiRecorder>({
},
payload: {
collection: Collections.Recorders,
import: async ({ username, anonymize, anonymous_code, languages, avatar, bio: bios }, user) => {
import: async ({ username, anonymize, anonymous_code, languages, avatar }, user) => {
const avatarId = await uploadStrapiImage({
collection: Collections.Images,
image: avatar,
@ -58,15 +57,6 @@ export const importFromStrapi = createStrapiImportEndpoint<StrapiRecorder>({
anonymize,
languages: languages.data?.map((language) => language.attributes.code),
avatar: avatarId,
biographies: bios?.map(({ language, bio }) => {
if (isUndefined(language.data))
throw new Error("A language is required for a Recorder biography");
if (isUndefined(bio)) throw new Error("A bio is required for a Recorder biography");
return {
language: language.data.attributes.code,
biography: plainTextToLexical(bio),
};
}),
email: `${anonymous_code}@accords-library.com`,
password: process.env.RECORDER_DEFAULT_PASSWORD,
},

View File

@ -14,6 +14,7 @@ export const slugField = ({ admin, ...otherProps }: Props): TextField => ({
type: "text",
required: true,
unique: true,
index: true,
validate: validateSlug,
admin: {
description:

View File

@ -17,6 +17,8 @@ import { Recorders } from "./collections/Recorders/Recorders";
import { Tags } from "./collections/Tags/Tags";
import { TagsGroups } from "./collections/TagsGroups/TagsGroups";
import { Videos } from "./collections/Videos/Videos";
import { VideosChannels } from "./collections/VideosChannels/VideosChannels";
import { VideosSubtitles } from "./collections/VideosSubtitles/VideosSubtitles";
import { Wordings } from "./collections/Wordings/Wordings";
import { Icon } from "./components/Icon";
import { Logo } from "./components/Logo";
@ -24,13 +26,6 @@ import { Collections } from "./constants";
import { ftpAdapter } from "./plugins/ftpAdapter";
import { createEditor } from "./utils/editor";
if (!process.env.PAYLOAD_URI) throw new Error("Missing PAYLOAD_URI in .env");
if (!process.env.MONGODB_URI) throw new Error("Missing MONGODB_URI in .env");
if (!process.env.FTP_HOST) throw new Error("Missing FTP_HOST in .env");
if (!process.env.FTP_USER) throw new Error("Missing FTP_USER in .env");
if (!process.env.FTP_PASSWORD) throw new Error("Missing FTP_PASSWORD in .env");
if (!process.env.FTP_BASE_URL) throw new Error("Missing FTP_BASE_URL in .env");
export default buildConfig({
serverURL: process.env.PAYLOAD_URI,
admin: {
@ -54,6 +49,8 @@ export default buildConfig({
Images,
Videos,
VideosSubtitles,
VideosChannels,
Tags,
TagsGroups,
@ -64,7 +61,7 @@ export default buildConfig({
GenericContents,
],
db: mongooseAdapter({
url: process.env.MONGODB_URI,
url: process.env.MONGODB_URI ?? "",
}),
globals: [HomeFolders],
telemetry: false,
@ -79,11 +76,11 @@ export default buildConfig({
collections: {
[Collections.Videos]: {
adapter: ftpAdapter({
host: process.env.FTP_HOST,
user: process.env.FTP_USER,
password: process.env.FTP_PASSWORD,
host: process.env.FTP_HOST ?? "",
user: process.env.FTP_USER ?? "",
password: process.env.FTP_PASSWORD ?? "",
secure: false,
endpoint: process.env.FTP_BASE_URL,
endpoint: process.env.FTP_BASE_URL ?? "",
}),
disableLocalStorage: true,
disablePayloadAccessControl: true,

View File

@ -139,10 +139,6 @@ export type EndpointRecorder = {
username: string;
avatar?: PayloadImage;
languages: string[];
biographies: {
language: string;
biography: RichTextContent;
}[];
};
export type EndpointWording = {

View File

@ -6,31 +6,6 @@
* and re-run `payload generate:types` to regenerate this file.
*/
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "RecorderBiographies".
*/
export type RecorderBiographies =
| {
language: string | Language;
biography: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ("ltr" | "rtl") | null;
format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
indent: number;
version: number;
};
[k: string]: unknown;
};
id?: string | null;
}[]
| null;
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "CategoryTranslations".
@ -207,7 +182,6 @@ export interface Recorder {
username: string;
avatar?: string | Image | null;
languages?: (string | Language)[] | null;
biographies?: RecorderBiographies;
role?: ("Admin" | "Recorder" | "Api")[] | null;
anonymize: boolean;
email: string;
@ -426,8 +400,7 @@ export interface Collectible {
blockType: "timeRange";
}
| {
translations?:
| {
translations: {
language: string | Language;
note: {
root: {
@ -445,8 +418,7 @@ export interface Collectible {
[k: string]: unknown;
};
id?: string | null;
}[]
| null;
}[];
id?: string | null;
blockName?: string | null;
blockType: "other";

View File

@ -76,18 +76,12 @@ export const handleParentPages = ({
export const handleRecorder = ({
id,
biographies,
languages,
username,
avatar,
anonymize,
}: Recorder): EndpointRecorder => ({
id,
biographies:
biographies?.map(({ biography, language }) => ({
biography,
language: isPayloadType(language) ? language.id : language,
})) ?? [],
languages: languages?.map((language) => (isPayloadType(language) ? language.id : language)) ?? [],
username: anonymize ? `Recorder#${id.substring(0, 5)}` : username,
...(isValidPayloadImage(avatar) ? { avatar } : {}),