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
d40cf221
Commit
d40cf221
authored
Nov 26, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Order files and folders, added support for icons in tree view
parent
17150ff3
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
255 deletions
+40
-255
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+15
-4
.eslintrc
libs/remix-ui/tree-view/.eslintrc
+14
-243
jest.config.js
libs/remix-ui/tree-view/jest.config.js
+1
-1
index.ts
libs/remix-ui/tree-view/src/index.ts
+2
-2
remix-ui-tree-view.tsx
libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.tsx
+1
-1
tree-view-item.tsx
...ix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
+3
-3
index.ts
libs/remix-ui/tree-view/src/types/index.ts
+4
-1
No files found.
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
d40cf221
...
@@ -160,18 +160,29 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -160,18 +160,29 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const
normalize
=
(
path
,
filesList
)
=>
{
const
normalize
=
(
path
,
filesList
)
=>
{
const
folders
=
[]
const
files
=
[]
const
prefix
=
path
.
split
(
'/'
)[
0
]
const
prefix
=
path
.
split
(
'/'
)[
0
]
const
files
=
Object
.
keys
(
filesList
).
map
(
key
=>
{
Object
.
keys
(
filesList
).
forEach
(
key
=>
{
const
path
=
prefix
+
'/'
+
key
const
path
=
prefix
+
'/'
+
key
return
{
if
(
filesList
[
key
].
isDirectory
)
{
folders
.
push
({
path
,
path
,
name
:
extractNameFromKey
(
path
),
name
:
extractNameFromKey
(
path
),
isDirectory
:
filesList
[
key
].
isDirectory
isDirectory
:
filesList
[
key
].
isDirectory
})
}
else
{
files
.
push
({
path
,
name
:
extractNameFromKey
(
path
),
isDirectory
:
filesList
[
key
].
isDirectory
})
}
}
})
})
return
files
return
[...
folders
,
...
files
]
}
}
const
extractNameFromKey
=
(
key
)
=>
{
const
extractNameFromKey
=
(
key
)
=>
{
...
@@ -390,7 +401,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -390,7 +401,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
renderFiles
=
(
file
,
index
)
=>
{
const
renderFiles
=
(
file
,
index
)
=>
{
if
(
file
.
isDirectory
)
{
if
(
file
.
isDirectory
)
{
return
(
return
(
<
TreeViewItem
id=
{
`treeViewItem${file.path}`
}
onClick=
{
()
=>
{
resolveDirectory
(
file
.
path
)
}
}
key=
{
index
}
label=
{
label
(
file
)
}
>
<
TreeViewItem
id=
{
`treeViewItem${file.path}`
}
iconX=
'px-3 far fa-folder'
iconY=
'px-3 far fa-folder-open'
key=
{
index
}
label=
{
label
(
file
)
}
onClick=
{
()
=>
{
resolveDirectory
(
file
.
path
)
}
}
>
{
{
file
.
child
?
<
TreeView
id=
{
`treeView${file.path}`
}
key=
{
index
}
>
{
file
.
child
?
<
TreeView
id=
{
`treeView${file.path}`
}
key=
{
index
}
>
{
file
.
child
.
map
((
file
,
index
)
=>
{
file
.
child
.
map
((
file
,
index
)
=>
{
...
...
libs/remix-ui/tree-view/.eslintrc
View file @
d40cf221
{
{
"rules": {
"array-callback-return": "warn",
"dot-location": ["warn", "property"],
"eqeqeq": ["warn", "smart"],
"new-parens": "warn",
"no-caller": "warn",
"no-cond-assign": ["warn", "except-parens"],
"no-const-assign": "warn",
"no-control-regex": "warn",
"no-delete-var": "warn",
"no-dupe-args": "warn",
"no-dupe-keys": "warn",
"no-duplicate-case": "warn",
"no-empty-character-class": "warn",
"no-empty-pattern": "warn",
"no-eval": "warn",
"no-ex-assign": "warn",
"no-extend-native": "warn",
"no-extra-bind": "warn",
"no-extra-label": "warn",
"no-fallthrough": "warn",
"no-func-assign": "warn",
"no-implied-eval": "warn",
"no-invalid-regexp": "warn",
"no-iterator": "warn",
"no-label-var": "warn",
"no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }],
"no-lone-blocks": "warn",
"no-loop-func": "warn",
"no-mixed-operators": [
"warn",
{
"groups": [
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
],
"allowSamePrecedence": false
}
],
"no-multi-str": "warn",
"no-native-reassign": "warn",
"no-negated-in-lhs": "warn",
"no-new-func": "warn",
"no-new-object": "warn",
"no-new-symbol": "warn",
"no-new-wrappers": "warn",
"no-obj-calls": "warn",
"no-octal": "warn",
"no-octal-escape": "warn",
"no-redeclare": "warn",
"no-regex-spaces": "warn",
"no-restricted-syntax": ["warn", "WithStatement"],
"no-script-url": "warn",
"no-self-assign": "warn",
"no-self-compare": "warn",
"no-sequences": "warn",
"no-shadow-restricted-names": "warn",
"no-sparse-arrays": "warn",
"no-template-curly-in-string": "warn",
"no-this-before-super": "warn",
"no-throw-literal": "warn",
"no-restricted-globals": [
"error",
"addEventListener",
"blur",
"close",
"closed",
"confirm",
"defaultStatus",
"defaultstatus",
"event",
"external",
"find",
"focus",
"frameElement",
"frames",
"history",
"innerHeight",
"innerWidth",
"length",
"location",
"locationbar",
"menubar",
"moveBy",
"moveTo",
"name",
"onblur",
"onerror",
"onfocus",
"onload",
"onresize",
"onunload",
"open",
"opener",
"opera",
"outerHeight",
"outerWidth",
"pageXOffset",
"pageYOffset",
"parent",
"print",
"removeEventListener",
"resizeBy",
"resizeTo",
"screen",
"screenLeft",
"screenTop",
"screenX",
"screenY",
"scroll",
"scrollbars",
"scrollBy",
"scrollTo",
"scrollX",
"scrollY",
"self",
"status",
"statusbar",
"stop",
"toolbar",
"top"
],
"no-unexpected-multiline": "warn",
"no-unreachable": "warn",
"no-unused-expressions": [
"error",
{
"allowShortCircuit": true,
"allowTernary": true,
"allowTaggedTemplates": true
}
],
"no-unused-labels": "warn",
"no-useless-computed-key": "warn",
"no-useless-concat": "warn",
"no-useless-escape": "warn",
"no-useless-rename": [
"warn",
{
"ignoreDestructuring": false,
"ignoreImport": false,
"ignoreExport": false
}
],
"no-with": "warn",
"no-whitespace-before-property": "warn",
"react-hooks/exhaustive-deps": "warn",
"require-yield": "warn",
"rest-spread-spacing": ["warn", "never"],
"strict": ["warn", "never"],
"unicode-bom": ["warn", "never"],
"use-isnan": "warn",
"valid-typeof": "warn",
"no-restricted-properties": [
"error",
{
"object": "require",
"property": "ensure",
"message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting"
},
{
"object": "System",
"property": "import",
"message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting"
}
],
"getter-return": "warn",
"import/first": "error",
"import/no-amd": "error",
"import/no-webpack-loader-syntax": "error",
"react/forbid-foreign-prop-types": ["warn", { "allowInPropTypes": true }],
"react/jsx-no-comment-textnodes": "warn",
"react/jsx-no-duplicate-props": "warn",
"react/jsx-no-target-blank": "warn",
"react/jsx-no-undef": "error",
"react/jsx-pascal-case": ["warn", { "allowAllCaps": true, "ignore": [] }],
"react/jsx-uses-react": "warn",
"react/jsx-uses-vars": "warn",
"react/no-danger-with-children": "warn",
"react/no-direct-mutation-state": "warn",
"react/no-is-mounted": "warn",
"react/no-typos": "error",
"react/react-in-jsx-scope": "error",
"react/require-render-return": "error",
"react/style-prop-object": "warn",
"react/jsx-no-useless-fragment": "warn",
"jsx-a11y/accessible-emoji": "warn",
"jsx-a11y/alt-text": "warn",
"jsx-a11y/anchor-has-content": "warn",
"jsx-a11y/anchor-is-valid": [
"warn",
{ "aspects": ["noHref", "invalidHref"] }
],
"jsx-a11y/aria-activedescendant-has-tabindex": "warn",
"jsx-a11y/aria-props": "warn",
"jsx-a11y/aria-proptypes": "warn",
"jsx-a11y/aria-role": "warn",
"jsx-a11y/aria-unsupported-elements": "warn",
"jsx-a11y/heading-has-content": "warn",
"jsx-a11y/iframe-has-title": "warn",
"jsx-a11y/img-redundant-alt": "warn",
"jsx-a11y/no-access-key": "warn",
"jsx-a11y/no-distracting-elements": "warn",
"jsx-a11y/no-redundant-roles": "warn",
"jsx-a11y/role-has-required-aria-props": "warn",
"jsx-a11y/role-supports-aria-props": "warn",
"jsx-a11y/scope": "warn",
"react-hooks/rules-of-hooks": "error",
"default-case": "off",
"no-dupe-class-members": "off",
"no-undef": "off",
"@typescript-eslint/consistent-type-assertions": "warn",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "warn",
"@typescript-eslint/no-namespace": "error",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": [
"warn",
{
"functions": false,
"classes": false,
"variables": false,
"typedefs": false
}
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ "args": "none", "ignoreRestSiblings": true }
],
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "warn"
},
"env": {
"env": {
"browser": true,
"browser": true,
"commonjs": true,
"es6": true
"es6": true,
},
"jest": true,
"extends": "../../../.eslintrc",
"node": true
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
},
"
settings": { "react": { "version": "detect" } },
"
rules": {
"plugins": ["import", "jsx-a11y", "react", "react-hooks"]
,
"no-unused-vars": "off"
,
"extends": ["../../../.eslintrc"],
"@typescript-eslint/no-unused-vars": "error"
"ignorePatterns": ["!**/*"]
}
}
}
libs/remix-ui/tree-view/jest.config.js
View file @
d40cf221
...
@@ -9,4 +9,4 @@ module.exports = {
...
@@ -9,4 +9,4 @@ module.exports = {
},
},
moduleFileExtensions
:
[
'ts'
,
'tsx'
,
'js'
,
'jsx'
,
'html'
],
moduleFileExtensions
:
[
'ts'
,
'tsx'
,
'js'
,
'jsx'
,
'html'
],
coverageDirectory
:
'../../../coverage/libs/remix-ui/tree-view'
coverageDirectory
:
'../../../coverage/libs/remix-ui/tree-view'
}
;
}
libs/remix-ui/tree-view/src/index.ts
View file @
d40cf221
export
*
from
'./lib/tree-view-item/tree-view-item'
;
export
*
from
'./lib/tree-view-item/tree-view-item'
export
*
from
'./lib/remix-ui-tree-view'
;
export
*
from
'./lib/remix-ui-tree-view'
libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.tsx
View file @
d40cf221
import
React
from
'react'
import
React
from
'react'
// eslint-disable-line
import
{
TreeViewProps
}
from
'../types'
import
{
TreeViewProps
}
from
'../types'
import
'./remix-ui-tree-view.css'
import
'./remix-ui-tree-view.css'
...
...
libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
View file @
d40cf221
import
React
,
{
useState
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useEffect
}
from
'react'
// eslint-disable-line
import
{
TreeViewItemProps
}
from
'../../types'
import
{
TreeViewItemProps
}
from
'../../types'
import
'./tree-view-item.css'
import
'./tree-view-item.css'
export
const
TreeViewItem
=
(
props
:
TreeViewItemProps
)
=>
{
export
const
TreeViewItem
=
(
props
:
TreeViewItemProps
)
=>
{
const
{
id
,
children
,
label
,
expand
,
...
otherProps
}
=
props
const
{
id
,
children
,
label
,
expand
,
iconX
=
'fas fa-caret-right'
,
iconY
=
'fas fa-caret-down'
,
icon
=
'fa fa-file'
,
...
otherProps
}
=
props
const
[
isExpanded
,
setIsExpanded
]
=
useState
(
false
)
const
[
isExpanded
,
setIsExpanded
]
=
useState
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -14,7 +14,7 @@ export const TreeViewItem = (props: TreeViewItemProps) => {
...
@@ -14,7 +14,7 @@ export const TreeViewItem = (props: TreeViewItemProps) => {
return
(
return
(
<
li
key=
{
`treeViewLi${id}`
}
data
-
id=
{
`treeViewLi${id}`
}
className=
'li_tv'
{
...
otherProps
}
>
<
li
key=
{
`treeViewLi${id}`
}
data
-
id=
{
`treeViewLi${id}`
}
className=
'li_tv'
{
...
otherProps
}
>
<
div
key=
{
`treeViewDiv${id}`
}
data
-
id=
{
`treeViewDiv${id}`
}
className=
'd-flex flex-row align-items-center'
onClick=
{
()
=>
setIsExpanded
(
!
isExpanded
)
}
>
<
div
key=
{
`treeViewDiv${id}`
}
data
-
id=
{
`treeViewDiv${id}`
}
className=
'd-flex flex-row align-items-center'
onClick=
{
()
=>
setIsExpanded
(
!
isExpanded
)
}
>
<
div
className=
{
isExpanded
?
'px-1 fas fa-caret-down caret caret_tv'
:
'px-1 fas fa-caret-right caret caret_tv'
}
style=
{
{
visibility
:
children
?
'visible'
:
'hidden'
}
}
></
div
>
{
children
?
<
div
className=
{
isExpanded
?
`px-1 ${iconY} caret caret_tv`
:
`px-1 ${iconX} caret caret_tv`
}
style=
{
{
visibility
:
children
?
'visible'
:
'hidden'
}
}
></
div
>
:
<
div
className=
{
`px-3 ${icon} caret caret_tv`
}
></
div
>
}
<
span
className=
'w-100 pl-1'
>
<
span
className=
'w-100 pl-1'
>
{
label
}
{
label
}
</
span
>
</
span
>
...
...
libs/remix-ui/tree-view/src/types/index.ts
View file @
d40cf221
...
@@ -9,5 +9,8 @@ export interface TreeViewItemProps {
...
@@ -9,5 +9,8 @@ export interface TreeViewItemProps {
label
:
string
|
number
|
React
.
ReactNode
,
label
:
string
|
number
|
React
.
ReactNode
,
expand
?:
boolean
,
expand
?:
boolean
,
onClick
?:
VoidFunction
,
onClick
?:
VoidFunction
,
className
?:
string
className
?:
string
,
iconX
?:
string
,
iconY
?:
string
,
icon
?:
string
}
}
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