Hide clipboard button when is not possible to copy to clipboard

pull/2292/head v1.3.2-beta.9
Matheus Horstmann 8 months ago committed by GitHub
parent 6d79e6f345
commit 452f8c12c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,24 +83,32 @@ const SettingsGeneralView: FunctionComponent = () => {
</CollapseBox> </CollapseBox>
<Text <Text
label="API Key" label="API Key"
disabled // User can copy through the clipboard button
disabled={window.isSecureContext}
// Enable user to at least copy when not in secure context
readOnly={!window.isSecureContext}
rightSectionWidth={95} rightSectionWidth={95}
rightSectionProps={{ style: { justifyContent: "flex-end" } }} rightSectionProps={{ style: { justifyContent: "flex-end" } }}
rightSection={ rightSection={
<MantineGroup spacing="xs" mx="xs" position="right"> <MantineGroup spacing="xs" mx="xs" position="right">
<Action {
label="Copy API Key" // Clipboard API is only available in secure contexts See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#interfaces
variant="light" window.isSecureContext && (
settingKey={settingApiKey} <Action
color={copied ? "green" : undefined} label="Copy API Key"
icon={copied ? faCheck : faClipboard} variant="light"
onClick={(update, value) => { settingKey={settingApiKey}
if (value) { color={copied ? "green" : undefined}
clipboard.copy(value); icon={copied ? faCheck : faClipboard}
toggleState(setCopy, 1500); onClick={(update, value) => {
} if (value) {
}} clipboard.copy(value);
></Action> toggleState(setCopy, 1500);
}
}}
/>
)
}
<Action <Action
label="Regenerate" label="Regenerate"
variant="light" variant="light"

Loading…
Cancel
Save