Merge remote-tracking branch 'origin/develop' into release-candidate

pull/16608/head
Diego Sampaio 5 years ago
commit eb321eca08
  1. 6
      app/apps/server/bridges/uiInteraction.js
  2. 26
      app/apps/server/communication/rest.js
  3. 7
      app/ui-message/client/blocks/MessageBlock.js

@ -14,12 +14,6 @@ export class UiInteractionBridge {
throw new Error('Invalid app provided');
}
const { name, iconFileContent } = app.getInfo();
Object.assign(interaction, {
appInfo: { name, base64Icon: iconFileContent },
});
Notifications.notifyUser(user.id, 'uiInteraction', interaction);
}
}

@ -503,16 +503,30 @@ export class AppsRestApi {
},
});
this.api.addRoute(':id/icon', { authRequired: true, permissionsRequired: ['manage-apps'] }, {
this.api.addRoute(':id/icon', { authRequired: false }, {
get() {
const prl = manager.getOneById(this.urlParams.id);
if (!prl) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
if (prl) {
const info = prl.getInfo();
return API.v1.success({ iconFileContent: info.iconFileContent });
const info = prl.getInfo();
if (!info || !info.iconFileContent) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
const imageData = info.iconFileContent.split(';base64,');
const buf = Buffer.from(imageData[1], 'base64');
return {
statusCode: 200,
headers: {
'Content-Length': buf.length,
'Content-Type': imageData[0].replace('data:', ''),
},
body: buf,
};
},
});

@ -5,9 +5,9 @@ import { Modal, AnimatedVisibility, ButtonGroup, Button, Box } from '@rocket.cha
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import { renderMessageBody } from '../../../ui-utils/client';
import { getURL } from '../../../utils/lib/getURL';
import { useReactiveValue } from '../../../../client/hooks/useReactiveValue';
const focusableElementsString = 'a[href]:not([tabindex="-1"]), area[href]:not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), iframe, object, embed, [tabindex]:not([tabindex="-1"]), [contenteditable]';
messageParser.text = ({ text, type } = {}) => {
@ -44,7 +44,6 @@ const textParser = uiKitText(new class {
return text;
}
}());
const thumb = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
// https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html
@ -128,14 +127,12 @@ export const modalBlockWithContext = ({
element.removeEventListener('click', close);
};
}, handleKeyDown);
const { appInfo = { base64Icon: thumb } } = data;
return (
<kitContext.Provider value={{ ...context, ...data, values }}>
<AnimatedVisibility visibility={AnimatedVisibility.UNHIDING}>
<Modal open id={id} ref={ref}>
<Modal.Header>
{/* <Modal.Thumb url={`api/apps/${ context.appId }/icon`} /> */}
<Modal.Thumb title={appInfo.name} url={appInfo.base64Icon} />
<Modal.Thumb url={getURL(`/api/apps/${ data.appId }/icon`)} />
<Modal.Title>{textParser([title])}</Modal.Title>
<Modal.Close tabIndex={-1} onClick={onClose} />
</Modal.Header>

Loading…
Cancel
Save