feat(submissions): notes field (#1020)

This commit is contained in:
Kyrch
2025-12-10 20:50:16 -03:00
committed by GitHub
parent 7b786cf911
commit fefff9b8ab
47 changed files with 88 additions and 54 deletions
+3 -1
View File
@@ -106,7 +106,9 @@ FFPROBE_BINARIES=
# filament
FILAMENT_URL=
FILAMENT_PATH=/admin
FILAMENT_PATH=admin
FILAMENT_SUBMISSION_URL=
FILAMENT_SUBMISSION_PATH=submission
# filesystems
FILESYSTEM_DISK=local
+3 -1
View File
@@ -104,7 +104,9 @@ FFPROBE_BINARIES=
# filament
FILAMENT_URL=
FILAMENT_PATH=/admin
FILAMENT_PATH=admin
FILAMENT_SUBMISSION_URL=
FILAMENT_SUBMISSION_PATH=submission
# filesystems
FILESYSTEM_DISK=local
+4 -2
View File
@@ -14,11 +14,13 @@ enum SpecialPermission: string
case BYPASS_GRAPHQL_RATE_LIMITER = 'bypass graphql rate limiter';
case MAKE_SUBMISSION = 'make submission';
case REVALIDATE_PAGES = 'revalidate pages';
case VIEW_FILAMENT = 'view filament';
case VIEW_HORIZON = 'view horizon';
case VIEW_PULSE = 'view pulse';
case REVALIDATE_PAGES = 'revalidate pages';
}
@@ -27,7 +27,7 @@ class BelongsToColumn extends TextColumn
throw_unless(($resource = new $resource) instanceof BaseResource, InvalidArgumentException::class, 'The resource must instanceof a BaseResource.');
$static = app(static::class, ['name' => $relation]);
$static = resolve(static::class, ['name' => $relation]);
$static->resource = $resource;
$static->shouldUseModelName = $shouldUseModelName;
$static->configure();
+1 -1
View File
@@ -67,7 +67,7 @@ class BelongsTo extends Select
{
$this->allowHtml();
$this->searchable();
$this->getOptionLabelUsing(fn ($state): string => is_null($state) ? '' : static::getSearchLabelWithBlade($modelClass::find($state), $this->withSubtitle));
$this->getOptionLabelUsing(fn ($state): string => is_null($state) ? '' : static::getSearchLabelWithBlade($modelClass::query()->find($state), $this->withSubtitle));
if (in_array(Searchable::class, class_uses_recursive($modelClass))) {
return $this
+1 -1
View File
@@ -25,7 +25,7 @@ class Select extends ComponentsSelect
return $this
->allowHtml()
->searchable()
->getOptionLabelUsing(fn ($state): string => is_null($state) ? '' : BelongsTo::getSearchLabelWithBlade($modelClass::find($state)))
->getOptionLabelUsing(fn ($state): string => is_null($state) ? '' : BelongsTo::getSearchLabelWithBlade($modelClass::query()->find($state)))
->getSearchResultsUsing(
fn (string $search) =>
/** @phpstan-ignore-next-line */
+1 -1
View File
@@ -12,7 +12,7 @@ class TextInput extends BaseTextInput
public function uri(): static
{
return $this
->stateCast(app(UriStateCast::class))
->stateCast(resolve(UriStateCast::class))
->url();
}
}
@@ -27,7 +27,7 @@ class BelongsToEntry extends TextEntry
throw_unless(($resource = new $resource) instanceof BaseResource, InvalidArgumentException::class, 'The resource must instanceof a BaseResource.');
$static = app(static::class, ['name' => $relation]);
$static = resolve(static::class, ['name' => $relation]);
$static->resource = $resource;
$static->shouldUseModelName = $shouldUseModelName;
$static->configure();
@@ -36,6 +36,7 @@ use Filament\Actions\Action;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Textarea;
use Filament\Resources\Pages\CreateRecord;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
@@ -52,6 +53,11 @@ class CreateAnimeSubmission extends CreateRecord
{
return $schema
->components([
Textarea::make('notes')
->label(__('submissions.fields.base.notes.name'))
->helperText(__('submissions.fields.base.notes.help'))
->rows(5),
Tabs::make('tabs')
->vertical()
->columnSpanFull()
@@ -78,7 +84,6 @@ class CreateAnimeSubmission extends CreateRecord
Repeater::make(Anime::RELATION_THEMES)
->label(__('filament.resources.label.anime_themes'))
->addActionLabel(__('filament.buttons.add', ['label' => __('filament.resources.singularLabel.anime_theme')]))
->defaultItems(0)
->schema([
Tabs::make('Tabs')
->schema([
@@ -296,12 +301,12 @@ class CreateAnimeSubmission extends CreateRecord
protected function getCreateFormAction(): Action
{
return parent::getCreateFormAction()
->label('Submit');
->label(__('submissions.buttons.submit'));
}
protected function getCreateAnotherFormAction(): Action
{
return parent::getCreateAnotherFormAction()
->label('Submit & Submit another');
->label(__('submissions.buttons.submit_another'));
}
}
+1 -1
View File
@@ -50,7 +50,7 @@ class ConnectionType extends RebingType
'edges' => [
'type' => Type::nonNull(Type::listOf(Type::nonNull(GraphQL::type($this->edgeType->getName())))),
'description' => "A list of {$this->getNodeTypeName()} edges.",
'resolve' => fn (LengthAwarePaginator $paginator): Collection => $this->edgesResolver($paginator),
'resolve' => $this->edgesResolver(...),
],
'nodes' => [
'type' => Type::nonNull(Type::listOf(Type::nonNull(GraphQL::type($this->getNodeTypeName())))),
+1 -1
View File
@@ -58,7 +58,7 @@ class Announcement extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnnouncementCreated::class,
+1 -1
View File
@@ -54,7 +54,7 @@ class Dump extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => DumpCreated::class,
+1 -1
View File
@@ -55,7 +55,7 @@ class Feature extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => FeatureCreated::class,
+1 -1
View File
@@ -72,7 +72,7 @@ class FeaturedTheme extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => FeaturedThemeCreated::class,
+2 -3
View File
@@ -8,7 +8,6 @@ use App\Concerns\Models\SoftDeletes;
use App\Contracts\Models\HasSubtitle;
use App\Contracts\Models\Nameable;
use App\Contracts\Models\SoftDeletable;
use App\Enums\Auth\Role;
use App\Enums\Auth\SpecialPermission;
use App\Enums\Http\Api\Filter\ComparisonOperator;
use App\Events\Auth\User\UserCreated;
@@ -112,7 +111,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => UserCreated::class,
@@ -176,7 +175,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasSubtit
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'submission') {
return $this->hasRole(Role::ADMIN->value);
return $this->hasAnyPermission(SpecialPermission::MAKE_SUBMISSION->value);
}
if ($this->hasVerifiedEmail() && $this->hasAnyPermission(SpecialPermission::VIEW_FILAMENT->value)) {
+1 -1
View File
@@ -83,7 +83,7 @@ class DiscordThread extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'deleted' => DiscordThreadDeleted::class,
+1 -1
View File
@@ -61,7 +61,7 @@ class Page extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => PageCreated::class,
+1 -1
View File
@@ -90,7 +90,7 @@ class ExternalProfile extends BaseModel
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ExternalProfileCreated::class,
+1 -1
View File
@@ -90,7 +90,7 @@ class Playlist extends BaseModel implements HasAggregateLikes, HasHashids, HasIm
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => PlaylistCreated::class,
+1 -1
View File
@@ -83,7 +83,7 @@ class PlaylistTrack extends BaseModel implements HasHashids, InteractsWithSchema
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => TrackCreated::class,
+1 -1
View File
@@ -108,7 +108,7 @@ class Anime extends BaseModel implements HasImages, HasResources, SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnimeCreated::class,
+1 -1
View File
@@ -62,7 +62,7 @@ class AnimeSynonym extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => SynonymCreated::class,
+1 -1
View File
@@ -107,7 +107,7 @@ class AnimeTheme extends BaseModel implements InteractsWithSchema, SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ThemeCreated::class,
@@ -110,7 +110,7 @@ class AnimeThemeEntry extends BaseModel implements HasAggregateLikes, HasResourc
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => EntryCreated::class,
+1 -1
View File
@@ -99,7 +99,7 @@ class Artist extends BaseModel implements HasImages, HasResources, SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ArtistCreated::class,
+1 -1
View File
@@ -70,7 +70,7 @@ class Audio extends BaseModel implements HasAggregateViews, SoftDeletable, Strea
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AudioCreated::class,
+1 -1
View File
@@ -69,7 +69,7 @@ class ExternalResource extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ExternalResourceCreated::class,
+1 -1
View File
@@ -58,7 +58,7 @@ class Group extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => GroupCreated::class,
+1 -1
View File
@@ -70,7 +70,7 @@ class Image extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ImageCreated::class,
+1 -1
View File
@@ -60,7 +60,7 @@ class Series extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => SeriesCreated::class,
+1 -1
View File
@@ -75,7 +75,7 @@ class Song extends BaseModel implements HasResources, SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => SongCreated::class,
+1 -1
View File
@@ -67,7 +67,7 @@ class Membership extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => MembershipCreated::class,
+1 -1
View File
@@ -73,7 +73,7 @@ class Performance extends BaseModel implements SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => PerformanceCreated::class,
+1 -1
View File
@@ -66,7 +66,7 @@ class Studio extends BaseModel implements HasImages, HasResources, SoftDeletable
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => StudioCreated::class,
+1 -1
View File
@@ -122,7 +122,7 @@ class Video extends BaseModel implements HasAggregateViews, SoftDeletable, Strea
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => VideoCreated::class,
+1 -1
View File
@@ -57,7 +57,7 @@ class VideoScript extends BaseModel implements InteractsWithSchema, SoftDeletabl
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => VideoScriptCreated::class,
+1 -1
View File
@@ -78,7 +78,7 @@ class Imageable extends BaseMorphPivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ImageableCreated::class,
+1 -1
View File
@@ -80,7 +80,7 @@ class Resourceable extends BaseMorphPivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ResourceableCreated::class,
+1 -1
View File
@@ -65,7 +65,7 @@ class AnimeSeries extends BasePivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnimeSeriesCreated::class,
+1 -1
View File
@@ -65,7 +65,7 @@ class AnimeStudio extends BasePivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnimeStudioCreated::class,
+1 -1
View File
@@ -69,7 +69,7 @@ class AnimeThemeEntryVideo extends BasePivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnimeThemeEntryVideoCreated::class,
+1 -1
View File
@@ -77,7 +77,7 @@ class ArtistMember extends BasePivot
*
* Allows for object-based events for native Eloquent events.
*
* @var class-string[]
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => ArtistMemberCreated::class,
@@ -17,6 +17,7 @@ use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Config;
use Illuminate\View\Middleware\ShareErrorsFromSession;
class SubmissionPanelProvider extends PanelProvider
@@ -24,13 +25,14 @@ class SubmissionPanelProvider extends PanelProvider
public function panel(Panel $panel): Panel
{
return $panel
->id('submission')
->path('submission')
->id(Config::get('filament.submission.path'))
->path(Config::get('filament.submission.path'))
->domain(Config::get('filament.submission.domain'))
->login()
->maxContentWidth(Width::Full)
->globalSearch(false)
->colors([
'primary' => Color::Amber,
'primary' => Color::Violet,
])
->discoverResources(in: app_path('Filament/Submission/Resources'), for: 'App\Filament\Submission\Resources')
->discoverPages(in: app_path('Filament/Submission/Pages'), for: 'App\Filament\Submission\Pages')
+14
View File
@@ -57,6 +57,20 @@ return [
'path' => env('FILAMENT_PATH'),
/*
|--------------------------------------------------------------------------
| Submission
|--------------------------------------------------------------------------
|
| Submission-related configuration.
|
*/
'submission' => [
'domain' => env('FILAMENT_SUBMISSION_URL', env('FILAMENT_URL')),
'path' => env('FILAMENT_SUBMISSION_PATH', ''),
],
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
@@ -16,7 +16,6 @@ use App\Models\List\Playlist;
use App\Models\List\Playlist\PlaylistTrack;
use App\Models\User\Like;
use App\Models\User\Notification;
use App\Models\User\Submission;
use App\Models\Wiki\Anime;
use App\Models\Wiki\Anime\AnimeSynonym;
use App\Models\Wiki\Anime\AnimeTheme;
@@ -60,7 +59,6 @@ class ContributorRoleSeeder extends RoleSeeder
// User Resources
$this->configureResource($role, Like::class, [CrudPermission::VIEW, CrudPermission::CREATE, CrudPermission::DELETE]);
$this->configureResource($role, Notification::class, [CrudPermission::VIEW, CrudPermission::UPDATE]);
$this->configureResource($role, Submission::class, [CrudPermission::VIEW, CrudPermission::CREATE, CrudPermission::UPDATE]);
// Wiki Resources
$this->configureResource($role, Anime::class, [CrudPermission::VIEW]);
@@ -16,7 +16,6 @@ use App\Models\List\Playlist;
use App\Models\List\Playlist\PlaylistTrack;
use App\Models\User\Like;
use App\Models\User\Notification;
use App\Models\User\Submission;
use App\Models\Wiki\Anime;
use App\Models\Wiki\Anime\AnimeSynonym;
use App\Models\Wiki\Anime\AnimeTheme;
@@ -60,7 +59,6 @@ class PanelViewerRoleSeeder extends RoleSeeder
// User Resources
$this->configureResource($role, Like::class, [CrudPermission::VIEW, CrudPermission::CREATE, CrudPermission::DELETE]);
$this->configureResource($role, Notification::class, [CrudPermission::VIEW, CrudPermission::UPDATE]);
$this->configureResource($role, Submission::class, [CrudPermission::VIEW, CrudPermission::CREATE, CrudPermission::UPDATE]);
// Wiki Resources
$this->configureResource($role, Anime::class, [CrudPermission::VIEW]);
+12
View File
@@ -3,6 +3,18 @@
declare(strict_types=1);
return [
'buttons' => [
'submit' => 'Submit',
'submit_another' => 'Submit & Submit another',
],
'fields' => [
'base' => [
'notes' => [
'help' => 'Add any relevant notes or sources that support this submission.',
'name' => 'Notes / Sources',
],
],
],
'resources' => [
'label' => [
'anime' => 'Anime',