-
-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a nojs blade template to be able to enable/disable extensions when one of them misbehaves.
- Loading branch information
Showing
15 changed files
with
403 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Minimal NoJs specific styles | ||
.NoJs-ExtensionsTable { | ||
td&-icon { | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
} | ||
|
||
.ExtensionListItem-Dot { | ||
position: relative; | ||
right: 0; | ||
margin: 0; | ||
} | ||
|
||
.ExtensionIcon { | ||
--size: 25px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
.Table { | ||
background: @control-bg; | ||
border-radius: @border-radius; | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
|
||
caption { | ||
text-align: start; | ||
} | ||
|
||
td, th { | ||
border-bottom: 1px solid @body-bg; | ||
color: @control-color; | ||
} | ||
|
||
td, th, .Checkbox, &-controls-item { | ||
padding: 10px 15px; | ||
} | ||
|
||
& &-checkbox, & &-controls { | ||
padding: 0; | ||
} | ||
|
||
thead { | ||
th { | ||
text-align: center; | ||
padding: 15px 25px; | ||
} | ||
|
||
.icon { | ||
display: block; | ||
font-size: 14px; | ||
width: auto; | ||
margin-bottom: 5px; | ||
} | ||
} | ||
|
||
&-groupToggle { | ||
cursor: pointer; | ||
|
||
.icon { | ||
font-size: 14px; | ||
margin-right: 2px; | ||
.fa-fw(); | ||
} | ||
} | ||
|
||
&-checkbox { | ||
.Checkbox { | ||
display: block; | ||
} | ||
|
||
.Checkbox-display { | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
|
||
&.highlighted .Checkbox, .Checkbox:hover { | ||
&:not(.disabled) { | ||
background: darken(@control-bg, 4%); | ||
} | ||
} | ||
} | ||
|
||
&-controls-item { | ||
width: 100%; | ||
border-radius: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,3 @@ | ||
.NotificationGrid { | ||
background: @control-bg; | ||
border-radius: @border-radius; | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
|
||
td, th { | ||
border-bottom: 1px solid @body-bg; | ||
color: @control-color; | ||
} | ||
td, th, .Checkbox { | ||
padding: 10px 15px; | ||
} | ||
.NotificationGrid-checkbox { | ||
padding: 0; | ||
} | ||
thead { | ||
th { | ||
text-align: center; | ||
padding: 15px 25px; | ||
} | ||
.icon { | ||
display: block; | ||
font-size: 14px; | ||
width: auto; | ||
margin-bottom: 5px; | ||
} | ||
} | ||
} | ||
.NotificationGrid-groupToggle { | ||
cursor: pointer; | ||
|
||
.icon { | ||
font-size: 14px; | ||
margin-right: 2px; | ||
.fa-fw(); | ||
} | ||
} | ||
.NotificationGrid-checkbox { | ||
.Checkbox { | ||
display: block; | ||
} | ||
.Checkbox-display { | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
&.highlighted .Checkbox, .Checkbox:hover { | ||
&:not(.disabled) { | ||
background: darken(@control-bg, 4%); | ||
} | ||
} | ||
.Table(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Admin\Content; | ||
|
||
use Flarum\Extension\ExtensionManager; | ||
use Flarum\Foundation\Application; | ||
use Flarum\Frontend\Document; | ||
use Flarum\Settings\SettingsRepositoryInterface; | ||
use Illuminate\Contracts\View\Factory; | ||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
|
||
class Index | ||
{ | ||
/** | ||
* @var Factory | ||
*/ | ||
protected $view; | ||
|
||
/** | ||
* @var ExtensionManager | ||
*/ | ||
protected $extensions; | ||
|
||
/** | ||
* @var SettingsRepositoryInterface | ||
*/ | ||
protected $settings; | ||
|
||
public function __construct(Factory $view, ExtensionManager $extensions, SettingsRepositoryInterface $settings) | ||
{ | ||
$this->view = $view; | ||
$this->extensions = $extensions; | ||
$this->settings = $settings; | ||
} | ||
|
||
public function __invoke(Document $document, Request $request): Document | ||
{ | ||
$extensions = $this->extensions->getExtensions(); | ||
$extensionsEnabled = json_decode($this->settings->get('extensions_enabled', '{}'), true); | ||
$csrfToken = $request->getAttribute('session')->token(); | ||
|
||
$mysqlVersion = $document->payload['mysqlVersion']; | ||
$phpVersion = $document->payload['phpVersion']; | ||
$flarumVersion = Application::VERSION; | ||
|
||
$document->content = $this->view->make( | ||
'flarum.admin::frontend.content.admin', | ||
compact('extensions', 'extensionsEnabled', 'csrfToken', 'flarumVersion', 'phpVersion', 'mysqlVersion') | ||
); | ||
|
||
return $document; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Admin\Controller; | ||
|
||
use Flarum\Bus\Dispatcher; | ||
use Flarum\Extension\Command\ToggleExtension; | ||
use Flarum\Http\RequestUtil; | ||
use Flarum\Http\UrlGenerator; | ||
use Illuminate\Support\Arr; | ||
use Laminas\Diactoros\Response\RedirectResponse; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
|
||
class UpdateExtensionController implements RequestHandlerInterface | ||
{ | ||
/** | ||
* @var UrlGenerator | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* @var Dispatcher | ||
*/ | ||
protected $bus; | ||
|
||
public function __construct(UrlGenerator $url, Dispatcher $bus) | ||
{ | ||
$this->url = $url; | ||
$this->bus = $bus; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(Request $request): ResponseInterface | ||
{ | ||
$actor = RequestUtil::getActor($request); | ||
$enabled = (bool) (int) Arr::get($request->getParsedBody(), 'enabled'); | ||
$name = Arr::get($request->getQueryParams(), 'name'); | ||
|
||
$this->bus->dispatch( | ||
new ToggleExtension($actor, $name, $enabled) | ||
); | ||
|
||
return new RedirectResponse($this->url->to('admin')->base()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.