Add support for referencing on frontend; updated Readme

This commit is contained in:
Vladyslav Matsiiako
2022-11-25 01:04:07 -05:00
parent d21bb11712
commit f2a9544bbc
5 changed files with 82 additions and 39 deletions

BIN
.github/images/star-infisical.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -7,6 +7,7 @@
</p> </p>
<h4 align="center"> <h4 align="center">
<a href="https://join.slack.com/t/infisical-users/shared_invite/zt-1kdbk07ro-RtoyEt_9E~fyzGo_xQYP6g">Slack</a> |
<a href="https://infisical.com/signup">Infisical Cloud</a> | <a href="https://infisical.com/signup">Infisical Cloud</a> |
<a href="https://infisical.com/docs/self-hosting/overview">Self-Hosting</a> | <a href="https://infisical.com/docs/self-hosting/overview">Self-Hosting</a> |
<a href="https://infisical.com/docs/gettingStarted">Docs</a> | <a href="https://infisical.com/docs/gettingStarted">Docs</a> |
@@ -20,7 +21,7 @@
<a href="https://github.com/infisical/infisical/blob/main/CONTRIBUTING.md"> <a href="https://github.com/infisical/infisical/blob/main/CONTRIBUTING.md">
<img src="https://img.shields.io/badge/PRs-Welcome-brightgreen" alt="PRs welcome!" /> <img src="https://img.shields.io/badge/PRs-Welcome-brightgreen" alt="PRs welcome!" />
</a> </a>
<a href="https://join.slack.com/t/infisical/shared_invite/zt-1dgg63ln8-G7PCNJdCymAT9YF3j1ewVA"> <a href="https://join.slack.com/t/infisical-users/shared_invite/zt-1kdbk07ro-RtoyEt_9E~fyzGo_xQYP6g">
<img src="https://img.shields.io/badge/chat-on%20Slack-blueviolet" alt="Slack community channel" /> <img src="https://img.shields.io/badge/chat-on%20Slack-blueviolet" alt="Slack community channel" />
</a> </a>
</h4> </h4>
@@ -48,6 +49,12 @@ And more.
To quickly get started, visit our [get started guide](https://infisical.com/docs/getting-started/introduction). To quickly get started, visit our [get started guide](https://infisical.com/docs/getting-started/introduction).
## Stay Up-to-Date
Infisical officially launched as v.1.0 on November 21st, 2022. However, a lot of new features are coming very quickly. Watch **releases** of this repository to be notified about future updates:
![infisical-star-github]()
## What's cool about this? ## What's cool about this?
Infisical is simple, E2EE, and (soon to be) complete. Infisical is simple, E2EE, and (soon to be) complete.

View File

@@ -4,48 +4,90 @@ import { faCircle } from "@fortawesome/free-solid-svg-icons";
import guidGenerator from "../utilities/randomId"; import guidGenerator from "../utilities/randomId";
const DashboardInputField = ({label, index, onChangeHandler, type, value, placeholder, isRequired, blurred, isStatic}) => { /**
if (isStatic === true) { * This function splits the input of a dashboard field into the parts that are inside and outside of ${...}
return ( * @param {*} text - the value of the input in the Dashboard Input Field
<div className="flex flex-col my-2 md:my-4 justify-center w-full max-w-md"> * @returns
<p className="text-sm font-semibold text-gray-400 mb-0.5"> */
{label} const findReferences = (text) => {
</p> var splitText = text.split('${');
{text && ( let textArray = [splitText[0]];
<p className="text-xs text-gray-400 mb-2">{text}</p> for (var i = 1; i < splitText.length; i++) {
)} let insideBrackets = "${" + splitText[i].split('}')[0]
<input if (splitText[i].includes('}')) {
onChange={(e) => console.log(e.target.value, index)} insideBrackets += "}"
type={type} }
placeholder={placeholder} textArray.push(insideBrackets)
value={value} textArray.push(splitText[i].split('}')[1])
required={isRequired} }
className="bg-bunker-800 text-gray-400 border border-gray-600 rounded-md text-md p-2 w-full min-w-16 outline-none" return textArray;
readOnly }
/>
</div> /**
); * This component renders the input fields on the dashboard
} else { * @param {*} index - the order number of a keyPair
* @param {*} onChangeHandler - what happens when the input is modified
* @param {*} type - whether the input field is for a Key Name or for a Key Value
* @param {*} value - value of the InputField
* @param {*} blurred - whether the input field should be blurred (behind the gray dots) or not; this can be turned on/off in the dashboard
* @returns
*/
const DashboardInputField = ({index, onChangeHandler, type, value, blurred}) => {
if (type === "varName") {
return ( return (
<div className="flex-col w-full"> <div className="flex-col w-full">
<div <div
className={`group flex flex-col justify-center w-full max-w-2xl border border-mineshaft-500 rounded-md`} className={`group relative flex flex-col justify-center w-full max-w-2xl border border-mineshaft-500 rounded-md`}
> >
<input <input
onChange={(e) => onChangeHandler(e.target.value, index)} onChange={(e) => onChangeHandler(e.target.value, index)}
type={type} type={type}
placeholder={placeholder}
value={value} value={value}
required={isRequired} className="asolute z-10 peer font-mono ph-no-capture bg-bunker-800 rounded-md caret-white text-gray-400 text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-200"
className={`${
blurred
? "text-bunker-800 group-hover:text-gray-400 focus:text-gray-400 active:text-gray-400"
: ""
} peer ph-no-capture bg-bunker-800 rounded-md text-gray-400 text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-200`}
spellCheck="false" spellCheck="false"
/> />
</div>
</div>
);
} else if (type === "value") {
return (
<div className="flex-col w-full">
<div
className={`group relative flex flex-col justify-center w-full max-w-2xl border border-mineshaft-500 rounded-md`}
>
<input
onChange={(e) => onChangeHandler(e.target.value, index)}
type={type}
value={value}
className={`${
blurred
? "text-transparent group-hover:text-transparent focus:text-transparent active:text-transparent"
: ""
} asolute z-10 peer font-mono ph-no-capture bg-transparent rounded-md caret-white text-transparent text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-200`}
spellCheck="false"
/>
<div
className={`${
blurred
? "text-bunker-800 group-hover:text-gray-400 peer-focus:text-gray-400 peer-active:text-gray-400"
: ""
} flex flex-row font-mono absolute z-0 ph-no-capture bg-bunker-800 rounded-md text-gray-400 text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-100`}
>
{findReferences(value).map((text, id) =>
id % 2 == 0 || text.length <= 2
? <span className="ph-no-capture">{text}</span>
: <span className="ph-no-capture text-yellow">
{text.slice(0, 2)}
<span className="ph-no-capture text-yellow-200/80">
{text.slice(2, text.length - 1)}
</span>
{text.slice(text.length - 1, text.length) == "}"
? <span className="ph-no-capture text-yellow">{text.slice(text.length - 1, text.length)} </span>
: <span className="ph-no-capture text-yellow-400">{text.slice(text.length - 1, text.length)} </span>}
</span>)}
</div>
{blurred && ( {blurred && (
<div className="peer pr-24 group-hover:hidden peer-hover:hidden peer-focus:hidden peer-active:invisible absolute h-10 w-fit max-w-xl rounded-md flex items-center text-gray-400/50 text-clip overflow-hidden"> <div className="z-20 peer pr-2 bg-bunker-800 group-hover:hidden peer-hover:hidden peer-focus:hidden peer-active:invisible absolute h-9 w-fit max-w-xl rounded-md flex items-center text-gray-400/50 text-clip overflow-hidden">
<p className="ml-2"></p> <p className="ml-2"></p>
{value {value
.split("") .split("")

View File

@@ -111,7 +111,7 @@ function generateBackupPDF(personalName, personalEmail, generatedKey) {
doc.text( doc.text(
180, 180,
420, 420,
"https://infisical.com/login" "https://app.infisical.com/login"
); );
doc.text( doc.text(
180, 180,

View File

@@ -45,26 +45,20 @@ const KeyPair = ({ keyPair, deleteRow, modifyKey, modifyValue, modifyVisibility,
<div className="min-w-xl w-96"> <div className="min-w-xl w-96">
<div className="flex items-center md:px-1 rounded-lg mt-4 md:mt-0 max-h-10"> <div className="flex items-center md:px-1 rounded-lg mt-4 md:mt-0 max-h-10">
<DashboardInputField <DashboardInputField
label=""
onChangeHandler={modifyKey} onChangeHandler={modifyKey}
type="varName" type="varName"
index={keyPair[1]} index={keyPair[1]}
value={keyPair[2]} value={keyPair[2]}
placeholder=""
isRequired
/> />
</div> </div>
</div> </div>
<div className="w-full min-w-5xl"> <div className="w-full min-w-5xl">
<div className="flex min-w-7xl items-center pl-1 pr-1.5 rounded-lg mt-4 md:mt-0 max-h-10 "> <div className="flex min-w-7xl items-center pl-1 pr-1.5 rounded-lg mt-4 md:mt-0 max-h-10 ">
<DashboardInputField <DashboardInputField
label=""
onChangeHandler={modifyValue} onChangeHandler={modifyValue}
type="value" type="value"
index={keyPair[1]} index={keyPair[1]}
value={keyPair[3]} value={keyPair[3]}
placeholder=""
isRequired
blurred={isBlurred} blurred={isBlurred}
/> />
</div> </div>