1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 19:44:35 +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' import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
@@ -12,6 +12,7 @@ type NameInputModalProps = {
isFolder: boolean isFolder: boolean
actionLabel: string actionLabel: string
action: (name: string) => void action: (name: string) => void
defaultName?: string
} }
const NameInputModal = ({ const NameInputModal = ({
@@ -20,12 +21,17 @@ const NameInputModal = ({
title, title,
isFolder, isFolder,
actionLabel, actionLabel,
action action,
defaultName
}: NameInputModalProps) => { }: NameInputModalProps) => {
const [name, setName] = useState('') const [name, setName] = useState('')
const [hasError, setHasError] = useState(false) const [hasError, setHasError] = useState(false)
const [errorText, setErrorText] = useState('') const [errorText, setErrorText] = useState('')
useEffect(() => {
if (defaultName) setName(defaultName)
}, [defaultName])
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value const value = event.target.value

View File

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