Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Kempe
Meerkat
Commits
084a9d1b
Commit
084a9d1b
authored
Aug 24, 2020
by
StreatCodes
Browse files
Add feedback when clicking save
parent
902a56a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/editor.jsx
View file @
084a9d1b
import
{
h
,
Fragment
}
from
'
preact
'
;
import
{
route
}
from
'
preact-router
'
;
import
{
useEffect
,
useReducer
}
from
'
preact/hooks
'
;
import
{
useEffect
,
useReducer
,
useState
}
from
'
preact/hooks
'
;
import
*
as
meerkat
from
'
./meerkat
'
import
{
routeParam
,
removeParam
,
TagEditor
}
from
'
./util
'
;
...
...
@@ -62,6 +62,7 @@ const dashboardReducer = (state, action) => {
//Edit page
export
function
Editor
({
slug
,
selectedElementId
})
{
const
[
dashboard
,
dashboardDispatch
]
=
useReducer
(
dashboardReducer
,
null
);
const
[
savingDashboard
,
setSavingDashboard
]
=
useState
(
false
);
useEffect
(()
=>
{
meerkat
.
getDashboard
(
slug
).
then
(
async
d
=>
{
...
...
@@ -87,6 +88,7 @@ export function Editor({slug, selectedElementId}) {
}
const
saveDashboard
=
async
e
=>
{
setSavingDashboard
(
true
);
console
.
log
(
dashboard
);
try
{
const
data
=
await
meerkat
.
saveDashboard
(
slug
,
dashboard
);
...
...
@@ -97,6 +99,7 @@ export function Editor({slug, selectedElementId}) {
console
.
log
(
'
error saving dashboard:
'
);
console
.
log
(
e
);
}
setSavingDashboard
(
false
);
}
return
<
Fragment
>
...
...
@@ -115,7 +118,7 @@ export function Editor({slug, selectedElementId}) {
</
div
>
<
div
class
=
"side-bar-footer lefty-righty"
>
<
button
class
=
"hollow"
onClick
=
{
e
=>
route
(
'
/
'
)
}
>
Home
</
button
>
<
button
onClick
=
{
saveDashboard
}
>
Save Dashboard
</
button
>
<
button
onClick
=
{
saveDashboard
}
class
=
{
savingDashboard
?
'
loading
'
:
''
}
>
Save Dashboard
</
button
>
</
div
>
</
Fragment
>
}
...
...
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