The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add support for esc key when editing item in storage explorer
Joshen Lim423dab16a991
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/ConfirmDeleteModal.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/ConfirmDeleteModal.tsxindex 3ca2bf868fd..5af97f03b04 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/ConfirmDeleteModal.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/ConfirmDeleteModal.tsx@@ -47,10 +47,16 @@ const ConfirmDeleteModal: FC<Props> = ({onCancel={onSelectCancel}customFooter={<div className="flex items-center gap-2">- <Button type="default" onClick={onSelectCancel}>+ <Button type="default" disabled={deleting} onClick={onSelectCancel}>Cancel</Button>- <Button type="primary" danger loading={deleting} onClick={onConfirmDelete}>+ <Button+ type="primary"+ danger+ disabled={deleting}+ loading={deleting}+ onClick={onConfirmDelete}+ >{deleting ? 'Deleting' : 'Delete'}</Button></div>diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsxindex 84dbdb48dae..0a8b23c0ca4 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx@@ -17,21 +17,35 @@ const FileExplorerRowEditing = ({ item, view, columnIndex }: FileExplorerRowEditconst inputRef = useRef<any>(null)const [itemName, setItemName] = useState(item.name)- const onSetItemName = async (event: any) => {- event.preventDefault()- event.stopPropagation()+ const onSaveItemName = async (name: string, event?: any) => {+ if (event) {+ event.preventDefault()+ event.stopPropagation()+ }+if (item.type === STORAGE_ROW_TYPES.FILE) {- await renameFile(item, itemName, columnIndex)+ await renameFile(item, name, columnIndex)} else if (has(item, 'id')) {const itemWithColumnIndex = { ...item, columnIndex }- renameFolder(itemWithColumnIndex, itemName, columnIndex)+ renameFolder(itemWithColumnIndex, name, columnIndex)} else {- addNewFolder(itemName, columnIndex)+ addNewFolder(name, columnIndex)}}useEffect(() => {if (inputRef.current) inputRef.current.select()++ // [Joshen] Esc should revert changes+ const handleEsc = (event: KeyboardEvent) => {+ if (event.key === 'Escape') {+ if (item?.id !== undefined) onSaveItemName(item.name)+ else addNewFolder('', columnIndex)+ }+ }++ window.addEventListener('keydown', handleEsc)+ return () => window.removeEventListener('keydown', handleEsc)}, [])return (@@ -45,7 +59,7 @@ const FileExplorerRowEditing = ({ item, view, columnIndex }: FileExplorerRowEditmimeType={item.metadata?.mimetype}/></div>- <form className="h-9" onSubmit={onSetItemName}>+ <form className="h-9" onSubmit={(event) => onSaveItemName(itemName, event)}><inputautoFocusref={inputRef}@@ -53,9 +67,13 @@ const FileExplorerRowEditing = ({ item, view, columnIndex }: FileExplorerRowEdittype="text"value={itemName}onChange={(event) => setItemName(event.target.value)}- onBlur={onSetItemName}+ onBlur={(event) => onSaveItemName(itemName, event)}+ />+ <button+ className="hidden"+ type="submit"+ onClick={(event) => onSaveItemName(itemName, event)}/>- <button className="hidden" type="submit" onClick={onSetItemName} /></form></div></div>diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 3269577e6ed..a7b8fa094e3 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -1125,7 +1125,7 @@ class StorageExplorerStore {renameFile = async (file, newName, columnIndex) => {const originalName = file.name- if (originalName === newName) {+ if (originalName === newName || newName.length === 0) {this.updateRowStatus(originalName, STORAGE_ROW_STATUS.READY, columnIndex)} else {this.updateRowStatus(originalName, STORAGE_ROW_STATUS.LOADING, columnIndex, newName)@@ -1576,8 +1576,6 @@ class StorageExplorerStore {}addTempRow = (type, name, status, columnIndex, metadata = {}, isPrepend = false) => {- console.log('addTempRow', { type, name, status })-const updatedColumns = this.columns.map((column, idx) => {if (idx === columnIndex) {const tempRow = { type, name, status, metadata }