Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0304493b
Unverified
Commit
0304493b
authored
Mar 09, 2020
by
Dominik Prokop
Committed by
GitHub
Mar 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DashboardSave: Correctly overwrite dashboard when saving (#22650)
parent
5d8fc6a1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
10 deletions
+41
-10
public/app/features/dashboard/components/SaveDashboard/SaveDashboardAsModal.tsx
+14
-4
public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx
+11
-3
public/app/features/dashboard/components/SaveDashboard/SaveDashboardModal.tsx
+14
-3
public/app/features/dashboard/components/SaveDashboard/useDashboardSave.tsx
+2
-0
No files found.
public/app/features/dashboard/components/SaveDashboard/SaveDashboardAsModal.tsx
View file @
0304493b
import
React
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
css
}
from
'emotion'
;
import
{
Modal
}
from
'@grafana/ui'
;
import
{
SaveDashboardAsForm
}
from
'./forms/SaveDashboardAsForm'
;
...
...
@@ -10,10 +10,17 @@ export const SaveDashboardAsModal: React.FC<SaveDashboardModalProps & {
isNew
?:
boolean
;
}
>
=
({
dashboard
,
onDismiss
,
isNew
})
=>
{
const
{
state
,
onDashboardSave
}
=
useDashboardSave
(
dashboard
);
const
[
dashboardSaveModelClone
,
setDashboardSaveModelClone
]
=
useState
();
return
(
<>
{
state
.
error
&&
<
SaveDashboardErrorProxy
error=
{
state
.
error
}
dashboard=
{
dashboard
}
onDismiss=
{
onDismiss
}
/>
}
{
state
.
error
&&
(
<
SaveDashboardErrorProxy
error=
{
state
.
error
}
dashboard=
{
dashboard
}
dashboardSaveModel=
{
dashboardSaveModelClone
}
onDismiss=
{
onDismiss
}
/>
)
}
{
!
state
.
error
&&
(
<
Modal
isOpen=
{
true
}
...
...
@@ -28,7 +35,10 @@ export const SaveDashboardAsModal: React.FC<SaveDashboardModalProps & {
dashboard=
{
dashboard
}
onCancel=
{
onDismiss
}
onSuccess=
{
onDismiss
}
onSubmit=
{
onDashboardSave
}
onSubmit=
{
(
clone
,
options
,
dashboard
)
=>
{
setDashboardSaveModelClone
(
clone
);
return
onDashboardSave
(
clone
,
options
,
dashboard
);
}
}
isNew=
{
isNew
}
/>
</
Modal
>
...
...
public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx
View file @
0304493b
...
...
@@ -8,12 +8,20 @@ import { SaveDashboardModalProps } from './types';
import
{
SaveDashboardAsButton
}
from
'./SaveDashboardButton'
;
interface
SaveDashboardErrorProxyProps
{
/** original dashboard */
dashboard
:
DashboardModel
;
/** dashboard save model with applied modifications, i.e. title */
dashboardSaveModel
:
any
;
error
:
any
;
onDismiss
:
()
=>
void
;
}
export
const
SaveDashboardErrorProxy
:
React
.
FC
<
SaveDashboardErrorProxyProps
>
=
({
dashboard
,
error
,
onDismiss
})
=>
{
export
const
SaveDashboardErrorProxy
:
React
.
FC
<
SaveDashboardErrorProxyProps
>
=
({
dashboard
,
dashboardSaveModel
,
error
,
onDismiss
,
})
=>
{
const
{
onDashboardSave
}
=
useDashboardSave
(
dashboard
);
useEffect
(()
=>
{
...
...
@@ -35,7 +43,7 @@ export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = (
}
confirmText=
"Save & Overwrite"
onConfirm=
{
async
()
=>
{
await
onDashboardSave
(
dashboard
.
getSaveModelClone
()
,
{
overwrite
:
true
},
dashboard
);
await
onDashboardSave
(
dashboard
SaveModel
,
{
overwrite
:
true
},
dashboard
);
onDismiss
();
}
}
onDismiss=
{
onDismiss
}
...
...
@@ -53,7 +61,7 @@ export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = (
}
confirmText=
"Save & Overwrite"
onConfirm=
{
async
()
=>
{
await
onDashboardSave
(
dashboard
.
getSaveModelClone
()
,
{
overwrite
:
true
},
dashboard
);
await
onDashboardSave
(
dashboard
SaveModel
,
{
overwrite
:
true
},
dashboard
);
onDismiss
();
}
}
onDismiss=
{
onDismiss
}
...
...
public/app/features/dashboard/components/SaveDashboard/SaveDashboardModal.tsx
View file @
0304493b
import
React
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Modal
}
from
'@grafana/ui'
;
import
{
css
}
from
'emotion'
;
import
{
SaveDashboardForm
}
from
'./forms/SaveDashboardForm'
;
...
...
@@ -8,9 +8,17 @@ import { SaveDashboardModalProps } from './types';
export
const
SaveDashboardModal
:
React
.
FC
<
SaveDashboardModalProps
>
=
({
dashboard
,
onDismiss
,
onSaveSuccess
})
=>
{
const
{
state
,
onDashboardSave
}
=
useDashboardSave
(
dashboard
);
const
[
dashboardSaveModelClone
,
setDashboardSaveModelClone
]
=
useState
();
return
(
<>
{
state
.
error
&&
<
SaveDashboardErrorProxy
error=
{
state
.
error
}
dashboard=
{
dashboard
}
onDismiss=
{
onDismiss
}
/>
}
{
state
.
error
&&
(
<
SaveDashboardErrorProxy
error=
{
state
.
error
}
dashboard=
{
dashboard
}
dashboardSaveModel=
{
dashboardSaveModelClone
}
onDismiss=
{
onDismiss
}
/>
)
}
{
!
state
.
error
&&
(
<
Modal
isOpen=
{
true
}
...
...
@@ -30,7 +38,10 @@ export const SaveDashboardModal: React.FC<SaveDashboardModalProps> = ({ dashboar
onSaveSuccess
();
}
}
}
onSubmit=
{
onDashboardSave
}
onSubmit=
{
(
clone
,
options
,
dashboard
)
=>
{
setDashboardSaveModelClone
(
clone
);
return
onDashboardSave
(
clone
,
options
,
dashboard
);
}
}
/>
</
Modal
>
)
}
...
...
public/app/features/dashboard/components/SaveDashboard/useDashboardSave.tsx
View file @
0304493b
...
...
@@ -39,6 +39,8 @@ export const useDashboardSave = (dashboard: DashboardModel) => {
dispatch
(
updateLocation
({
path
:
newUrl
,
replace
:
true
,
query
:
{},
})
);
}
...
...
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