mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 13:28:27 +00:00
Moved project id from dashboard to settings
This commit is contained in:
@@ -86,7 +86,6 @@ export default function Dashboard() {
|
|||||||
const [isNew, setIsNew] = useState(false);
|
const [isNew, setIsNew] = useState(false);
|
||||||
const [searchKeys, setSearchKeys] = useState('');
|
const [searchKeys, setSearchKeys] = useState('');
|
||||||
const [errorDragAndDrop, setErrorDragAndDrop] = useState(false);
|
const [errorDragAndDrop, setErrorDragAndDrop] = useState(false);
|
||||||
const [projectIdCopied, setProjectIdCopied] = useState(false);
|
|
||||||
const [sortMethod, setSortMethod] = useState('alphabetical');
|
const [sortMethod, setSortMethod] = useState('alphabetical');
|
||||||
const [checkDocsPopUpVisible, setCheckDocsPopUpVisible] = useState(false);
|
const [checkDocsPopUpVisible, setCheckDocsPopUpVisible] = useState(false);
|
||||||
const [hasUserEverPushed, setHasUserEverPushed] = useState(false);
|
const [hasUserEverPushed, setHasUserEverPushed] = useState(false);
|
||||||
@@ -404,23 +403,6 @@ export default function Dashboard() {
|
|||||||
deleteRow({ids, secretName});
|
deleteRow({ids, secretName});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* This function copies the project id to the clipboard
|
|
||||||
*/
|
|
||||||
function copyToClipboard() {
|
|
||||||
const copyText = document.getElementById('myInput') as HTMLInputElement;
|
|
||||||
|
|
||||||
if (copyText) {
|
|
||||||
copyText.select();
|
|
||||||
copyText.setSelectionRange(0, 99999); // For mobile devices
|
|
||||||
|
|
||||||
navigator.clipboard.writeText(copyText.value);
|
|
||||||
|
|
||||||
setProjectIdCopied(true);
|
|
||||||
setTimeout(() => setProjectIdCopied(false), 2000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data ? (
|
return data ? (
|
||||||
<div className="bg-bunker-800 max-h-screen flex flex-col justify-between text-white">
|
<div className="bg-bunker-800 max-h-screen flex flex-col justify-between text-white">
|
||||||
<Head>
|
<Head>
|
||||||
@@ -470,33 +452,6 @@ export default function Dashboard() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<div className="flex justify-end items-center bg-white/[0.07] text-base mt-2 mr-2 rounded-md text-gray-400">
|
|
||||||
<p className="mr-2 font-bold pl-4">{`${t(
|
|
||||||
"common:project-id"
|
|
||||||
)}:`}</p>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={workspaceId}
|
|
||||||
id="myInput"
|
|
||||||
className="bg-white/0 text-gray-400 py-2 w-60 px-2 min-w-md outline-none"
|
|
||||||
disabled
|
|
||||||
></input>
|
|
||||||
<div className="group font-normal group relative inline-block text-gray-400 underline hover:text-primary duration-200">
|
|
||||||
<button
|
|
||||||
onClick={copyToClipboard}
|
|
||||||
className="pl-4 pr-4 border-l border-white/20 py-2 hover:bg-white/[0.12] duration-200"
|
|
||||||
>
|
|
||||||
{projectIdCopied ? (
|
|
||||||
<FontAwesomeIcon icon={faCheck} className="pr-0.5" />
|
|
||||||
) : (
|
|
||||||
<FontAwesomeIcon icon={faCopy} />
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
<span className="absolute hidden group-hover:flex group-hover:animate-popup duration-300 w-28 -left-8 -top-20 translate-y-full pl-3 py-2 bg-white/10 rounded-md text-center text-gray-400 text-sm">
|
|
||||||
{t("common:click-to-copy")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{(data?.length !== 0 || buttonReady) && (
|
{(data?.length !== 0 || buttonReady) && (
|
||||||
<div className={`flex justify-start max-w-sm mt-2`}>
|
<div className={`flex justify-start max-w-sm mt-2`}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { useEffect, useRef, useState } from "react";
|
|||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
import { faCheck, faPlus } from "@fortawesome/free-solid-svg-icons";
|
import { faCheck, faCopy, faPlus } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
import Button from "~/components/basic/buttons/Button";
|
import Button from "~/components/basic/buttons/Button";
|
||||||
import AddServiceTokenDialog from "~/components/basic/dialog/AddServiceTokenDialog";
|
import AddServiceTokenDialog from "~/components/basic/dialog/AddServiceTokenDialog";
|
||||||
@@ -16,6 +17,7 @@ import deleteWorkspace from "../../api/workspace/deleteWorkspace";
|
|||||||
import getWorkspaces from "../../api/workspace/getWorkspaces";
|
import getWorkspaces from "../../api/workspace/getWorkspaces";
|
||||||
import renameWorkspace from "../../api/workspace/renameWorkspace";
|
import renameWorkspace from "../../api/workspace/renameWorkspace";
|
||||||
|
|
||||||
|
|
||||||
export default function SettingsBasic() {
|
export default function SettingsBasic() {
|
||||||
const [buttonReady, setButtonReady] = useState(false);
|
const [buttonReady, setButtonReady] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -26,9 +28,28 @@ export default function SettingsBasic() {
|
|||||||
const [isAddOpen, setIsAddOpen] = useState(false);
|
const [isAddOpen, setIsAddOpen] = useState(false);
|
||||||
let [isAddServiceTokenDialogOpen, setIsAddServiceTokenDialogOpen] =
|
let [isAddServiceTokenDialogOpen, setIsAddServiceTokenDialogOpen] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
const [projectIdCopied, setProjectIdCopied] = useState(false);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function copies the project id to the clipboard
|
||||||
|
*/
|
||||||
|
function copyToClipboard() {
|
||||||
|
// const copyText = document.getElementById('myInput') as HTMLInputElement;
|
||||||
|
const copyText = document.getElementById('myInput')
|
||||||
|
|
||||||
|
if (copyText) {
|
||||||
|
copyText.select();
|
||||||
|
copyText.setSelectionRange(0, 99999); // For mobile devices
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(copyText.value);
|
||||||
|
|
||||||
|
setProjectIdCopied(true);
|
||||||
|
setTimeout(() => setProjectIdCopied(false), 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
let userWorkspaces = await getWorkspaces();
|
let userWorkspaces = await getWorkspaces();
|
||||||
userWorkspaces.map((userWorkspace) => {
|
userWorkspaces.map((userWorkspace) => {
|
||||||
@@ -169,15 +190,33 @@ export default function SettingsBasic() {
|
|||||||
{t("settings-project:docs")}
|
{t("settings-project:docs")}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<div className="max-h-28 w-ful">
|
<p className="mt-4 text-xs text-bunker-300">{t("settings-project:auto-generated")}</p>
|
||||||
<InputField
|
<div className="flex justify-end items-center bg-white/[0.07] text-base mt-2 mb-3 mr-2 rounded-md text-gray-400">
|
||||||
type="varName"
|
<p className="mr-2 font-bold pl-4">{`${t(
|
||||||
value={router.query.id}
|
"common:project-id"
|
||||||
placeholder=""
|
)}:`}</p>
|
||||||
isRequired
|
<input
|
||||||
static
|
type="text"
|
||||||
text={t("settings-project:auto-generated")}
|
value={workspaceId}
|
||||||
/>
|
id="myInput"
|
||||||
|
className="bg-white/0 text-gray-400 py-2 w-60 px-2 min-w-md outline-none"
|
||||||
|
disabled
|
||||||
|
></input>
|
||||||
|
<div className="group font-normal group relative inline-block text-gray-400 underline hover:text-primary duration-200">
|
||||||
|
<button
|
||||||
|
onClick={copyToClipboard}
|
||||||
|
className="pl-4 pr-4 border-l border-white/20 py-2 hover:bg-white/[0.12] duration-200"
|
||||||
|
>
|
||||||
|
{projectIdCopied ? (
|
||||||
|
<FontAwesomeIcon icon={faCheck} className="pr-0.5" />
|
||||||
|
) : (
|
||||||
|
<FontAwesomeIcon icon={faCopy} />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<span className="absolute hidden group-hover:flex group-hover:animate-popup duration-300 w-28 -left-8 -top-20 translate-y-full pl-3 py-2 bg-bunker-800 rounded-md text-center text-gray-400 text-sm">
|
||||||
|
{t("common:click-to-copy")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white/5 rounded-md px-6 pt-6 flex flex-col items-start flex flex-col items-start w-full mt-4 mb-4 pt-2">
|
<div className="bg-white/5 rounded-md px-6 pt-6 flex flex-col items-start flex flex-col items-start w-full mt-4 mb-4 pt-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user