1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 19:34:34 +00:00

fix(web): show original name as default name in rename file/folder modal

This commit is contained in:
2022-07-27 01:44:13 +05:00
parent c574b42235
commit 9640f65264
2 changed files with 9 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
@@ -12,6 +12,7 @@ type NameInputModalProps = {
isFolder: boolean
actionLabel: string
action: (name: string) => void
defaultName?: string
}
const NameInputModal = ({
@@ -20,12 +21,17 @@ const NameInputModal = ({
title,
isFolder,
actionLabel,
action
action,
defaultName
}: NameInputModalProps) => {
const [name, setName] = useState('')
const [hasError, setHasError] = useState(false)
const [errorText, setErrorText] = useState('')
useEffect(() => {
if (defaultName) setName(defaultName)
}, [defaultName])
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value

View File

@@ -208,6 +208,7 @@ const TreeViewNode = ({
action={
nameInputModalActionLabel === 'Add' ? addFileFolder : renameFileFolder
}
defaultName={node.relativePath.split('/').pop()}
/>
<Menu
open={contextMenu !== null}