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
16a1d2f7
Unverified
Commit
16a1d2f7
authored
Oct 30, 2020
by
Torkel Ödegaard
Committed by
GitHub
Oct 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TextPanel: Fixes problems where text panel would show old content (#28643)
parent
5a83fc57
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
public/app/plugins/panel/text/textPanelMigrationHandler.test.ts
+18
-0
public/app/plugins/panel/text/textPanelMigrationHandler.ts
+14
-6
No files found.
public/app/plugins/panel/text/textPanelMigrationHandler.test.ts
View file @
16a1d2f7
...
...
@@ -8,12 +8,30 @@ describe('textPanelMigrationHandler', () => {
const
panel
:
any
=
{
content
:
'<span>Hello World<span>'
,
mode
:
'html'
,
options
:
{},
};
const
result
=
textPanelMigrationHandler
(
panel
);
expect
(
result
.
content
).
toEqual
(
'<span>Hello World<span>'
);
expect
(
result
.
mode
).
toEqual
(
'html'
);
expect
(
panel
.
content
).
toBeUndefined
();
expect
(
panel
.
mode
).
toBeUndefined
();
});
});
describe
(
'when invoked and previous version 7.1 or later'
,
()
=>
{
it
(
'then not migrate options'
,
()
=>
{
const
panel
:
any
=
{
content
:
'<span>Hello World<span>'
,
mode
:
'html'
,
options
:
{
content
:
'New content'
},
pluginVersion
:
'7.1.0'
,
};
const
result
=
textPanelMigrationHandler
(
panel
);
expect
(
result
.
content
).
toEqual
(
'New content'
);
});
});
...
...
public/app/plugins/panel/text/textPanelMigrationHandler.ts
View file @
16a1d2f7
...
...
@@ -2,19 +2,27 @@ import { PanelModel } from '@grafana/data';
import
{
TextMode
,
TextOptions
}
from
'./types'
;
export
const
textPanelMigrationHandler
=
(
panel
:
PanelModel
<
TextOptions
>
):
Partial
<
TextOptions
>
=>
{
const
previousVersion
=
parseFloat
(
panel
.
pluginVersion
||
'6.1'
);
let
options
=
panel
.
options
;
// Migrates old Angular based text panel props to new props
if
(
panel
.
hasOwnProperty
(
'content'
)
&&
panel
.
hasOwnProperty
(
'mode'
))
{
const
oldTextPanel
:
{
content
:
string
;
mode
:
string
}
=
(
panel
as
unknown
)
as
any
;
const
oldTextPanel
:
any
=
panel
as
any
;
const
content
=
oldTextPanel
.
content
;
const
mode
=
(
oldTextPanel
.
mode
as
unknown
)
as
TextMode
;
const
mode
=
oldTextPanel
.
mode
as
TextMode
;
delete
oldTextPanel
.
content
;
delete
oldTextPanel
.
mode
;
return
{
content
,
mode
};
if
(
previousVersion
<
7.1
)
{
options
=
{
content
,
mode
};
}
}
// The 'text' mode has been removed so we need to update any panels still using it to markdown
if
(
panel
.
options
.
mode
!==
'html'
&&
panel
.
options
.
mode
!==
'markdown'
)
{
return
{
content
:
panel
.
options
.
content
,
mode
:
'markdown'
};
if
(
options
.
mode
!==
'html'
&&
options
.
mode
!==
'markdown'
)
{
options
=
{
...
options
,
mode
:
'markdown'
};
}
return
panel
.
options
;
return
options
;
};
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