diff --git a/packages/client/src/lib.js b/packages/client/src/lib.js index 3d9b21127e..872be3c80a 100644 --- a/packages/client/src/lib.js +++ b/packages/client/src/lib.js @@ -41,6 +41,8 @@ const RATE_LIMIT_PERIOD = 10 * 1000 /** @typedef { import('./lib/interface.js').API } API */ /** @typedef { import('./lib/interface.js').Status} Status */ /** @typedef { import('./lib/interface.js').Upload} Upload */ +/** @typedef { import('./lib/interface.js').Deal} Deal */ +/** @typedef { import('./lib/interface.js').Pin} Pin */ /** @typedef { import('./lib/interface.js').Service } Service */ /** @typedef { import('./lib/interface.js').Web3File} Web3File */ /** @typedef { import('./lib/interface.js').Filelike } Filelike */ diff --git a/packages/website/components/account/fileUploader/fileUploader.js b/packages/website/components/account/fileUploader/fileUploader.js index 7310ff1fdc..7b4773cf34 100644 --- a/packages/website/components/account/fileUploader/fileUploader.js +++ b/packages/website/components/account/fileUploader/fileUploader.js @@ -87,7 +87,6 @@ const FileUploader = ({ className = '', content, uploadModalState, background }) }; useEffect(() => { const acceptedTermsLocalStorage = localStorage.getItem('acceptedTerms'); - console.log(acceptedTermsLocalStorage); if (acceptedTermsLocalStorage) setHasAcceptedTerms(true); }, []); diff --git a/packages/website/components/account/filesManager/cellRendererComponents/cidCell.js b/packages/website/components/account/filesManager/cellRendererComponents/cidCell.js new file mode 100644 index 0000000000..11c8597e90 --- /dev/null +++ b/packages/website/components/account/filesManager/cellRendererComponents/cidCell.js @@ -0,0 +1,33 @@ +import { useMemo } from 'react'; + +import CopyIcon from 'assets/icons/copy'; +import { addTextToClipboard, truncateString } from 'lib/utils'; + +/** + * @type {import('react').FC} + * Used to render a checkbox cell within a table component. + * @param {Object} props + * @param {string} props.cid the CID of the upload. + * @param {string} props.gatewayPrefix the gateway prefix used for linking to the file in a gateway. + * @returns + */ +function CidCellRenderer({ cid, gatewayPrefix }) { + const truncatedCID = useMemo(() => truncateString(cid, 5, '...', 'double'), [cid]); + return ( + + + {truncatedCID} + + + + ); +} + +export default CidCellRenderer; diff --git a/packages/website/components/account/filesManager/cellRendererComponents/editUploadNameCell.js b/packages/website/components/account/filesManager/cellRendererComponents/editUploadNameCell.js new file mode 100644 index 0000000000..66ff9d5dce --- /dev/null +++ b/packages/website/components/account/filesManager/cellRendererComponents/editUploadNameCell.js @@ -0,0 +1,92 @@ +import { useRef, useState } from 'react'; +import clsx from 'clsx'; + +import PencilIcon from 'assets/icons/pencil'; +import Loading from 'components/loading/loading'; + +/** + * @type {import('react').FC} + * @param {Object} props + * @param {string} props.name Name of the upload. + * @param {string} props.cid CID of the upload. + * @param {function} props.onNameEdit On edit callback. + * @param {function} props.renameUploadAction Async method to call to rename the upload. + * @returns + */ +function EditUploadNameRenderer({ name, cid, onNameEdit, renameUploadAction }) { + const [isEditingName, setIsEditingName] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [editError, setEditError] = useState(''); + + /** @type {import('react').RefObject} */ + const textAreaInput = useRef(null); + + const toggleEdit = () => { + setIsEditingName(!isEditingName); + }; + + const saveNewName = async (oldName, cid) => { + const newName = textAreaInput.current?.value; + + setIsLoading(true); + + try { + await renameUploadAction(cid, newName); + } catch (error) { + setEditError('Unable to set name.'); + } + + if (editError) { + setEditError(''); + } + + setIsLoading(false); + toggleEdit(); + onNameEdit(); + }; + + return ( +
+
+ {/* {'fileRowLabels.name.label'} */} + {!isEditingName ? ( + {name} + ) : ( + +