Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uiKitText reference #20625

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions client/views/blocks/ModalBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,17 @@ import { UIKitIncomingInteractionContainerType } from '@rocket.chat/apps-engine/
import { Modal, AnimatedVisibility, ButtonGroup, Button, Box } from '@rocket.chat/fuselage';
import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks';
import { kitContext, UiKitComponent, UiKitModal, modalParser } from '@rocket.chat/fuselage-ui-kit';
import { uiKitText } from '@rocket.chat/ui-kit';
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';

import { renderMessageBody } from '../../lib/renderMessageBody';
import { getURL } from '../../../app/utils/lib/getURL';
import * as ActionManager from '../../../app/ui-message/client/ActionManager';

// TODO: move this to fuselage-ui-kit itself
modalParser.text = ({ text, type } = {}) => {
if (type !== 'mrkdwn') {
return text;
}
modalParser.plainText = ({ text } = {}) => text;

return <span dangerouslySetInnerHTML={{ __html: renderMessageBody({ msg: text }) }} />;
};

const textParser = uiKitText({
plain_text: ({ text }) => text,
text: ({ text }) => text,
});
// TODO: move this to fuselage-ui-kit itself
modalParser.mrkdwn = ({ text }) => <span dangerouslySetInnerHTML={{ __html: renderMessageBody({ msg: text }) }} />;

const focusableElementsString = `
a[href]:not([tabindex="-1"]),
Expand Down Expand Up @@ -150,7 +141,7 @@ export function ModalBlock({
<Modal open id={id} ref={ref}>
<Modal.Header>
{view.showIcon ? <Modal.Thumb url={getURL(`/api/apps/${ appId }/icon`)} /> : null}
<Modal.Title>{textParser([view.title])}</Modal.Title>
<Modal.Title>{modalParser.text(view.title)}</Modal.Title>
<Modal.Close tabIndex={-1} onClick={onClose} />
</Modal.Header>
<Modal.Content>
Expand All @@ -165,8 +156,8 @@ export function ModalBlock({
</Modal.Content>
<Modal.Footer>
<ButtonGroup align='end'>
{view.close && <Button onClick={onCancel}>{textParser([view.close.text])}</Button>}
{view.submit && <Button primary onClick={onSubmit}>{textParser([view.submit.text])}</Button>}
{view.close && <Button onClick={onCancel}>{modalParser.text(view.close.text)}</Button>}
{view.submit && <Button primary onClick={onSubmit}>{modalParser.text(view.submit.text)}</Button>}
</ButtonGroup>
</Modal.Footer>
</Modal>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.