From f5bece4ae6a9cf2c314dcb1d1c26398b47b11aa0 Mon Sep 17 00:00:00 2001 From: aditya-mitra <55396651+aditya-mitra@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:57:13 +0530 Subject: [PATCH 1/9] replace h2 with text --- .../panels/Properties/elementList/index.tsx | 69 +++++++------------ 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/packages/ui/src/components/editor/panels/Properties/elementList/index.tsx b/packages/ui/src/components/editor/panels/Properties/elementList/index.tsx index 5fcf4d1377..f6f09b3588 100644 --- a/packages/ui/src/components/editor/panels/Properties/elementList/index.tsx +++ b/packages/ui/src/components/editor/panels/Properties/elementList/index.tsx @@ -28,16 +28,16 @@ import React, { useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { Component } from '@etherealengine/ecs/src/ComponentFunctions' -import { getMutableState, getState, useHookstate } from '@etherealengine/hyperflux' - -import PlaceHolderIcon from '@mui/icons-material/GroupAddOutlined' +import { getMutableState, getState, useHookstate, useMutableState } from '@etherealengine/hyperflux' import { ItemTypes } from '@etherealengine/editor/src/constants/AssetTypes' import { EditorControlFunctions } from '@etherealengine/editor/src/functions/EditorControlFunctions' import { ComponentEditorsState } from '@etherealengine/editor/src/services/ComponentEditors' import { ComponentShelfCategoriesState } from '@etherealengine/editor/src/services/ComponentShelfCategoriesState' import { SelectionState } from '@etherealengine/editor/src/services/SelectionServices' +import { GrStatusPlaceholder } from 'react-icons/gr' import { IoIosArrowDown, IoIosArrowUp } from 'react-icons/io' +import Text from '../../../../../primitives/tailwind/Text' import StringInput from '../../../input/String' import { usePopoverContextClose } from '../../../util/PopoverContext' @@ -50,10 +50,12 @@ export type SceneElementType = { const ComponentListItem = ({ item }: { item: Component }) => { const { t } = useTranslation() - useHookstate(getMutableState(ComponentEditorsState).keys).value // ensure reactively updates new components - const Icon = getState(ComponentEditorsState)[item.name]?.iconComponent ?? PlaceHolderIcon + useMutableState(ComponentEditorsState).keys // ensure reactively updates new components + const Icon = getState(ComponentEditorsState)[item.name]?.iconComponent ?? GrStatusPlaceholder const handleClosePopover = usePopoverContextClose() + const jsonName = item.jsonID?.slice(3).replace('_', '-') || item.name + return ( ) @@ -95,7 +97,7 @@ const SceneElementListItem = ({ {categoryTitle} {isCollapsed || open.value ? : } -
+
    {categoryItems.map((item) => ( @@ -145,16 +147,16 @@ export function ElementList() { return ( <> -
    -
    -

    {t('editor:layout.assetGrid.components')}

    - onSearch(val)} - inputRef={inputReference} - /> -
    +
    + + {t('editor:layout.assetGrid.components')} + + onSearch(val)} + inputRef={inputReference} + />
    {shelves.map(([category, items]) => ( ) - { - /* - - {t('editor:layout.assetGrid.components')} - - onSearch(e.target.value)} - inputRef={inputReference} - /> -
    - } - > - {shelves.map(([category, items]) => ( - - ))} - */ - } } export default ElementList From 19f17d1d454771c68d41c74cccb7f17cd1dbf12f Mon Sep 17 00:00:00 2001 From: aditya-mitra <55396651+aditya-mitra@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:58:05 +0530 Subject: [PATCH 2/9] elementlist descriptions --- .../editor/panels/Properties/container/index.tsx | 2 +- .../components/editor/panels/Viewport/tools/GridTool.tsx | 2 +- .../src/components/editor/properties/light/spot/index.tsx | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/editor/panels/Properties/container/index.tsx b/packages/ui/src/components/editor/panels/Properties/container/index.tsx index e8726f08ee..f505954c49 100644 --- a/packages/ui/src/components/editor/panels/Properties/container/index.tsx +++ b/packages/ui/src/components/editor/panels/Properties/container/index.tsx @@ -110,7 +110,7 @@ const EntityEditor = (props: { entityUUID: EntityUUID; multiEdit: boolean }) => anchorPosition={anchorPosition} className="h-[60%] w-full min-w-[300px] overflow-y-auto" > - {} + {components.map((c, i) => ( diff --git a/packages/ui/src/components/editor/panels/Viewport/tools/GridTool.tsx b/packages/ui/src/components/editor/panels/Viewport/tools/GridTool.tsx index f47fd1f86b..3591b85fed 100644 --- a/packages/ui/src/components/editor/panels/Viewport/tools/GridTool.tsx +++ b/packages/ui/src/components/editor/panels/Viewport/tools/GridTool.tsx @@ -48,7 +48,7 @@ const GridTool = () => { startIcon={} onClick={onToggleGridVisible} variant="transparent" - title={t('editor:toolbar.transformPivot.info-toggleGridVisibility')} + title={t('editor:toolbar.grid.info-toggleGridVisibility')} className="px-0" /> { const lightComponent = useComponent(props.entity, SpotLightComponent).value return ( - }> + } + > From ca91a927461c75700afc442f4c2782637816a419 Mon Sep 17 00:00:00 2001 From: aditya-mitra <55396651+aditya-mitra@users.noreply.github.com> Date: Wed, 5 Jun 2024 11:41:14 +0530 Subject: [PATCH 3/9] wrap euler input --- packages/ui/src/components/editor/input/Euler/index.tsx | 2 +- .../ui/src/components/editor/input/Vector3/index.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/editor/input/Euler/index.tsx b/packages/ui/src/components/editor/input/Euler/index.tsx index 4295d7e350..03a0baeae9 100644 --- a/packages/ui/src/components/editor/input/Euler/index.tsx +++ b/packages/ui/src/components/editor/input/Euler/index.tsx @@ -64,7 +64,7 @@ export const EulerInput = (props: EulerInputProps) => { ) return ( -
    +
    +
    {uniformScaling && ( -
    From 437d277673a00968730031a881ba55270ac1d8eb Mon Sep 17 00:00:00 2001 From: aditya-mitra <55396651+aditya-mitra@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:50:22 +0530 Subject: [PATCH 7/9] rename file using a separate modal --- packages/client-core/i18n/en/editor.json | 1 + .../Files/browserGrid/RenameFileModal.tsx | 63 +++++++++++++++ .../editor/panels/Files/browserGrid/index.tsx | 78 ++++--------------- .../editor/panels/Files/container/index.tsx | 1 - 4 files changed, 80 insertions(+), 63 deletions(-) create mode 100644 packages/ui/src/components/editor/panels/Files/browserGrid/RenameFileModal.tsx diff --git a/packages/client-core/i18n/en/editor.json b/packages/client-core/i18n/en/editor.json index 56f27d3441..214846ceeb 100755 --- a/packages/client-core/i18n/en/editor.json +++ b/packages/client-core/i18n/en/editor.json @@ -1132,6 +1132,7 @@ "copyAsset": "Copy", "pasteAsset": "Paste", "renameAsset": "Rename", + "renameFile": "Rename File", "viewAssetProperties": "View Properties", "refresh": "Refresh", "back": "Back", diff --git a/packages/ui/src/components/editor/panels/Files/browserGrid/RenameFileModal.tsx b/packages/ui/src/components/editor/panels/Files/browserGrid/RenameFileModal.tsx new file mode 100644 index 0000000000..924c89c6ee --- /dev/null +++ b/packages/ui/src/components/editor/panels/Files/browserGrid/RenameFileModal.tsx @@ -0,0 +1,63 @@ +/* +CPAL-1.0 License + +The contents of this file are subject to the Common Public Attribution License +Version 1.0. (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. +The License is based on the Mozilla Public License Version 1.1, but Sections 14 +and 15 have been added to cover use of software over a computer network and +provide for limited attribution for the Original Developer. In addition, +Exhibit A has been modified to be consistent with Exhibit B. + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +specific language governing rights and limitations under the License. + +The Original Code is Ethereal Engine. + +The Original Developer is the Initial Developer. The Initial Developer of the +Original Code is the Ethereal Engine team. + +All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 +Ethereal Engine. All Rights Reserved. +*/ + +import React from 'react' +import { useTranslation } from 'react-i18next' + +import { PopoverState } from '@etherealengine/client-core/src/common/services/PopoverState' +import { fileBrowserPath } from '@etherealengine/common/src/schema.type.module' +import { FileDataType } from '@etherealengine/editor/src/components/assets/FileBrowser/FileDataType' +import { useHookstate } from '@etherealengine/hyperflux' +import { useMutation } from '@etherealengine/spatial/src/common/functions/FeathersHooks' +import Input from '../../../../../primitives/tailwind/Input' +import Modal from '../../../../../primitives/tailwind/Modal' + +export default function RenameFileModal({ file }: { file: FileDataType }) { + const { t } = useTranslation() + const newFileName = useHookstate(file.name) + const fileService = useMutation(fileBrowserPath) + + const handleSubmit = async () => { + fileService.update(null, { + oldName: file.fullName, + newName: file.isFolder ? newFileName.value : `${newFileName.value}.${file.type}`, + oldPath: file.path, + newPath: file.path, + isCopy: false + }) + PopoverState.hidePopupover() + } + + return ( + + newFileName.set(event.target.value)} /> + + ) +} diff --git a/packages/ui/src/components/editor/panels/Files/browserGrid/index.tsx b/packages/ui/src/components/editor/panels/Files/browserGrid/index.tsx index 93553b17c9..a942ee7232 100644 --- a/packages/ui/src/components/editor/panels/Files/browserGrid/index.tsx +++ b/packages/ui/src/components/editor/panels/Files/browserGrid/index.tsx @@ -23,6 +23,7 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20 Ethereal Engine. All Rights Reserved. */ +import { PopoverState } from '@etherealengine/client-core/src/common/services/PopoverState' import { fileBrowserPath, staticResourcePath } from '@etherealengine/common/src/schema.type.module' import { FilesViewModeSettings, @@ -35,7 +36,7 @@ import { getSpawnPositionAtCenter } from '@etherealengine/editor/src/functions/s import { getMutableState, useHookstate } from '@etherealengine/hyperflux' import { useFind, useMutation } from '@etherealengine/spatial/src/common/functions/FeathersHooks' import { TransformComponent } from '@etherealengine/spatial/src/transform/components/TransformComponent' -import React, { MouseEventHandler, MutableRefObject, useEffect, useState } from 'react' +import React, { MouseEventHandler, MutableRefObject, useEffect } from 'react' import { ConnectDragSource, ConnectDropTarget, useDrag, useDrop } from 'react-dnd' import { getEmptyImage } from 'react-dnd-html5-backend' import { useTranslation } from 'react-i18next' @@ -43,26 +44,9 @@ import { IoIosArrowForward } from 'react-icons/io' import { VscBlank } from 'react-icons/vsc' import { Vector3 } from 'three' import Button from '../../../../../primitives/tailwind/Button' -import Input from '../../../../../primitives/tailwind/Input' import { ContextMenu } from '../../../layout/ContextMenu' import { FileIcon } from '../icon' - -const RenameInput = ({ fileName, onNameChanged }: { fileName: string; onNameChanged: (newName: string) => void }) => { - const newFileName = useHookstate(fileName) - - return ( - newFileName.set(event.target.value)} - onKeyUp={async (e) => { - if (e.key == 'Enter') { - onNameChanged(newFileName.value) - } - }} - /> - ) -} +import RenameFileModal from './RenameFileModal' export const canDropItemOverFolder = (folderName: string) => folderName.endsWith('/assets') || @@ -103,8 +87,6 @@ export const FileTableWrapper = ({ wrap, children }: { wrap: boolean; children: export const FileTableListBody = ({ file, onContextMenu, - isRenaming, - onNameChanged, onClick, onDoubleClick, modifiedDate, @@ -114,8 +96,6 @@ export const FileTableListBody = ({ }: { file: FileDataType onContextMenu: React.MouseEventHandler - isRenaming: boolean - onNameChanged: (newName: string) => void onClick?: MouseEventHandler onDoubleClick?: MouseEventHandler modifiedDate?: string @@ -136,7 +116,7 @@ export const FileTableListBody = ({ {file.isFolder ? : } - {isRenaming ? : file.fullName} + {file.fullName} ), type: file.type.toUpperCase(), @@ -148,8 +128,8 @@ export const FileTableListBody = ({ key={file.key} className={`h-[${fontSize * 3}px] text-[${fontSize}px] text-[#a3a3a3] hover:bg-theme-surfaceInput`} onContextMenu={onContextMenu} - onClick={isRenaming ? () => {} : onClick} - onDoubleClick={isRenaming ? () => {} : onDoubleClick} + onClick={onClick} + onDoubleClick={onDoubleClick} ref={(ref) => dragFn(dropFn(ref))} > {availableTableColumns @@ -165,10 +145,8 @@ export const FileTableListBody = ({ type FileGridItemProps = { item: FileDataType - isRenaming: boolean onDoubleClick?: MouseEventHandler onClick?: MouseEventHandler - onNameChanged: (newName: string) => void } export const FileGridItem: React.FC = (props) => { @@ -196,14 +174,9 @@ export const FileGridItem: React.FC = (props) => { color="text-[#375DAF]" />
    - {props.isRenaming ? ( - <> - ) : ( - /**/ -
    - {props.item.fullName} -
    - )} +
    + {props.item.fullName} +
    ) } @@ -220,7 +193,6 @@ type FileBrowserItemType = { deleteContent: (contentPath: string, type: string) => void onClick: (params: FileDataType) => void dropItemsOnPanel: (data: any, dropOn?: FileDataType) => void - moveContent: (oldName: string, newName: string, oldPath: string, newPath: string, isCopy?: boolean) => Promise addFolder: () => void isListView: boolean staticResourceModifiedDates: Record @@ -237,7 +209,6 @@ export function FileBrowserItem({ deleteContent, onClick, dropItemsOnPanel, - moveContent, isFilesLoading, addFolder, isListView, @@ -247,7 +218,6 @@ export function FileBrowserItem({ const [anchorPosition, setAnchorPosition] = React.useState(undefined) const [anchorEl, setAnchorEl] = React.useState(null) const open = Boolean(anchorEl) - const [renamingAsset, setRenamingAsset] = useState(false) const fileService = useMutation(fileBrowserPath) @@ -339,17 +309,6 @@ export function FileBrowserItem({ handleClose() } - const onNameChanged = async (fileName: string): Promise => { - setRenamingAsset(false) - - await moveContent(item.fullName, item.isFolder ? fileName : `${fileName}.${item.type}`, item.path, item.path, false) - } - - const rename = () => { - setRenamingAsset(true) - handleClose() - } - const [_dragProps, drag, preview] = disableDnD ? [undefined, undefined, undefined] : useDrag(() => ({ @@ -382,8 +341,6 @@ export function FileBrowserItem({ onContextMenu={handleContextMenu} onClick={onClickItem} onDoubleClick={onClickItem} - isRenaming={renamingAsset} - onNameChanged={onNameChanged} modifiedDate={staticResourceModifiedDates[item.key]} drop={drop} isOver={isOver} @@ -393,15 +350,7 @@ export function FileBrowserItem({
    - { - - } + {}
    @@ -445,7 +394,12 @@ export function FileBrowserItem({ -