mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 03:23:48 +00:00
Improve admin UX for configuration of document template (document generation)
This commit is contained in:
@@ -15,7 +15,6 @@ use ChampsLibres\WopiLib\Contract\Service\Configuration\ConfigurationInterface;
|
||||
use ChampsLibres\WopiLib\Contract\Service\Discovery\DiscoveryInterface;
|
||||
use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\WopiBundle\Service\Controller\ResponderInterface;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||
use loophp\psr17\Psr17Interface;
|
||||
@@ -43,13 +42,11 @@ final readonly class Editor
|
||||
|
||||
public function __invoke(string $fileId, Request $request): Response
|
||||
{
|
||||
if (null === $user = $this->security->getUser()) {
|
||||
if (!($this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN'))) {
|
||||
throw new AccessDeniedHttpException('Please authenticate to access this feature');
|
||||
}
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException('Please authenticate as a user to access this feature');
|
||||
}
|
||||
$user = $this->security->getUser();
|
||||
|
||||
$configuration = $this->wopiConfiguration->jsonSerialize();
|
||||
/** @var StoredObject $storedObject */
|
||||
@@ -77,7 +74,12 @@ final readonly class Editor
|
||||
}
|
||||
|
||||
if ([] === $discoverExtension = $this->wopiDiscovery->discoverMimeType($storedObject->getType())) {
|
||||
throw new \Exception(sprintf('Unable to find mime type %s', $storedObject->getType()));
|
||||
return new Response(
|
||||
$this->engine
|
||||
->render('@ChillWopi/Editor/unable_to_edit_such_document.html.twig', [
|
||||
'document' => $storedObject,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
$configuration['favIconUrl'] = '';
|
||||
|
@@ -0,0 +1,34 @@
|
||||
{% extends '@ChillMain/layout.html.twig' %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="alert alert-danger text-center">
|
||||
<div>
|
||||
<p>
|
||||
{{ 'wopi_editor.document unsupported for edition'|trans }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>{{ document|chill_document_button_group(document.title|default('Document'), false) }}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<ul class="sticky-form-buttons record_actions">
|
||||
<li class="cancel">
|
||||
<a href="{{ chill_return_path_or('chill_main_homepage') }}" class="btn btn-cancel">
|
||||
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock content %}
|
@@ -38,7 +38,7 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
|
||||
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
if (!($user instanceof User || $this->security->isGranted('ROLE_ADMIN'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,10 @@ class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInter
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User && $this->security->isGranted('ROLE_ADMIN')) {
|
||||
return $user->getUsername();
|
||||
}
|
||||
|
||||
if (!$user instanceof User) {
|
||||
return null;
|
||||
}
|
||||
@@ -36,6 +40,10 @@ class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInter
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User && $this->security->isGranted('ROLE_ADMIN')) {
|
||||
return $user->getUsername();
|
||||
}
|
||||
|
||||
if (!$user instanceof User) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -0,0 +1,2 @@
|
||||
wopi_editor:
|
||||
document unsupported for edition: Ce format de document n'est pas éditable
|
Reference in New Issue
Block a user