Skip to content

Feature loading indicator #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
52c81cf
Increase Heap Size
dragonpoo Nov 20, 2024
3a443bb
Merge pull request #1323 from lowcoder-org/fix/heapsize
FalkWolsky Nov 20, 2024
24ba4bd
convert snapshot migration to use aggregation pipeline
dragonpoo Nov 20, 2024
0c5c344
delete after copying records
dragonpoo Nov 20, 2024
1eca3af
different migration based on mongo version.
dragonpoo Nov 20, 2024
dc98eb3
Merge pull request #1324 from lowcoder-org/fix/migration
FalkWolsky Nov 20, 2024
b605907
modify to use aggregate
dragonpoo Nov 21, 2024
f7a6179
modify snapshot task logic to move from normal collection to timeseri…
dragonpoo Nov 21, 2024
138ebd8
swap ts and normal collection in api endpoint
dragonpoo Nov 22, 2024
a28b90f
application snapshot history count logic fix
dragonpoo Nov 22, 2024
311bae7
page number start from 1
dragonpoo Nov 22, 2024
570e35c
#1284 Fixed duplicate key error for currentUser endpoint when logging…
dragonpoo Nov 22, 2024
d6d7a88
fix test compile issue
dragonpoo Nov 22, 2024
a740d0f
Added tree structure basically.
Imiss-U1025 Nov 19, 2024
69c7415
Added Movefolder in redux.
Imiss-U1025 Nov 21, 2024
b6e07d5
Made be possible Drag and Drop in extension.
Imiss-U1025 Nov 21, 2024
63534ca
Added removing module.
Imiss-U1025 Nov 21, 2024
c8daa8d
Added removing folder.
Imiss-U1025 Nov 22, 2024
39dbd40
Added Renaming folders.
Imiss-U1025 Nov 22, 2024
521370f
Added removing modules
Imiss-U1025 Nov 22, 2024
fdc0145
Fixed UI.
Imiss-U1025 Nov 22, 2024
ff55d93
Fxied ability to module drag and drop in right panel.
Imiss-U1025 Nov 22, 2024
4e4e906
Fixed an issue where subApplications are hidden when rename a folder.
Imiss-U1025 Nov 22, 2024
ab549e4
Merge pull request #1334 from lowcoder-org/feature-extension
FalkWolsky Nov 22, 2024
4871649
Fixed an issue miss loading-indicator.
Imiss-U1025 Nov 23, 2024
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
Prev Previous commit
Next Next commit
Added removing module.
  • Loading branch information
Imiss-U1025 committed Nov 22, 2024
commit 63534caada12c8fb5f85ee05c97621a8fda03d55
189 changes: 146 additions & 43 deletions client/packages/lowcoder/src/pages/editor/right/ModulePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {
PointIcon,
PopupCard,
UnfoldIcon,
FileFolderIcon
FileFolderIcon, messageInstance, CustomModal
} from "lowcoder-design";
import { trans } from "i18n";
import {trans, transToNode} from "i18n";
import { draggingUtils } from "layout/draggingUtils";
import {CSSProperties, useContext, useEffect, useState} from "react";
import React, {CSSProperties, useContext, useEffect, useState} from "react";
import { useDispatch, useSelector } from "react-redux";
import { fetchAllModules } from "redux/reduxActions/applicationActions";
import {fetchAllModules, recycleApplication} from "redux/reduxActions/applicationActions";
import styled from "styled-components";
import CreateAppButton from "components/CreateAppButton";
import { TransparentImg } from "util/commonUtils";
Expand All @@ -31,12 +31,20 @@ import {showAppSnapshotSelector} from "@lowcoder-ee/redux/selectors/appSnapshotS
import {DraggableTreeNode, DraggableTreeNodeItemRenderProps} from "@lowcoder-ee/components/DraggableTree/types";
import RefTreeComp from "@lowcoder-ee/comps/comps/refTreeComp";
import { EmptyContent } from "components/EmptyContent";
import {moveToFolder} from "@lowcoder-ee/redux/reduxActions/folderActions";
import {HomeResInfo} from "@lowcoder-ee/util/homeResUtils";
const ItemWrapper = styled.div`
display: flex;
flex-direction: row;
&:last-child {
margin-bottom: 0;
}
.module-container {
//width: 70px;
display: flex;
justify-content: space-between;
text-align: left;
}
.module-icon {

display: flex;
Expand All @@ -52,6 +60,8 @@ const ItemWrapper = styled.div`
overflow: hidden;
}
.module-name {
//flex-grow: 1;
//margin-right: 8px;
line-height: 1.5;
font-size: 13px;
overflow: hidden;
Expand All @@ -77,8 +87,8 @@ function buildTree(elementRecord: Record<string, Array<ApplicationMeta | FolderM
const elements = elementRecord[""];
const elementMap: Record<string, NodeType> = {};
let rootNode: NodeType = {
name: "",
id: "",
name: "root",
id: "root",
isFolder: true,
children: [],
rename: val => rootNode.name = val,
Expand All @@ -99,7 +109,7 @@ function buildTree(elementRecord: Record<string, Array<ApplicationMeta | FolderM

// Process subapplications inside the folder
for (const app of element.subApplications || []) {
if (app.applicationType === AppTypeEnum.Module) {
if (!!app && app.applicationType === AppTypeEnum.Module) {
const appNode: NodeType = {
name: app.name,
id: app.applicationId,
Expand Down Expand Up @@ -142,15 +152,15 @@ function buildTree(elementRecord: Record<string, Array<ApplicationMeta | FolderM
rootNode.children.push(elementMap[element.applicationId]);
}
}
console.log(rootNode.children.sort((a, b) => {
rootNode.children.sort((a, b) => {
if (a.isFolder && !b.isFolder) {
return -1; // a is a isFolder and should come first
} else if (!a.isFolder && b.isFolder) {
return 1; // b is a folder and should come first
} else {
return 0; // both are folders or both are not, keep original order
}
}));
});
return rootNode;
}

Expand All @@ -168,6 +178,7 @@ function ModuleItem(props: ModuleItemProps) {
draggable
onDragStart={(e) => {
console.log(meta);
e.stopPropagation();
e.dataTransfer.setData("compType", compType);
e.dataTransfer.setDragImage(TransparentImg, 0, 0);
draggingUtils.setData("compType", compType);
Expand All @@ -183,11 +194,13 @@ function ModuleItem(props: ModuleItemProps) {
props.onDrag(compType);
}}
>
<div className="module-icon">
<ModuleDocIcon width="19px" height="19px"/>
</div>
<div className="module-content">
<div className="module-name">{props.meta.name}</div>
<div className="module-container" >
<div className="module-icon">
<ModuleDocIcon width="19px" height="19px"/>
</div>
<div className="module-content">
<div className="module-name">{props.meta.name}</div>
</div>
</div>
</ItemWrapper>
);
Expand Down Expand Up @@ -372,28 +385,29 @@ function ModuleSidebarItem(props: ModuleSidebarItemProps) {
<ColumnDiv onClick={handleClickItem} $color={isSelected} $isOverlay={isOverlay}>
<HighlightBorder $active={isOver && isFolder} $level={level} $foldable={isFolder}>
{isFolder && <FoldIconBtn>{!isFolded ? <FoldedIcon /> : <UnfoldIcon />}</FoldIconBtn>}
{isFolder ?
<>
<FileFolderIcon />
<div style={{ flexGrow: 1, marginRight: "8px", width: "calc(100% - 62px)" }}>
<EditText
text={name}
forceClickIcon={isFolder}
disabled={!isSelected || readOnly || isOverlay}
onFinish={handleFinishRename}
onChange={handleNameChange}
onEditStateChange={(editing) => setEditing(editing)}
/>
<PopupCard
editorFocus={!!error && editing}
title={error ? trans("error") : ""}
content={error}
hasError={!!error}
/>
</div></> : <ModuleItem onDrag={onDrag} key={id} meta={resComp.module!} />
}
{ isFolder ?
<>
<FileFolderIcon />
<div style={{ flexGrow: 1, marginRight: "8px", width: "calc(100% - 62px)" }}>
<EditText
text={name}
forceClickIcon={isFolder}
disabled={!isSelected || readOnly || isOverlay}
onFinish={handleFinishRename}
onChange={handleNameChange}
onEditStateChange={(editing) => setEditing(editing)}
/>
<PopupCard
editorFocus={!!error && editing}
title={error ? trans("error") : ""}
content={error}
hasError={!!error}
/>
</div>
</> :
<ModuleItem onDrag={onDrag} key={id} meta={resComp.module!} /> }
{!readOnly && !isOverlay && (
<EditPopover copy={!isFolder ? onCopy : undefined} del={onDelete}>
<EditPopover copy={!isFolder ? onCopy : undefined} del={() => onDelete()}>
<Icon tabIndex={-1} />
</EditPopover>
)}
Expand All @@ -404,9 +418,10 @@ function ModuleSidebarItem(props: ModuleSidebarItemProps) {

export default function ModulePanel() {
const dispatch = useDispatch();
const elements = useSelector(folderElementsSelector);
let elements = useSelector(folderElementsSelector);
// const reload = () => elements = useSelector(folderElementsSelector);
const { onDrag, searchValue } = useContext(RightContext);

const [deleteFlag, setDeleteFlag] = useState(false);
useEffect(() => {
dispatch(fetchAllModules({}));
}, [dispatch]);
Expand All @@ -433,9 +448,12 @@ export default function ModulePanel() {
}

const getById = (id: string): NodeType | undefined => getByIdFromNode(tree, id);
let popedItem : DraggableTreeNode<any>[] = [];
let popedItemSourceId = ""
const convertRefTree = (treeNode: NodeType) => {
const moduleResComp = getById(treeNode.id);
const currentNodeType = moduleResComp?.isFolder;

const childrenItems = treeNode.children
.map((i) => convertRefTree(i as NodeType))
.filter((i): i is DraggableTreeNode<NodeType> => !!i);
Expand Down Expand Up @@ -473,21 +491,73 @@ export default function ModulePanel() {
data: moduleResComp,
addSubItem(value) {
console.log("addSubItem", node.id, value, node);
// node.items.push(value)
// const pushAction = node.items.pushAction({ value: value.id() });
// node.items.dispatch(pushAction);
},
deleteItem(index) {
console.log("deleteItem", node.id, index);
console.log("deleteItem", node, index);
popedItemSourceId = node.id!;
if(!deleteFlag){
popedItem = node.items.splice(index, 1);
console.log(popedItem);
}

// const deleteAction = node.children.items.deleteAction(index);
// node.children.items.dispatch(deleteAction);
},
addItem(value) {
console.log("addItem", node.id, value);
console.log("additem", "value", value, node);
node.items.push(popedItem[0])
popedItem = [];
// const pushAction = node.children.items.pushAction({ value: value.id() });
// node.children.items.dispatch(pushAction);
// if (popedItem[0]){
// dispatch(
// moveToFolder(
// {
// sourceFolderId: popedItemSourceId,
// sourceId: popedItem[0].id!,
// folderId: node.id!,
// moveFlag: true
// },
// () => {
//
//
// },
// () => {}
// )
// );
// node.items.push(popedItem[0]);
// popedItemSourceId = "";
// popedItem = [];
// }
},
moveItem(from, to) {
console.log("node", node);
console.log("moveItem", node, from, to, node.id);
if (popedItem[0]){
node.items.push(popedItem[0]);

dispatch(
moveToFolder(
{
sourceFolderId: popedItemSourceId,
sourceId: popedItem[0].id!,
folderId: node.id!,
moveFlag: true
},
() => {


},
() => {}
)
);
popedItemSourceId = "";
popedItem = [];

}
// popedItem = [];
// const moveAction = node.children.items.arrayMoveAction(from, to);
// node.children.items.dispatch(moveAction);
},
Expand All @@ -505,18 +575,51 @@ export default function ModulePanel() {
};

const node = convertRefTree(tree);

console.log("started!!!!", node)
function onCopy(type: boolean, id: string) {
console.log("onCopy", type, id);
}

function onSelect(type: boolean, id: string, meta: any) {
console.log("onSelect", type, id, meta)
return <ModuleItem onDrag={onDrag} key={id} meta={meta} />
// return <ModuleItem onDrag={onDrag} key={id} meta={meta} />
}

function onDelete(type: boolean, id: string) {
console.log("onDelete", type, id);
setDeleteFlag(true);
console.log("1111111111111111111111111", type, id, node);
if (type) {
alert(1);
}
else {
CustomModal.confirm({
title: trans("home.moveToTrash"),
content: transToNode("home.moveToTrashSubTitle", {
type: "",
name: "This file",
}),
onConfirm: () => {
dispatch(
recycleApplication(
{
applicationId: id,
folderId: popedItemSourceId,
},
() => {
messageInstance.success(trans("success"))

},
() => {
}
)
)
setDeleteFlag(false)
},
confirmBtnType: "delete",
okText: trans("home.moveToTrash"),
onCancel: () => setDeleteFlag(false)
});
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,24 @@ export const folderReducer = createReducer(initialState, {
state: FolderReduxState,
action: ReduxAction<RecycleApplicationPayload>
): FolderReduxState => {
const deleteArray : number[] = [];
const elements = { ...state.folderElements };
elements[action.payload.folderId ?? ""] = elements[action.payload.folderId ?? ""]?.filter(
(e) => e.folder || (!e.folder && e.applicationId !== action.payload.applicationId)
);
elements[""] = elements[""].map((item, index) => {
if(item.folder) {
const tempSubApplications = item.subApplications?.filter(e => e.applicationId !== action.payload.applicationId);
return { ...item, subApplications: tempSubApplications };
} else {
if (item.applicationId !== action.payload.applicationId)
return item;
else {
deleteArray.push(index);
return item;
}
}
});
deleteArray.map(item => {
elements[""].splice(item, 1);
})
return {
...state,
folderElements: elements,
Expand Down