Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -16,17 +16,17 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import url from 'url';
|
||||
import { RoomMember } from 'matrix-js-sdk/src/models/room-member';
|
||||
import React from "react";
|
||||
import url from "url";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
|
||||
import { _t } from '../../../languageHandler';
|
||||
import SdkConfig from '../../../SdkConfig';
|
||||
import { _t } from "../../../languageHandler";
|
||||
import SdkConfig from "../../../SdkConfig";
|
||||
import WidgetUtils from "../../../utils/WidgetUtils";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import MemberAvatar from '../avatars/MemberAvatar';
|
||||
import BaseAvatar from '../avatars/BaseAvatar';
|
||||
import AccessibleButton from './AccessibleButton';
|
||||
import MemberAvatar from "../avatars/MemberAvatar";
|
||||
import BaseAvatar from "../avatars/BaseAvatar";
|
||||
import AccessibleButton from "./AccessibleButton";
|
||||
import TextWithTooltip from "./TextWithTooltip";
|
||||
|
||||
interface IProps {
|
||||
|
@ -68,14 +68,14 @@ export default class AppPermission extends React.Component<IProps, IState> {
|
|||
};
|
||||
}
|
||||
|
||||
private parseWidgetUrl(): { isWrapped: boolean, widgetDomain: string } {
|
||||
private parseWidgetUrl(): { isWrapped: boolean; widgetDomain: string } {
|
||||
const widgetUrl = url.parse(this.props.url);
|
||||
const params = new URLSearchParams(widgetUrl.search);
|
||||
|
||||
// HACK: We're relying on the query params when we should be relying on the widget's `data`.
|
||||
// This is a workaround for Scalar.
|
||||
if (WidgetUtils.isScalarUrl(this.props.url) && params && params.get('url')) {
|
||||
const unwrappedUrl = url.parse(params.get('url'));
|
||||
if (WidgetUtils.isScalarUrl(this.props.url) && params && params.get("url")) {
|
||||
const unwrappedUrl = url.parse(params.get("url"));
|
||||
return {
|
||||
widgetDomain: unwrappedUrl.host || unwrappedUrl.hostname,
|
||||
isWrapped: true,
|
||||
|
@ -94,58 +94,67 @@ export default class AppPermission extends React.Component<IProps, IState> {
|
|||
const displayName = this.state.roomMember ? this.state.roomMember.name : this.props.creatorUserId;
|
||||
const userId = displayName === this.props.creatorUserId ? null : this.props.creatorUserId;
|
||||
|
||||
const avatar = this.state.roomMember
|
||||
? <MemberAvatar member={this.state.roomMember} width={38} height={38} />
|
||||
: <BaseAvatar name={this.props.creatorUserId} width={38} height={38} />;
|
||||
const avatar = this.state.roomMember ? (
|
||||
<MemberAvatar member={this.state.roomMember} width={38} height={38} />
|
||||
) : (
|
||||
<BaseAvatar name={this.props.creatorUserId} width={38} height={38} />
|
||||
);
|
||||
|
||||
const warningTooltipText = (
|
||||
<div>
|
||||
{ _t("Any of the following data may be shared:") }
|
||||
{_t("Any of the following data may be shared:")}
|
||||
<ul>
|
||||
<li>{ _t("Your display name") }</li>
|
||||
<li>{ _t("Your avatar URL") }</li>
|
||||
<li>{ _t("Your user ID") }</li>
|
||||
<li>{ _t("Your theme") }</li>
|
||||
<li>{ _t("%(brand)s URL", { brand }) }</li>
|
||||
<li>{ _t("Room ID") }</li>
|
||||
<li>{ _t("Widget ID") }</li>
|
||||
<li>{_t("Your display name")}</li>
|
||||
<li>{_t("Your avatar URL")}</li>
|
||||
<li>{_t("Your user ID")}</li>
|
||||
<li>{_t("Your theme")}</li>
|
||||
<li>{_t("%(brand)s URL", { brand })}</li>
|
||||
<li>{_t("Room ID")}</li>
|
||||
<li>{_t("Widget ID")}</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
const warningTooltip = (
|
||||
<TextWithTooltip tooltip={warningTooltipText} tooltipClass='mx_AppPermissionWarning_tooltip mx_Tooltip_dark'>
|
||||
<span className='mx_AppPermissionWarning_helpIcon' />
|
||||
<TextWithTooltip
|
||||
tooltip={warningTooltipText}
|
||||
tooltipClass="mx_AppPermissionWarning_tooltip mx_Tooltip_dark"
|
||||
>
|
||||
<span className="mx_AppPermissionWarning_helpIcon" />
|
||||
</TextWithTooltip>
|
||||
);
|
||||
|
||||
// Due to i18n limitations, we can't dedupe the code for variables in these two messages.
|
||||
const warning = this.state.isWrapped
|
||||
? _t("Using this widget may share data <helpIcon /> with %(widgetDomain)s & your integration manager.",
|
||||
{ widgetDomain: this.state.widgetDomain }, { helpIcon: () => warningTooltip })
|
||||
: _t("Using this widget may share data <helpIcon /> with %(widgetDomain)s.",
|
||||
{ widgetDomain: this.state.widgetDomain }, { helpIcon: () => warningTooltip });
|
||||
? _t(
|
||||
"Using this widget may share data <helpIcon /> with %(widgetDomain)s & your integration manager.",
|
||||
{ widgetDomain: this.state.widgetDomain },
|
||||
{ helpIcon: () => warningTooltip },
|
||||
)
|
||||
: _t(
|
||||
"Using this widget may share data <helpIcon /> with %(widgetDomain)s.",
|
||||
{ widgetDomain: this.state.widgetDomain },
|
||||
{ helpIcon: () => warningTooltip },
|
||||
);
|
||||
|
||||
const encryptionWarning = this.props.isRoomEncrypted ? _t("Widgets do not use message encryption.") : null;
|
||||
|
||||
return (
|
||||
<div className='mx_AppPermissionWarning'>
|
||||
<div className='mx_AppPermissionWarning_row mx_AppPermissionWarning_bolder mx_AppPermissionWarning_smallText'>
|
||||
{ _t("Widget added by") }
|
||||
<div className="mx_AppPermissionWarning">
|
||||
<div className="mx_AppPermissionWarning_row mx_AppPermissionWarning_bolder mx_AppPermissionWarning_smallText">
|
||||
{_t("Widget added by")}
|
||||
</div>
|
||||
<div className='mx_AppPermissionWarning_row'>
|
||||
{ avatar }
|
||||
<h4 className='mx_AppPermissionWarning_bolder'>{ displayName }</h4>
|
||||
<div className='mx_AppPermissionWarning_smallText'>{ userId }</div>
|
||||
<div className="mx_AppPermissionWarning_row">
|
||||
{avatar}
|
||||
<h4 className="mx_AppPermissionWarning_bolder">{displayName}</h4>
|
||||
<div className="mx_AppPermissionWarning_smallText">{userId}</div>
|
||||
</div>
|
||||
<div className='mx_AppPermissionWarning_row mx_AppPermissionWarning_smallText'>
|
||||
{ warning }
|
||||
<div className="mx_AppPermissionWarning_row mx_AppPermissionWarning_smallText">{warning}</div>
|
||||
<div className="mx_AppPermissionWarning_row mx_AppPermissionWarning_smallText">
|
||||
{_t("This widget may use cookies.")} {encryptionWarning}
|
||||
</div>
|
||||
<div className='mx_AppPermissionWarning_row mx_AppPermissionWarning_smallText'>
|
||||
{ _t("This widget may use cookies.") } { encryptionWarning }
|
||||
</div>
|
||||
<div className='mx_AppPermissionWarning_row'>
|
||||
<AccessibleButton kind='primary_sm' onClick={this.props.onPermissionGranted}>
|
||||
{ _t("Continue") }
|
||||
<div className="mx_AppPermissionWarning_row">
|
||||
<AccessibleButton kind="primary_sm" onClick={this.props.onPermissionGranted}>
|
||||
{_t("Continue")}
|
||||
</AccessibleButton>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue