Enhance grid import/export functionality to support dynamic groups and collections
ci / build-backend (push) Successful in 1m43s
ci / build-frontend (push) Successful in 58s
ci / tests (push) Successful in 4m14s
ci / sonar (push) Successful in 4m38s

Updated the grid import/export process to allow for the inclusion of groups and collections directly from the configuration file. This enhancement ensures that missing groups and collections are created during import, improving the flexibility of the grid management system. Adjusted related classes and methods to accommodate these changes, ensuring a cohesive integration. Enhanced documentation and user prompts to clarify the new functionality and its usage.
This commit is contained in:
Leonid Pershin
2026-07-28 02:23:43 +03:00
parent f7e7b5f7c3
commit fe11034b16
14 changed files with 539 additions and 28 deletions
@@ -90,6 +90,15 @@ export function GridTransferDialog({
skipped: result.skipped,
}),
)
// Заведённые группы упоминаем отдельно: файл от модели меняет не только сетку, и узнать
// об этом из общего «создано слотов» нельзя.
if (result.groups > 0 || result.collections > 0)
toast.success(
t('admin.channels.transfer.importedLibrary', {
groups: result.groups,
collections: result.collections,
}),
)
onImported()
},
onError: (error: unknown) => {
+19
View File
@@ -827,6 +827,21 @@ export type GridConfigLayer = {
applicability?: LayerApplicability | null
}
/** Коллекция в формате обмена: цикл или франшиза из шоу по названиям. */
export type GridConfigCollection = {
name: string
shows: string[]
description?: string | null
}
/** Группа в формате обмена: шоу и коллекции по названиям — импорт заводит недостающие. */
export type GridConfigGroup = {
name: string
shows?: string[] | null
collections?: string[] | null
description?: string | null
}
export type GridConfig = {
format: string
version: number
@@ -834,6 +849,8 @@ export type GridConfig = {
rules?: PlanningRules | null
fallbackGroup?: string | null
defaultJunction?: string | null
collections?: GridConfigCollection[] | null
groups?: GridConfigGroup[] | null
layers: GridConfigLayer[]
}
@@ -843,6 +860,8 @@ export type GridImportResultDto = {
slots: number
skipped: number
removed: number
groups: number
collections: number
warnings: string[]
}
+3 -2
View File
@@ -439,16 +439,17 @@ export const en = {
exportAction: 'Download file',
exported: 'File exported',
importHint:
'Load a file or paste JSON — a model answer, for example. Unknown references do not break the import: such slots are skipped and listed below.',
'Load a file or paste JSON — a model answer, for example. The file may bring missing groups and collections with it; shows are never created — those come from media uploads. Unknown references do not break the import: such slots are skipped and listed below.',
pickFile: 'Pick a file',
replace: 'Remove existing slots',
pastePlaceholder: 'Paste the grid configuration JSON',
importAction: 'Import',
imported: 'Slots created: {{slots}}, skipped: {{skipped}}',
importedLibrary: 'Groups created: {{groups}}, collections: {{collections}}',
badJson: 'That does not look like JSON — check that the whole answer was copied.',
warnings: 'What could not be resolved',
aiHint:
'We build the request: channel settings, your groups and library, your references and notes, plus the answer schema. The model returns JSON that loads on the import tab.',
'We build the request: channel settings, your groups and library, your references and notes, plus the answer schema. The model may define the groups it needs the import creates them.',
references: 'Reference channels',
referencesPlaceholder: 'Cartoon Network, Paramount Comedy',
referencesHint:
+3 -2
View File
@@ -440,16 +440,17 @@ export const ru = {
exportAction: 'Скачать файл',
exported: 'Файл выгружен',
importHint:
'Загрузите файл или вставьте JSON — например ответ модели. Незнакомые ссылки не валят импорт: такие слоты пропускаются, и вы увидите их списком.',
'Загрузите файл или вставьте JSON — например ответ модели. Недостающие группы и коллекции файл может принести с собой; шоу не создаются никогда — их приносит загрузка медиа. Незнакомые ссылки не валят импорт: такие слоты пропускаются, и вы увидите их списком.',
pickFile: 'Выбрать файл',
replace: 'Снести существующие слоты',
pastePlaceholder: 'Вставьте JSON конфигурации сетки',
importAction: 'Загрузить',
imported: 'Создано слотов: {{slots}}, пропущено: {{skipped}}',
importedLibrary: 'Заведено групп: {{groups}}, коллекций: {{collections}}',
badJson: 'Это не похоже на JSON — проверьте, что скопирован весь ответ целиком.',
warnings: 'Что не удалось разобрать',
aiHint:
'Соберём запрос: параметры канала, ваши группы и библиотека, ваши референсы и пожелания, плюс схема ответа. Модель вернёт JSON, который загружается вкладкой импорта.',
'Соберём запрос: параметры канала, ваши группы и библиотека, ваши референсы и пожелания, плюс схема ответа. Модель может собрать нужные ей группы сама — они заведутся при импорте.',
references: 'Референс-каналы',
referencesPlaceholder: '2×2, Paramount Comedy',
referencesHint: