From 4de89c19a65d7669b59345cae18fd7cb78db74f0 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 8 Jan 2021 16:13:37 -0300 Subject: [PATCH 1/2] Rewrite action links --- app/action-links/client/index.js | 2 -- app/action-links/client/init.js | 33 ------------------- .../client/stylesheets/actionLinks.css | 32 ------------------ app/ui-message/client/message.html | 17 +--------- app/ui-utils/client/lib/messageContext.js | 27 +++++++++++++-- client/adapters.js | 1 + client/components/Message/Actions/index.tsx | 26 +++++++++++++++ 7 files changed, 53 insertions(+), 85 deletions(-) delete mode 100644 app/action-links/client/init.js delete mode 100644 app/action-links/client/stylesheets/actionLinks.css create mode 100644 client/components/Message/Actions/index.tsx diff --git a/app/action-links/client/index.js b/app/action-links/client/index.js index c09886562a2d9..89bf0fccfb2cc 100644 --- a/app/action-links/client/index.js +++ b/app/action-links/client/index.js @@ -1,6 +1,4 @@ import { actionLinks } from './lib/actionLinks'; -import './init'; -import './stylesheets/actionLinks.css'; export { actionLinks, diff --git a/app/action-links/client/init.js b/app/action-links/client/init.js deleted file mode 100644 index f21776e7c2c06..0000000000000 --- a/app/action-links/client/init.js +++ /dev/null @@ -1,33 +0,0 @@ -import { Blaze } from 'meteor/blaze'; -import { Template } from 'meteor/templating'; - -import { handleError } from '../../utils/client'; -import { fireGlobalEvent, Layout } from '../../ui-utils/client'; -import { messageArgs } from '../../ui-utils/client/lib/messageArgs'; -import { actionLinks } from './lib/actionLinks'; - - -Template.roomOld.events({ - 'click [data-actionlink]'(event, instance) { - event.preventDefault(); - event.stopPropagation(); - - const data = Blaze.getData(event.currentTarget); - const { msg } = messageArgs(data); - if (Layout.isEmbedded()) { - return fireGlobalEvent('click-action-link', { - actionlink: $(event.currentTarget).data('actionlink'), - value: msg._id, - message: msg, - }); - } - - if (msg._id) { - actionLinks.run($(event.currentTarget).data('actionlink'), msg._id, instance, (err) => { - if (err) { - handleError(err); - } - }); - } - }, -}); diff --git a/app/action-links/client/stylesheets/actionLinks.css b/app/action-links/client/stylesheets/actionLinks.css deleted file mode 100644 index 1b5a9977c5f27..0000000000000 --- a/app/action-links/client/stylesheets/actionLinks.css +++ /dev/null @@ -1,32 +0,0 @@ -.message { - & .actionLinks { - margin-top: 4px; - margin-bottom: 4px; - padding: 0; - - text-align: center; - - & li { - position: relative; - - display: inline; - - padding-right: 2px; - - list-style: none; - - cursor: pointer; - - & .action-link { - margin: 0 2px; - padding: 5px; - - border-radius: 7px; - } - } - - & li:last-child::after { - content: none; - } - } -} diff --git a/app/ui-message/client/message.html b/app/ui-message/client/message.html index ffdef76c626ac..ae9c30fb0e811 100644 --- a/app/ui-message/client/message.html +++ b/app/ui-message/client/message.html @@ -166,22 +166,7 @@ {{/unless}} {{#unless hideActionLinks}} - + {{> MessageActions mid=msg._id actions=actionLinks runAction=(actions.runAction msg)}} {{/unless}} {{#if broadcast}} {{#with msg}} diff --git a/app/ui-utils/client/lib/messageContext.js b/app/ui-utils/client/lib/messageContext.js index a445073b5e525..ca7f0386011b0 100644 --- a/app/ui-utils/client/lib/messageContext.js +++ b/app/ui-utils/client/lib/messageContext.js @@ -5,15 +5,18 @@ import { FlowRouter } from 'meteor/kadira:flow-router'; import { Subscriptions, Rooms, Users } from '../../../models/client'; import { hasPermission } from '../../../authorization/client'; import { settings } from '../../../settings/client'; -import { getUserPreference } from '../../../utils/client'; +import { getUserPreference, handleError } from '../../../utils/client'; import { AutoTranslate } from '../../../autotranslate/client'; +import { Layout } from './Layout'; +import { fireGlobalEvent } from './fireGlobalEvent'; +import { actionLinks } from '../../../action-links/client'; const fields = { name: 1, username: 1, 'settings.preferences.showMessageInMainThread': 1, 'settings.preferences.autoImageLoad': 1, 'settings.preferences.saveMobileBandwidth': 1, 'settings.preferences.collapseMediaByDefault': 1, 'settings.preferences.hideRoles': 1 }; export function messageContext({ rid } = Template.instance()) { const uid = Meteor.userId(); const user = Users.findOne({ _id: uid }, { fields }) || {}; - + const instace = Template.instance(); const openThread = (e) => { const { rid, mid, tmid } = e.currentTarget.dataset; const room = Rooms.findOne({ _id: rid }); @@ -27,6 +30,23 @@ export function messageContext({ rid } = Template.instance()) { }); }; + const runAction = Layout.isEmbedded() ? (msg, e) => { + const { actionlink } = e.currentTarget.dataset; + return fireGlobalEvent('click-action-link', { + actionlink, + value: msg._id, + message: msg, + }); + } : (msg, e) => { + console.log(e); + const { actionlink } = e.currentTarget.dataset; + actionLinks.run(actionlink, msg._id, instace, (err) => { + if (err) { + handleError(err); + } + }); + }; + return { u: user, room: Rooms.findOne({ _id: rid }, { @@ -50,6 +70,9 @@ export function messageContext({ rid } = Template.instance()) { openThread() { return openThread; }, + runAction(msg) { + return () => (e) => runAction(msg, e); + }, }, settings: { translateLanguage: AutoTranslate.getLanguage(rid), diff --git a/client/adapters.js b/client/adapters.js index 475c69af61524..ec390c03657a5 100644 --- a/client/adapters.js +++ b/client/adapters.js @@ -1,3 +1,4 @@ const { createTemplateForComponent } = require('./reactAdapters'); createTemplateForComponent('ThreadReply', () => import('./components/Message/Metrics/Thread')); +createTemplateForComponent('MessageActions', () => import('./components/Message/Actions')); diff --git a/client/components/Message/Actions/index.tsx b/client/components/Message/Actions/index.tsx new file mode 100644 index 0000000000000..332fcbd2ed35b --- /dev/null +++ b/client/components/Message/Actions/index.tsx @@ -0,0 +1,26 @@ +import React, { FC } from 'react'; +import { IconProps, Icon, Button, ButtonGroup } from '@rocket.chat/fuselage'; + +import { useTranslation } from '../../../contexts/TranslationContext'; +import { Content } from '..'; + +type RunAction = () => void; + +type ActionOptions = { + mid: string; + id: string; + icon: IconProps['name']; + i18nLabel?: string; + label?: string; + runAction?: RunAction; +}; + +export const Action: FC = ({ id, icon, i18nLabel, label, mid, runAction }) => { + const t = useTranslation(); + + return ; +}; + +const Actions: FC<{ actions: Array; runAction: RunAction; mid: string }> = ({ actions, runAction }) => {actions.map((action) => )}; + +export default Actions; From bc5bc8d9bc4c0ad25a70a2403de427c690bf4dff Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 15 Jan 2021 21:15:15 -0300 Subject: [PATCH 2/2] Fix Martin --- app/videobridge/client/views/videoFlexTab.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/videobridge/client/views/videoFlexTab.js b/app/videobridge/client/views/videoFlexTab.js index 30fd8fbbf1202..4d5cf16999065 100644 --- a/app/videobridge/client/views/videoFlexTab.js +++ b/app/videobridge/client/views/videoFlexTab.js @@ -155,6 +155,14 @@ Template.videoFlexTab.onRendered(function() { }); } + await new Promise((resolve) => { + if (typeof JitsiMeetExternalAPI === 'undefined') { + const prefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ''; + return $.getScript(`${ prefix }/packages/rocketchat_videobridge/client/public/external_api.js`, resolve); + } + resolve(); + }); + if (typeof JitsiMeetExternalAPI !== 'undefined') { // Keep it from showing duplicates when re-evaluated on variable change. const name = Users.findOne(Meteor.userId(), { fields: { name: 1 } }); @@ -162,6 +170,7 @@ Template.videoFlexTab.onRendered(function() { Tracker.nonreactive(async () => { await start(); + this.api = new JitsiMeetExternalAPI(domain, jitsiRoom, width, height, this.$('.video-container').get(0), configOverwrite, interfaceConfigOverwrite, noSsl, accessToken); /*