Skip to content

Commit

Permalink
Merge pull request #176 from Larsklopstra/features/disable-markdown-u…
Browse files Browse the repository at this point in the history
…ploads

Disable markdown uploads
  • Loading branch information
Cannonb4ll authored Oct 18, 2022
2 parents 524e4d5 + b33d033 commit da7bd2c
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

namespace App\Console\Commands;

use App\Settings\GeneralSettings;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Console\Command;

class ConvertNotifications extends Command
{
protected $signature = 'roadmap:convert-notifications';

protected $description = 'Convert notifications to new format';

return new class extends Migration {
public function up()
public function handle()
{
$array = [];

Expand All @@ -20,10 +25,7 @@ public function up()

app(GeneralSettings::class)->send_notifications_to = $array;
app(GeneralSettings::class)->save();
}

public function down()
{
//
return Command::SUCCESS;
}
};
}
4 changes: 4 additions & 0 deletions app/Filament/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ protected function getFormSchema(): array
->label('Users must verify their email before they can submit items, or reply to items.')
->columnSpan(2),

Toggle::make('disable_file_uploads')
->label('Disallow users to upload files or images via the markdown editors.')
->columnSpan(2),

Grid::make()->schema([
Select::make('inbox_workflow')
->options(InboxWorkflow::getSelectOptions())
Expand Down
1 change: 1 addition & 0 deletions app/Http/Livewire/Item/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected function getFormSchema(): array
MarkdownEditor::make('content')
->label(trans('comments.comment'))
->helperText(trans('comments.mention-helper-text'))
->disableToolbarButtons(app(GeneralSettings::class)->getDisabledToolbarButtons())
->minLength(3)
->required(),
];
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Livewire/Item/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Item;
use App\Models\Board;
use App\Models\Project;
use App\Settings\GeneralSettings;
use Livewire\Component;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\TextInput;
Expand Down Expand Up @@ -35,6 +36,7 @@ protected function getFormSchema(): array
->required(),
MarkdownEditor::make('content')
->label(trans('table.content'))
->disableToolbarButtons(app(GeneralSettings::class)->getDisabledToolbarButtons())
->minLength(10)
->required(),
];
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Livewire/Item/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Livewire\Item;

use App\Models\Item;
use App\Settings\GeneralSettings;
use Livewire\Component;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\TextInput;
Expand Down Expand Up @@ -32,6 +33,7 @@ protected function getFormSchema(): array
->required(),
MarkdownEditor::make('content')
->label(trans('table.content'))
->disableToolbarButtons(app(GeneralSettings::class)->getDisabledToolbarButtons())
->minLength(10)
->required(),
];
Expand Down
8 changes: 5 additions & 3 deletions app/Http/Livewire/Modals/Item/Comment/EditCommentModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use function view;
use function redirect;
use App\Models\Comment;
use App\Settings\GeneralSettings;
use Filament\Forms\Components\Group;
use LivewireUI\Modal\ModalComponent;
use Filament\Forms\Contracts\HasForms;
Expand All @@ -31,9 +32,10 @@ protected function getFormSchema(): array
return [
Group::make([
MarkdownEditor::make('content')
->label(trans('comments.comment'))
->id('edit-comment' . $this->comment->id)
->required(),
->label(trans('comments.comment'))
->id('edit-comment' . $this->comment->id)
->disableToolbarButtons(app(GeneralSettings::class)->getDisabledToolbarButtons())
->required(),
])
];
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Livewire/Modals/Item/CreateItemModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected function getFormSchema(): array
$inputs[] = Group::make([
MarkdownEditor::make('content')
->label(trans('table.content'))
->disableToolbarButtons(app(GeneralSettings::class)->getDisabledToolbarButtons())
->minLength(10)
->required()
]);
Expand Down
12 changes: 12 additions & 0 deletions app/Settings/GeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,24 @@ class GeneralSettings extends Settings
public bool $enable_changelog;
public bool $show_changelog_author;
public bool $show_changelog_related_items;
public bool $disable_file_uploads;

public function getInboxWorkflow(): InboxWorkflow
{
return InboxWorkflow::from($this->inbox_workflow);
}

public function getDisabledToolbarButtons(): array
{
$toolbarButtons = [];

if ($this->disable_file_uploads) {
$toolbarButtons[] = 'attachFiles';
}

return $toolbarButtons;
}

public static function group(): string
{
return 'general';
Expand Down
11 changes: 11 additions & 0 deletions database/settings/2022_10_18_114350_add_disable_file_uploads.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

class AddDisableFileUploads extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('general.disable_file_uploads', false);
}
}

0 comments on commit da7bd2c

Please sign in to comment.