import { useState } from 'react'; import Image from 'next/image'; import { useTranslation } from "next-i18next"; import { faX } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import SecretVersionList from 'ee/components/SecretVersionList'; import Button from '../basic/buttons/Button'; import Toggle from '../basic/Toggle'; import CommentField from './CommentField'; import DashboardInputField from './DashboardInputField'; import { DeleteActionButton } from './DeleteActionButton'; import GenerateSecretMenu from './GenerateSecretMenu'; interface SecretProps { key: string; value: string; pos: number; type: string; id: string; comment: string; } interface OverrideProps { id: string; keyName: string; value: string; pos: number; comment: string; } export interface DeleteRowFunctionProps { ids: string[]; secretName: string; } interface SideBarProps { toggleSidebar: (value: string) => void; data: SecretProps[]; modifyKey: (value: string, position: number) => void; modifyValue: (value: string, position: number) => void; modifyComment: (value: string, position: number) => void; addOverride: (value: OverrideProps) => void; deleteOverride: (id: string) => void; buttonReady: boolean; savePush: () => void; sharedToHide: string[]; setSharedToHide: (values: string[]) => void; deleteRow: (props: DeleteRowFunctionProps) => void; } /** * @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.addOverride - override a certain secret * @param {function} obj.deleteOverride - delete the personal override for a certain secret * @param {boolean} obj.buttonReady - is the button for saving chagnes active * @param {function} obj.savePush - save changes andp ush secrets * @param {string[]} obj.sharedToHide - an array of shared secrets that we want to hide visually because they are overriden. * @param {function} obj.setSharedToHide - a function that updates the array of secrets that we want to hide visually * @param {function} obj.deleteRow - a function to delete a certain keyPair * @returns the sidebar with 'secret's settings' */ const SideBar = ({ toggleSidebar, data, modifyKey, modifyValue, modifyComment, addOverride, deleteOverride, buttonReady, savePush, sharedToHide, setSharedToHide, deleteRow }: SideBarProps) => { const [isLoading, setIsLoading] = useState(false); const [overrideEnabled, setOverrideEnabled] = useState(data.map(secret => secret.type).includes("personal")); const { t } = useTranslation(); return
{t("dashboard:sidebar.secret")}
{t("dashboard:sidebar.key")}
{t("dashboard:sidebar.value")}
{t("dashboard:sidebar.override")}