Add copy buttons for event & room ID (#8302)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
511965b840
commit
2b91ed1084
3 changed files with 26 additions and 9 deletions
|
@ -18,13 +18,16 @@ limitations under the License.
|
||||||
.mx_CopyableText {
|
.mx_CopyableText {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
width: max-content;
|
||||||
|
max-width: 100%;
|
||||||
|
|
||||||
|
&.mx_CopyableText_border {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: solid 1px $light-fg-color;
|
border: solid 1px $light-fg-color;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
width: max-content;
|
}
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
.mx_CopyableText_copyButton {
|
.mx_CopyableText_copyButton {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
|
@ -167,8 +167,16 @@ export default class ViewSource extends React.Component<IProps, IState> {
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_ViewSource" onFinished={this.props.onFinished} title={_t("View Source")}>
|
<BaseDialog className="mx_ViewSource" onFinished={this.props.onFinished} title={_t("View Source")}>
|
||||||
<div>
|
<div>
|
||||||
<div>{ _t("Room ID: %(roomId)s", { roomId }) }</div>
|
<div>
|
||||||
<div>{ _t("Event ID: %(eventId)s", { eventId }) }</div>
|
<CopyableText getTextToCopy={() => roomId} border={false}>
|
||||||
|
{ _t("Room ID: %(roomId)s", { roomId }) }
|
||||||
|
</CopyableText>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<CopyableText getTextToCopy={() => eventId} border={false}>
|
||||||
|
{ _t("Event ID: %(eventId)s", { eventId }) }
|
||||||
|
</CopyableText>
|
||||||
|
</div>
|
||||||
<div className="mx_ViewSource_separator" />
|
<div className="mx_ViewSource_separator" />
|
||||||
{ isEditing ? this.editSourceContent() : this.viewSourceContent() }
|
{ isEditing ? this.editSourceContent() : this.viewSourceContent() }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import { copyPlaintext } from "../../../utils/strings";
|
import { copyPlaintext } from "../../../utils/strings";
|
||||||
|
@ -25,9 +26,10 @@ import AccessibleTooltipButton from "./AccessibleTooltipButton";
|
||||||
interface IProps {
|
interface IProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
getTextToCopy: () => string;
|
getTextToCopy: () => string;
|
||||||
|
border?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CopyableText: React.FC<IProps> = ({ children, getTextToCopy }) => {
|
const CopyableText: React.FC<IProps> = ({ children, getTextToCopy, border=true }) => {
|
||||||
const [tooltip, setTooltip] = useState<string | undefined>(undefined);
|
const [tooltip, setTooltip] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
const onCopyClickInternal = async (e: ButtonEvent) => {
|
const onCopyClickInternal = async (e: ButtonEvent) => {
|
||||||
|
@ -42,7 +44,11 @@ const CopyableText: React.FC<IProps> = ({ children, getTextToCopy }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return <div className="mx_CopyableText">
|
const className = classNames("mx_CopyableText", {
|
||||||
|
mx_CopyableText_border: border,
|
||||||
|
});
|
||||||
|
|
||||||
|
return <div className={className}>
|
||||||
{ children }
|
{ children }
|
||||||
<AccessibleTooltipButton
|
<AccessibleTooltipButton
|
||||||
title={tooltip ?? _t("Copy")}
|
title={tooltip ?? _t("Copy")}
|
||||||
|
|
Loading…
Reference in a new issue