Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
943890a2
Commit
943890a2
authored
May 31, 2021
by
filip mertens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing multi focused items
parent
b6fc7433
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
file-explorer-context-menu.tsx
...x-ui/file-explorer/src/lib/file-explorer-context-menu.tsx
+22
-6
No files found.
libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx
View file @
943890a2
...
@@ -21,11 +21,27 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
...
@@ -21,11 +21,27 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
}
}
},
[
pageX
,
pageY
])
},
[
pageX
,
pageY
])
const
itemMatchesCondition
=
(
item
:
action
)
=>
{
const
filterItem
=
(
item
:
action
)
=>
{
if
(
item
.
type
&&
Array
.
isArray
(
item
.
type
)
&&
(
item
.
type
.
findIndex
(
name
=>
name
===
type
)
!==
-
1
))
return
true
/**
else
if
(
item
.
path
&&
Array
.
isArray
(
item
.
path
)
&&
(
item
.
path
.
findIndex
(
key
=>
key
===
path
)
!==
-
1
))
return
true
* if there are multiple elements focused we need to take this and all conditions must be met
else
if
(
item
.
extension
&&
Array
.
isArray
(
item
.
extension
)
&&
(
item
.
extension
.
findIndex
(
ext
=>
path
.
endsWith
(
ext
))
!==
-
1
))
return
true
* for example : 'downloadAsZip' with type ['file','folder','multi'] will work on files and folders when multiple are selected
else
if
(
item
.
pattern
&&
Array
.
isArray
(
item
.
pattern
)
&&
(
item
.
pattern
.
filter
(
value
=>
path
.
match
(
new
RegExp
(
value
))).
length
>
0
))
return
true
**/
const
nonRootFocus
=
focus
.
filter
((
el
)
=>
{
return
!
(
el
.
key
===
''
&&
el
.
type
===
'folder'
)
})
if
(
nonRootFocus
.
length
>
1
)
{
for
(
const
element
of
nonRootFocus
)
{
if
(
!
itemMatchesCondition
(
item
,
element
.
type
,
element
.
key
))
return
false
}
return
true
}
else
{
return
itemMatchesCondition
(
item
,
type
,
path
)
}
}
const
itemMatchesCondition
=
(
item
:
action
,
itemType
:
string
,
itemPath
:
string
)
=>
{
if
(
item
.
type
&&
Array
.
isArray
(
item
.
type
)
&&
(
item
.
type
.
findIndex
(
name
=>
name
===
itemType
)
!==
-
1
))
return
true
else
if
(
item
.
path
&&
Array
.
isArray
(
item
.
path
)
&&
(
item
.
path
.
findIndex
(
key
=>
key
===
itemPath
)
!==
-
1
))
return
true
else
if
(
item
.
extension
&&
Array
.
isArray
(
item
.
extension
)
&&
(
item
.
extension
.
findIndex
(
ext
=>
itemPath
.
endsWith
(
ext
))
!==
-
1
))
return
true
else
if
(
item
.
pattern
&&
Array
.
isArray
(
item
.
pattern
)
&&
(
item
.
pattern
.
filter
(
value
=>
itemPath
.
match
(
new
RegExp
(
value
))).
length
>
0
))
return
true
else
return
false
else
return
false
}
}
...
@@ -38,7 +54,7 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
...
@@ -38,7 +54,7 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
}
}
const
menu
=
()
=>
{
const
menu
=
()
=>
{
return
actions
.
filter
(
item
=>
itemMatchesCondition
(
item
)).
map
((
item
,
index
)
=>
{
return
actions
.
filter
(
item
=>
filterItem
(
item
)).
map
((
item
,
index
)
=>
{
return
<
li
return
<
li
id=
{
`menuitem${item.name.toLowerCase()}`
}
id=
{
`menuitem${item.name.toLowerCase()}`
}
key=
{
index
}
key=
{
index
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment