Skip to content

Commit

Permalink
Add "Create new folder" menu item inside "Move to folder" menu (#7172)
Browse files Browse the repository at this point in the history
  • Loading branch information
4ian authored Nov 18, 2024
1 parent 13aab9a commit 9eada90
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 29 deletions.
48 changes: 31 additions & 17 deletions newIDE/app/src/ObjectsList/ObjectFolderTreeViewItemContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,38 @@ export class ObjectFolderTreeViewItemContent implements TreeViewItemContent {
},
{
label: i18n._('Move to folder'),
submenu: filteredFolderAndPathsInContainer.map(({ folder, path }) => ({
label: path,
enabled: folder !== this.objectFolder.getParent(),
click: () => {
if (folder === this.objectFolder.getParent()) return;
this.objectFolder
.getParent()
.moveObjectFolderOrObjectToAnotherFolder(
this.objectFolder,
folder,
0
);
onMovedObjectFolderOrObjectToAnotherFolderInSameContainer({
objectFolderOrObject: folder,
global: this._isGlobal,
});
submenu: [
...filteredFolderAndPathsInContainer.map(({ folder, path }) => ({
label: path,
enabled: folder !== this.objectFolder.getParent(),
click: () => {
if (folder === this.objectFolder.getParent()) return;
this.objectFolder
.getParent()
.moveObjectFolderOrObjectToAnotherFolder(
this.objectFolder,
folder,
0
);
onMovedObjectFolderOrObjectToAnotherFolderInSameContainer({
objectFolderOrObject: folder,
global: this._isGlobal,
});
},
})),

{ type: 'separator' },
{
label: i18n._(t`Create new folder...`),
click: () =>
addFolder([
{
objectFolderOrObject: this.objectFolder.getParent(),
global: this._isGlobal,
},
]),
},
})),
],
},
...renderQuickCustomizationMenuItems({
i18n,
Expand Down
43 changes: 31 additions & 12 deletions newIDE/app/src/ObjectsList/ObjectTreeViewItemContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type ObjectTreeViewItemProps = {|
selectObjectFolderOrObjectWithContext: (
objectFolderOrObjectWithContext: ?ObjectFolderOrObjectWithContext
) => void,
addFolder: (items: Array<ObjectFolderOrObjectWithContext>) => void,
forceUpdateList: () => void,
forceUpdate: () => void,
|};
Expand Down Expand Up @@ -280,6 +281,7 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
setAsGlobalObject,
onOpenEventBasedObjectEditor,
selectObjectFolderOrObjectWithContext,
addFolder,
} = this.props;
const container = this._isGlobal
Expand Down Expand Up @@ -390,19 +392,36 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
},
{
label: i18n._('Move to folder'),
submenu: folderAndPathsInContainer.map(({ folder, path }) => ({
label: path,
enabled: folder !== this.object.getParent(),
click: () => {
this.object
.getParent()
.moveObjectFolderOrObjectToAnotherFolder(this.object, folder, 0);
onMovedObjectFolderOrObjectToAnotherFolderInSameContainer({
objectFolderOrObject: folder,
global: this._isGlobal,
});
submenu: [
...folderAndPathsInContainer.map(({ folder, path }) => ({
label: path,
enabled: folder !== this.object.getParent(),
click: () => {
this.object
.getParent()
.moveObjectFolderOrObjectToAnotherFolder(
this.object,
folder,
0
);
onMovedObjectFolderOrObjectToAnotherFolderInSameContainer({
objectFolderOrObject: folder,
global: this._isGlobal,
});
},
})),
{ type: 'separator' },
{
label: i18n._(t`Create new folder...`),
click: () =>
addFolder([
{
objectFolderOrObject: this.object.getParent(),
global: this._isGlobal,
},
]),
},
})),
],
},
{ type: 'separator' },
{
Expand Down
2 changes: 2 additions & 0 deletions newIDE/app/src/ObjectsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ const ObjectsList = React.forwardRef<Props, ObjectsListInterface>(
getThumbnail,
showDeleteConfirmation,
selectObjectFolderOrObjectWithContext,
addFolder,
forceUpdateList,
forceUpdate,
}),
Expand All @@ -972,6 +973,7 @@ const ObjectsList = React.forwardRef<Props, ObjectsListInterface>(
getThumbnail,
showDeleteConfirmation,
selectObjectFolderOrObjectWithContext,
addFolder,
forceUpdateList,
forceUpdate,
]
Expand Down

0 comments on commit 9eada90

Please sign in to comment.