From c630a0647da73ed8c7c90746e10e2a3032af83e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 17 Jan 2020 00:40:31 +0100 Subject: [PATCH 1/3] Add support for opening files through Viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that the "path" property was already being passed to FilePreview, although it was not explicitly declared. At this time the Viewer can open only internal files, which are available only for registered users. Therefore the Viewer is not loaded for guests. Also, for the time being, due to a limitation in the Viewer API, when a file is opened the Viewer allows the user to iterate through all the files in the directory of that file instead of through all the files in the conversation, as it would have been expected. Signed-off-by: Daniel Calviño Sánchez --- lib/Controller/PageController.php | 10 +++++ .../Message/MessagePart/FilePreview.vue | 44 ++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 33b0f5a74dd..b3b3eb10e83 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -32,6 +32,7 @@ use OCA\Talk\Participant; use OCA\Talk\Room; use OCA\Talk\TalkSession; +use OCA\Viewer\Event\LoadViewer; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -40,6 +41,7 @@ use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; use OCP\IInitialStateService; @@ -53,6 +55,8 @@ class PageController extends Controller { /** @var string|null */ private $userId; + /** @var IEventDispatcher */ + private $eventDispatcher; /** @var RoomController */ private $api; /** @var TalkSession */ @@ -78,6 +82,7 @@ class PageController extends Controller { public function __construct(string $appName, IRequest $request, + IEventDispatcher $eventDispatcher, RoomController $api, TalkSession $session, IUserSession $userSession, @@ -91,6 +96,7 @@ public function __construct(string $appName, IRootFolder $rootFolder, Config $config) { parent::__construct($appName, $request); + $this->eventDispatcher = $eventDispatcher; $this->api = $api; $this->talkSession = $session; $this->userSession = $userSession; @@ -243,6 +249,10 @@ public function index(string $token = '', string $callUser = '', string $passwor } } + if (class_exists(LoadViewer::class)) { + $this->eventDispatcher->dispatchTyped(new LoadViewer()); + } + $params = [ 'token' => $token, 'signaling-settings' => $this->config->getSettings($this->userId), diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index ed8d13f7d7c..52f28845e00 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -23,7 +23,8 @@ + rel="noopener noreferrer" + @click="showPreview"> From 21c2874d62274b1311903737b6da1be201e86981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Tue, 25 Feb 2020 19:37:30 +0100 Subject: [PATCH 2/3] Show hover/focus/active state on file previews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A hover colour is shown around the file preview when hovered/focused/active in a similar way to how list items or non primary buttons are highlighted. Signed-off-by: Daniel Calviño Sánchez --- .../Message/MessagePart/FilePreview.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index 52f28845e00..f76391c2fef 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -156,6 +156,22 @@ export default { image. */ display: inline-block; + /* Show a hover colour around the preview when navigating with the + * keyboard through the file links (or hovering them with the mouse). */ + &:hover, + &:focus, + &:active { + .preview { + background-color: var(--color-background-hover); + + /* Trick to keep the same position while adding a padding to show + * the background. */ + box-sizing: content-box !important; + padding: 10px; + margin: -10px; + } + } + .preview { display: block; width: 128px; From 6ab75d7816a015a2d4d5fb001e45d914db522e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Tue, 25 Feb 2020 19:46:56 +0100 Subject: [PATCH 3/3] Add hint to file previews not supported by the viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like done on links, " ↗" is now added to the name of file previews to hint that the file will be opened in a different tab/window. Signed-off-by: Daniel Calviño Sánchez --- .../MessagesGroup/Message/MessagePart/FilePreview.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index f76391c2fef..9a5a77968ea 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -22,6 +22,7 @@