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
6fd03b1f
Commit
6fd03b1f
authored
Aug 23, 2021
by
joseph izang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add localPlugin Form state fix
parent
860f24a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
+43
-4
LocalPluginForm.tsx
...-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
+4
-4
useLocalStorage.ts
...ui/plugin-manager/src/lib/custom-hooks/useLocalStorage.ts
+36
-0
tsconfig.lib.json
libs/remix-ui/plugin-manager/tsconfig.lib.json
+3
-0
No files found.
libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
View file @
6fd03b1f
...
@@ -97,7 +97,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
...
@@ -97,7 +97,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
<
input
<
input
className=
"form-control"
className=
"form-control"
onChange=
{
e
=>
setName
(
e
.
target
.
value
)
}
onChange=
{
e
=>
setName
(
e
.
target
.
value
)
}
value=
{
name
}
value=
{
name
||
defaultPlugin
.
name
}
id=
"plugin-name"
id=
"plugin-name"
data
-
id=
"localPluginName"
data
-
id=
"localPluginName"
placeholder=
"Should be camelCase"
/>
placeholder=
"Should be camelCase"
/>
...
@@ -107,7 +107,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
...
@@ -107,7 +107,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
<
input
<
input
className=
"form-control"
className=
"form-control"
onChange=
{
e
=>
setDisplayName
(
e
.
target
.
value
)
}
onChange=
{
e
=>
setDisplayName
(
e
.
target
.
value
)
}
value=
{
displayName
}
value=
{
displayName
||
defaultPlugin
.
displayName
}
id=
"plugin-displayname"
id=
"plugin-displayname"
data
-
id=
"localPluginDisplayName"
data
-
id=
"localPluginDisplayName"
placeholder=
"Name in the header"
/>
placeholder=
"Name in the header"
/>
...
@@ -117,7 +117,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
...
@@ -117,7 +117,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
<
input
<
input
className=
"form-control"
className=
"form-control"
onChange=
{
e
=>
setMethods
(
e
.
target
.
value
)
}
onChange=
{
e
=>
setMethods
(
e
.
target
.
value
)
}
value=
{
methods
}
value=
{
methods
||
defaultPlugin
.
methods
}
id=
"plugin-methods"
id=
"plugin-methods"
data
-
id=
"localPluginMethods"
data
-
id=
"localPluginMethods"
placeholder=
"Name in the header"
/>
placeholder=
"Name in the header"
/>
...
@@ -128,7 +128,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
...
@@ -128,7 +128,7 @@ function LocalPluginForm ({ closeModal, visible, pluginManager }: LocalPluginFor
<
input
<
input
className=
"form-control"
className=
"form-control"
onChange=
{
e
=>
setUrl
(
e
.
target
.
value
)
}
onChange=
{
e
=>
setUrl
(
e
.
target
.
value
)
}
value=
{
url
}
value=
{
url
||
defaultPlugin
.
url
}
id=
"plugin-url"
id=
"plugin-url"
data
-
id=
"localPluginUrl"
data
-
id=
"localPluginUrl"
placeholder=
"ex: https://localhost:8000"
/>
placeholder=
"ex: https://localhost:8000"
/>
...
...
libs/remix-ui/plugin-manager/src/lib/custom-hooks/useLocalStorage.ts
0 → 100644
View file @
6fd03b1f
import
{
useState
}
from
'react'
// Hook
export
const
useLocalStorage
=
(
key
:
string
,
initialValue
:
any
)
=>
{
// State to store our value
// Pass initial state function to useState so logic is only executed once
const
[
storedValue
,
setStoredValue
]
=
useState
<
any
>
(()
=>
{
try
{
// Get from local storage by key
const
item
=
window
.
localStorage
.
getItem
(
key
)
// Parse stored json or if none return initialValue
return
item
?
JSON
.
parse
(
item
)
:
initialValue
}
catch
(
error
)
{
// If error also return initialValue
console
.
log
(
error
)
return
initialValue
}
})
// Return a wrapped version of useState's setter function that ...
// ... persists the new value to localStorage.
const
setValue
=
(
value
:
any
|
((
val
:
any
)
=>
any
))
=>
{
try
{
// Allow value to be a function so we have same API as useState
const
valueToStore
=
value
instanceof
Function
?
value
(
storedValue
)
:
value
// Save state
setStoredValue
(
valueToStore
)
// Save to local storage
window
.
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
valueToStore
))
}
catch
(
error
)
{
// A more advanced implementation would handle the error case
console
.
log
(
error
)
}
}
return
[
storedValue
,
setValue
]
as
const
}
libs/remix-ui/plugin-manager/tsconfig.lib.json
View file @
6fd03b1f
{
{
"extends"
:
"../../../tsconfig.base.json"
,
"extends"
:
"../../../tsconfig.base.json"
,
"compilerOptions"
:
{
"compilerOptions"
:
{
"jsx"
:
"react"
,
"composite"
:
true
,
"outDir"
:
"../../../dist/out-tsc"
,
"outDir"
:
"../../../dist/out-tsc"
,
"types"
:
[
"node"
]
"types"
:
[
"node"
]
},
},
"files"
:
[],
"files"
:
[],
"composite"
:
true
,
"exclude"
:
[
"**/*.spec.ts"
,
"**/*.spec.tsx"
],
"exclude"
:
[
"**/*.spec.ts"
,
"**/*.spec.tsx"
],
"include"
:
[
"**/*.js"
,
"**/*.jsx"
,
"**/*.ts"
,
"**/*.tsx"
],
"include"
:
[
"**/*.js"
,
"**/*.jsx"
,
"**/*.ts"
,
"**/*.tsx"
],
"references"
:
[
"references"
:
[
...
...
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