fix: YouTube requires content text — frontend validation now shows error when content is empty
This commit is contained in:
parent
7aaaf4df4f
commit
66d0731090
9 changed files with 19 additions and 3 deletions
|
|
@ -137,6 +137,14 @@ public function supportsTextOnly(): bool
|
|||
};
|
||||
}
|
||||
|
||||
public function requiresContent(): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::YouTube => true,
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
public function queue(): string
|
||||
{
|
||||
return 'social-'.$this->value;
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ public function edit(Request $request, Post $post): Response|RedirectResponse
|
|||
'maxImages' => $account->platform->maxImages(),
|
||||
'allowedMediaTypes' => array_map(fn ($type) => $type->value, $account->platform->allowedMediaTypes()),
|
||||
'supportsTextOnly' => $account->platform->supportsTextOnly(),
|
||||
'requiresContent' => $account->platform->requiresContent(),
|
||||
],
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
'videos_not_supported' => 'Videos not supported',
|
||||
'max_images' => 'Max :count images',
|
||||
'requires_media' => 'Requires media',
|
||||
'requires_content' => 'Text content is required',
|
||||
'exceeded' => ':count exceeded',
|
||||
'does_not_support_images' => ':platform does not support images',
|
||||
'supports_up_to_images' => ':platform supports up to :count images',
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
'videos_not_supported' => 'Videos no soportados',
|
||||
'max_images' => 'Máximo :count imágenes',
|
||||
'requires_media' => 'Requiere multimedia',
|
||||
'requires_content' => 'Se requiere texto',
|
||||
'exceeded' => ':count excedido',
|
||||
'does_not_support_images' => ':platform no soporta imágenes',
|
||||
'supports_up_to_images' => ':platform soporta hasta :count imágenes',
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -115,6 +115,7 @@
|
|||
'videos_not_supported' => 'Vídeos não suportados',
|
||||
'max_images' => 'Máx :count imagens',
|
||||
'requires_media' => 'Requer mídia',
|
||||
'requires_content' => 'Texto é obrigatório',
|
||||
'exceeded' => ':count excedido',
|
||||
'does_not_support_images' => ':platform não suporta imagens',
|
||||
'supports_up_to_images' => ':platform suporta até :count imagens',
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ interface PlatformConfig {
|
|||
maxImages: number;
|
||||
allowedMediaTypes: string[];
|
||||
supportsTextOnly: boolean;
|
||||
requiresContent: boolean;
|
||||
}
|
||||
|
||||
interface Workspace {
|
||||
|
|
@ -371,6 +372,7 @@ const getConfig = (postPlatform: PostPlatform): PlatformConfig => {
|
|||
maxImages: 10,
|
||||
allowedMediaTypes: ['image', 'video'],
|
||||
supportsTextOnly: true,
|
||||
requiresContent: false,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -567,6 +569,8 @@ const contentValidation = computed(() => {
|
|||
results[pp.id] = { valid: false, message: trans('posts.edit.validation.max_images', { count: String(config.maxImages) }), charCount, maxLength: config.maxContentLength };
|
||||
} else if (!config.supportsTextOnly && !hasMedia) {
|
||||
results[pp.id] = { valid: false, message: trans('posts.edit.validation.requires_media'), charCount, maxLength: config.maxContentLength };
|
||||
} else if (config.requiresContent && !hasContent) {
|
||||
results[pp.id] = { valid: false, message: trans('posts.edit.validation.requires_content'), charCount, maxLength: config.maxContentLength };
|
||||
} else if (!hasContent && !hasMedia) {
|
||||
results[pp.id] = { valid: false, message: trans('posts.edit.no_content'), charCount, maxLength: config.maxContentLength };
|
||||
} else if (!withinLimit) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue