/* eslint-disable react/no-unused-prop-types */ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import Image from 'next/image'; import { faXmark } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import SecretVersionList from '@app/ee/components/SecretVersionList'; import { WorkspaceEnv } from '@app/hooks/api/types'; import Button from '../basic/buttons/Button'; import Toggle from '../basic/Toggle'; import CommentField from './CommentField'; import CompareSecretsModal from './CompareSecretsModal'; import DashboardInputField from './DashboardInputField'; import { DeleteActionButton } from './DeleteActionButton'; import GenerateSecretMenu from './GenerateSecretMenu'; interface SecretProps { key: string; value: string | undefined; valueOverride: string | undefined; pos: number; id: string; comment: string; } export interface DeleteRowFunctionProps { ids: string[]; secretName: string; } interface SideBarProps { toggleSidebar: (value: string) => void; data: SecretProps[]; modifyKey: (value: string, id: string) => void; modifyValue: (value: string, id: string) => void; modifyValueOverride: (value: string | undefined, id: string) => void; modifyComment: (value: string, id: string) => void; buttonReady: boolean; savePush: () => void; sharedToHide: string[]; setSharedToHide: (values: string[]) => void; deleteRow: (props: DeleteRowFunctionProps) => void; workspaceEnvs: WorkspaceEnv[]; selectedEnv: WorkspaceEnv; workspaceId: string; } /** * @param {object} obj * @param {function} obj.toggleSidebar - function that opens or closes the sidebar * @param {SecretProps[]} obj.data - data of a certain key valeu pair * @param {function} obj.modifyKey - function that modifies the secret key * @param {function} obj.modifyValue - function that modifies the secret value * @param {function} obj.modifyValueOverride - function that modifies the secret value if it is an override * @param {boolean} obj.buttonReady - is the button for saving chagnes active * @param {function} obj.savePush - save changes andp ush secrets * @param {function} obj.deleteRow - a function to delete a certain keyPair * @returns the sidebar with 'secret's settings' */ const SideBar = ({ toggleSidebar, data, modifyKey, modifyValue, modifyValueOverride, modifyComment, buttonReady, savePush, deleteRow, workspaceEnvs, selectedEnv, workspaceId }: SideBarProps) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [isLoading, setIsLoading] = useState(false); const [overrideEnabled, setOverrideEnabled] = useState(data[0]?.valueOverride !== undefined); const [compareModal, setCompareModal] = useState(false); const { t } = useTranslation(); return (
{isLoading ? (
infisical loading indicator
) : (

{t('dashboard.sidebar.secret')}

null} role="button" tabIndex={0} className="p-1" onClick={() => toggleSidebar('None')} >

{t('dashboard.sidebar.key')}

{data[0]?.value || data[0]?.value === '' ? (

{t('dashboard.sidebar.value')}

) : (
{t('common.note')}: {t('dashboard.sidebar.personal-explanation')}
)}
{(data[0]?.value || data[0]?.value === '') && (

{t('dashboard.sidebar.override')}

)}
)}
); }; export default SideBar;