Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default function FolderContainer({
console.log(id);
dispatch(traverseIntoFolder(id));
};

return (
<IconContainer>
<FolderIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Props {

export default function Renamable({ name, id }: Props) {
const [toggle, setToggle] = useState(true);
const [inputName, setInputName] = useState(name);
const [inputName, setInputName] = useState<string>(name);

const dispatch = useDispatch();

Expand All @@ -30,7 +30,12 @@ export default function Renamable({ name, id }: Props) {
return (
<>
{toggle ? (
<div onDoubleClick={() => setToggle(false)}>{name}</div>
<div onDoubleClick={() => {
setToggle(false);
// required as browser doesn't update inputName
// after first refresh of page after renaming
setInputName(name);
}}>{name}</div>
) : (
<input
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RootState } from 'src/redux-state/reducers';
import { folderSelectors } from '../../state/folders/index';
import FileContainer from './FileContainer';
import FolderContainer from './FolderContainer';
import { FileEntity } from '../../state/folders/types';

type Props = {
selectedFile: string | null;
Expand All @@ -17,8 +18,29 @@ export default function Renderer({ selectedFile, setSelectedFile }: Props) {

const folderItems = folders.items;

const renderItems = () =>
folderItems.map((item, index) => {
// folderItems

const fileComparator = (a : FileEntity, b : FileEntity) => {
if (a.type === b.type) {
return (
a.name.toLowerCase() < b.name.toLowerCase()
? -1
: ( a.name.toLowerCase() > b.name.toLowerCase()
? 1
: 0
)
);
} else if (a.type === "File") {
return 1
}
return -1;
};

const renderItems = () =>

[...folderItems]
.sort(fileComparator)
.map((item, index) => {
switch (item.type) {
case 'Folder':
return (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/packages/dashboard/state/folders/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function renameFileEntity(
state: sliceState,
action: PayloadAction<RenamePayloadType>
) {

const { id, newName } = action.payload;
return {
...state,
Expand Down