Skip to content

Commit 2a096be

Browse files
author
FalkWolsky
committed
API Key to clipboard extension
1 parent 58b4d82 commit 2a096be

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

client/packages/lowcoder/src/i18n/locales/de.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,7 @@ export const de: typeof en = {
22662266
"createApiKey": "API-Schlüssel erstellen",
22672267
"apiKeyName": "Name",
22682268
"apiKeyDescription": "Beschreibung",
2269+
"apiKeyCopy": "Klicke auf den API Schlüssel um den Key in die Zwischenablage zu kopieren",
22692270
"apiKey": "API-Schlüssel",
22702271
"deleteApiKey": "API-Schlüssel löschen",
22712272
"deleteApiKeyContent": "Sind Sie sicher, dass Sie diesen API-Schlüssel löschen möchten?",
@@ -2791,7 +2792,7 @@ export const de: typeof en = {
27912792
"none": "Keine",
27922793
"formPlaceholder": "Bitte {label} eingeben",
27932794
"formSelectPlaceholder": "Bitte wähle das {label}",
2794-
"saveSuccess": "Erfolgreich gerettet",
2795+
"saveSuccess": "Erfolgreich gespeichert",
27952796
"dangerLabel": "Gefahrenzone",
27962797
"dangerTip": "Die Deaktivierung dieses ID-Anbieters kann dazu führen, dass sich einige Nutzer nicht mehr anmelden können. Gehe mit Vorsicht vor.",
27972798
"disable": "Deaktivieren",

client/packages/lowcoder/src/i18n/locales/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,7 @@ export const en = {
23192319
"createApiKey": "Create API Key",
23202320
"apiKeyName": "Name",
23212321
"apiKeyDescription": "Description",
2322+
"apiKeyCopy": "Click the Api Key to get the value in your clipboard",
23222323
"apiKey": "API Key",
23232324
"deleteApiKey": "Delete API Key",
23242325
"deleteApiKeyContent": "Are you sure you want to delete this API key?",

client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ export function UserProfileLayout(props: UserProfileLayoutProps) {
315315
</Space>
316316
</Card>
317317

318+
<UserApiKeysCard />
319+
318320
<Card style={{ marginBottom: "20px" }}>
319321
<Title level={4}>{trans("profile.info")}</Title>
320322
<Space direction="horizontal" size={10}>
@@ -395,7 +397,7 @@ export function UserProfileLayout(props: UserProfileLayoutProps) {
395397
</Space>
396398
</Card>
397399

398-
<UserApiKeysCard />
400+
399401

400402
</ProfileView>
401403
</ContentWrapper>

client/packages/lowcoder/src/pages/ApplicationV2/components/UserApiKeysCard.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Card from "antd/es/card";
33
import Flex from "antd/es/flex";
44
import Title from "antd/es/typography/Title";
55
import Table from "antd/es/table";
6+
import Tooltip from "antd/es/tooltip";
67
import { useDispatch, useSelector } from "react-redux";
78
import { useState } from "react";
89
import { styled } from "styled-components";
@@ -41,6 +42,14 @@ export default function UserApiKeysCard() {
4142
const apiKeys = useSelector(getApiKeys);
4243
const [modalVisible, setModalVisible] = useState(false);
4344

45+
const handleCopy = (value: string) => {
46+
navigator.clipboard.writeText(value).then(() => {
47+
messageInstance.success('Copied to clipboard!');
48+
}).catch(err => {
49+
messageInstance.error('Failed to copy!');
50+
});
51+
};
52+
4453
return (
4554
<>
4655
<Card style={{ marginBottom: "20px" }}>
@@ -89,9 +98,11 @@ export default function UserApiKeysCard() {
8998
const startToken = value.substring(0, 6);
9099
const endToken = value.substring(value.length - 6);
91100
return (
92-
<>
93-
{ `${startToken}********************${endToken}`}
94-
</>
101+
<Tooltip placement="topLeft" title={ trans("profile.apiKeyCopy")}>
102+
<div onClick={() => handleCopy(value)} style={{ cursor: 'pointer' }}>
103+
{`${startToken}********************${endToken}`}
104+
</div>
105+
</Tooltip>
95106
)
96107
}
97108
},

0 commit comments

Comments
 (0)