Restore "Stream Key Button (#7127)" + lint and modifications
- Consolidate functionality into existing component. - Use proper strings.
This commit is contained in:
parent
8bc8c4bcae
commit
6658217865
4 changed files with 38 additions and 22 deletions
|
@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Clicking on the title of a floating player will take you back to the list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
- Clicking on the title of a floating player will take you back to the list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||||
- Fix floating player stopping on markdown or image files ([#7073](https://github.com/lbryio/lbry-desktop/pull/7073))
|
- Fix floating player stopping on markdown or image files ([#7073](https://github.com/lbryio/lbry-desktop/pull/7073))
|
||||||
- Fix list thumbnail upload ([#7074](https://github.com/lbryio/lbry-desktop/pull/7074))
|
- Fix list thumbnail upload ([#7074](https://github.com/lbryio/lbry-desktop/pull/7074))
|
||||||
|
- Stream Key is now hidden _community pr!_ ([#7127](https://github.com/lbryio/lbry-desktop/pull/7127))
|
||||||
|
|
||||||
## [0.51.2] - [2021-08-20]
|
## [0.51.2] - [2021-08-20]
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,9 @@
|
||||||
"View": "View",
|
"View": "View",
|
||||||
"Edit": "Edit",
|
"Edit": "Edit",
|
||||||
"Copied": "Copied",
|
"Copied": "Copied",
|
||||||
|
"Copied stream key.": "Copied stream key.",
|
||||||
|
"Copied stream server URL.": "Copied stream server URL.",
|
||||||
|
"Failed to copy.": "Failed to copy.",
|
||||||
"The publisher has chosen to charge %lbc% to view this content. Your balance is currently too low to view it. Check out %reward_link% for free %lbc% or send more %lbc% to your wallet. You can also %buy_link% more %lbc%.": "The publisher has chosen to charge %lbc% to view this content. Your balance is currently too low to view it. Check out %reward_link% for free %lbc% or send more %lbc% to your wallet. You can also %buy_link% more %lbc%.",
|
"The publisher has chosen to charge %lbc% to view this content. Your balance is currently too low to view it. Check out %reward_link% for free %lbc% or send more %lbc% to your wallet. You can also %buy_link% more %lbc%.": "The publisher has chosen to charge %lbc% to view this content. Your balance is currently too low to view it. Check out %reward_link% for free %lbc% or send more %lbc% to your wallet. You can also %buy_link% more %lbc%.",
|
||||||
"Connecting...": "Connecting...",
|
"Connecting...": "Connecting...",
|
||||||
"Comments": "Comments",
|
"Comments": "Comments",
|
||||||
|
|
|
@ -12,23 +12,38 @@ type Props = {
|
||||||
primaryButton?: boolean,
|
primaryButton?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
onCopy?: (string) => string,
|
onCopy?: (string) => string,
|
||||||
|
enableInputMask?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CopyableText(props: Props) {
|
export default function CopyableText(props: Props) {
|
||||||
const { copyable, doToast, snackMessage, label, primaryButton = false, name, onCopy } = props;
|
const { copyable, doToast, snackMessage, label, primaryButton = false, name, onCopy, enableInputMask } = props;
|
||||||
|
const [maskInput, setMaskInput] = React.useState(enableInputMask);
|
||||||
|
|
||||||
const input = useRef();
|
const input = useRef();
|
||||||
|
|
||||||
function copyToClipboard() {
|
function handleCopyText() {
|
||||||
const topRef = input.current;
|
if (enableInputMask) {
|
||||||
if (topRef && topRef.input && topRef.input.current) {
|
navigator.clipboard
|
||||||
topRef.input.current.select();
|
.writeText(copyable)
|
||||||
if (onCopy) {
|
.then(() => {
|
||||||
onCopy(topRef.input.current);
|
doToast({ message: snackMessage || __('Text copied') });
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
doToast({ message: __('Failed to copy.'), isError: true });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const topRef = input.current;
|
||||||
|
if (topRef && topRef.input && topRef.input.current) {
|
||||||
|
topRef.input.current.select();
|
||||||
|
if (onCopy) {
|
||||||
|
// Allow clients to change the selection before making the copy.
|
||||||
|
onCopy(topRef.input.current);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
|
doToast({ message: snackMessage || __('Text copied') });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFocus() {
|
function onFocus() {
|
||||||
|
@ -41,7 +56,7 @@ export default function CopyableText(props: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormField
|
<FormField
|
||||||
type="text"
|
type={maskInput ? 'password' : 'text'}
|
||||||
className="form-field--copyable"
|
className="form-field--copyable"
|
||||||
readOnly
|
readOnly
|
||||||
name={name}
|
name={name}
|
||||||
|
@ -50,16 +65,12 @@ export default function CopyableText(props: Props) {
|
||||||
ref={input}
|
ref={input}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
inputButton={
|
inputButton={
|
||||||
<Button
|
<Button button={primaryButton ? 'primary' : 'secondary'} icon={ICONS.COPY} onClick={handleCopyText} />
|
||||||
button={primaryButton ? 'primary' : 'secondary'}
|
}
|
||||||
icon={ICONS.COPY}
|
helper={
|
||||||
onClick={() => {
|
enableInputMask && (
|
||||||
copyToClipboard();
|
<Button button="link" onClick={() => setMaskInput(!maskInput)} label={maskInput ? __('Show') : __('Hide')} />
|
||||||
doToast({
|
)
|
||||||
message: snackMessage || __('Text copied'),
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -184,14 +184,15 @@ export default function LivestreamSetupPage(props: Props) {
|
||||||
name="stream-server"
|
name="stream-server"
|
||||||
label={__('Stream server')}
|
label={__('Stream server')}
|
||||||
copyable={LIVESTREAM_RTMP_URL}
|
copyable={LIVESTREAM_RTMP_URL}
|
||||||
snackMessage={__('Copied')}
|
snackMessage={__('Copied stream server URL.')}
|
||||||
/>
|
/>
|
||||||
<CopyableText
|
<CopyableText
|
||||||
primaryButton
|
primaryButton
|
||||||
|
enableInputMask
|
||||||
name="livestream-key"
|
name="livestream-key"
|
||||||
label={__('Stream key')}
|
label={__('Stream key')}
|
||||||
copyable={streamKey}
|
copyable={streamKey}
|
||||||
snackMessage={__('Copied')}
|
snackMessage={__('Copied stream key.')}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue