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
d4239e6f
Unverified
Commit
d4239e6f
authored
Jun 30, 2020
by
Ryan McKinley
Committed by
GitHub
Jun 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Monaco: option to hide line numbers (#25920)
parent
bbce01de
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
15 deletions
+34
-15
packages/grafana-ui/src/components/Monaco/CodeEditor.story.internal.tsx
+8
-2
packages/grafana-ui/src/components/Monaco/CodeEditor.tsx
+21
-11
public/app/features/dashboard/components/Inspector/InspectJSONTab.tsx
+4
-2
public/app/plugins/panel/text/TextPanelEditor.tsx
+1
-0
No files found.
packages/grafana-ui/src/components/Monaco/CodeEditor.story.internal.tsx
View file @
d4239e6f
import
React
from
'react'
;
import
React
from
'react'
;
import
{
number
,
text
}
from
'@storybook/addon-knobs'
;
import
{
number
,
text
,
boolean
}
from
'@storybook/addon-knobs'
;
import
{
action
}
from
'@storybook/addon-actions'
;
import
{
action
}
from
'@storybook/addon-actions'
;
import
{
withCenteredStory
}
from
'../../utils/storybook/withCenteredStory'
;
import
{
withCenteredStory
}
from
'../../utils/storybook/withCenteredStory'
;
import
mdx
from
'./CodeEditor.mdx'
;
import
mdx
from
'./CodeEditor.mdx'
;
...
@@ -24,6 +24,9 @@ const getKnobs = () => {
...
@@ -24,6 +24,9 @@ const getKnobs = () => {
containerWidth
,
containerWidth
,
text
:
text
(
'Body'
,
'SELECT * FROM table LIMIT 10'
),
text
:
text
(
'Body'
,
'SELECT * FROM table LIMIT 10'
),
language
:
text
(
'Language'
,
'sql'
),
language
:
text
(
'Language'
,
'sql'
),
showLineNumbers
:
boolean
(
'Show line numbers'
,
false
),
showMiniMap
:
boolean
(
'Show mini map'
,
false
),
readOnly
:
boolean
(
'readonly'
,
false
),
};
};
};
};
...
@@ -39,7 +42,7 @@ export default {
...
@@ -39,7 +42,7 @@ export default {
};
};
export
const
basic
=
()
=>
{
export
const
basic
=
()
=>
{
const
{
containerWidth
,
text
,
language
}
=
getKnobs
();
const
{
containerWidth
,
text
,
language
,
showLineNumbers
,
showMiniMap
,
readOnly
}
=
getKnobs
();
return
(
return
(
<
CodeEditor
<
CodeEditor
width=
{
containerWidth
}
width=
{
containerWidth
}
...
@@ -52,6 +55,9 @@ export const basic = () => {
...
@@ -52,6 +55,9 @@ export const basic = () => {
onSave=
{
(
text
:
string
)
=>
{
onSave=
{
(
text
:
string
)
=>
{
action
(
'code saved'
)(
text
);
action
(
'code saved'
)(
text
);
}
}
}
}
showLineNumbers=
{
showLineNumbers
}
showMiniMap=
{
showMiniMap
}
readOnly=
{
readOnly
}
/>
/>
);
);
};
};
packages/grafana-ui/src/components/Monaco/CodeEditor.tsx
View file @
d4239e6f
...
@@ -12,6 +12,7 @@ export interface CodeEditorProps {
...
@@ -12,6 +12,7 @@ export interface CodeEditorProps {
readOnly
?:
boolean
;
readOnly
?:
boolean
;
showMiniMap
?:
boolean
;
showMiniMap
?:
boolean
;
showLineNumbers
?:
boolean
;
/**
/**
* Callback after the editor has mounted that gives you raw access to monaco
* Callback after the editor has mounted that gives you raw access to monaco
...
@@ -56,19 +57,11 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
...
@@ -56,19 +57,11 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
};
};
render
()
{
render
()
{
const
{
theme
,
language
,
width
,
height
,
showMiniMap
,
readOnly
}
=
this
.
props
;
const
{
theme
,
language
,
width
,
height
,
showMiniMap
,
showLineNumbers
,
readOnly
}
=
this
.
props
;
const
value
=
this
.
props
.
value
??
''
;
const
value
=
this
.
props
.
value
??
''
;
const
longText
=
value
.
length
>
100
;
const
longText
=
value
.
length
>
100
;
return
(
const
options
:
editor
.
IEditorConstructionOptions
=
{
<
div
onBlur=
{
this
.
onBlur
}
>
<
ReactMonaco
width=
{
width
}
height=
{
height
}
language=
{
language
}
theme=
{
theme
.
isDark
?
'vs-dark'
:
'vs-light'
}
value=
{
value
}
options=
{
{
wordWrap
:
'off'
,
wordWrap
:
'off'
,
codeLens
:
false
,
// not included in the bundle
codeLens
:
false
,
// not included in the bundle
minimap
:
{
minimap
:
{
...
@@ -80,7 +73,24 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
...
@@ -80,7 +73,24 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
lineDecorationsWidth
:
0
,
lineDecorationsWidth
:
0
,
overviewRulerBorder
:
false
,
overviewRulerBorder
:
false
,
automaticLayout
:
true
,
automaticLayout
:
true
,
}
}
};
if
(
!
showLineNumbers
)
{
options
.
glyphMargin
=
false
;
options
.
folding
=
false
;
options
.
lineNumbers
=
'off'
;
options
.
lineDecorationsWidth
=
5
;
// left margin when not showing line numbers
options
.
lineNumbersMinChars
=
0
;
}
return
(
<
div
onBlur=
{
this
.
onBlur
}
>
<
ReactMonaco
width=
{
width
}
height=
{
height
}
language=
{
language
}
theme=
{
theme
.
isDark
?
'vs-dark'
:
'vs-light'
}
value=
{
value
}
options=
{
options
}
editorDidMount=
{
this
.
editorDidMount
}
editorDidMount=
{
this
.
editorDidMount
}
/>
/>
</
div
>
</
div
>
...
...
public/app/features/dashboard/components/Inspector/InspectJSONTab.tsx
View file @
d4239e6f
...
@@ -116,7 +116,7 @@ export class InspectJSONTab extends PureComponent<Props, State> {
...
@@ -116,7 +116,7 @@ export class InspectJSONTab extends PureComponent<Props, State> {
render
()
{
render
()
{
const
{
dashboard
}
=
this
.
props
;
const
{
dashboard
}
=
this
.
props
;
const
{
show
}
=
this
.
state
;
const
{
show
,
text
}
=
this
.
state
;
const
selected
=
options
.
find
(
v
=>
v
.
value
===
show
);
const
selected
=
options
.
find
(
v
=>
v
.
value
===
show
);
const
isPanelJSON
=
show
===
ShowContent
.
PanelJSON
;
const
isPanelJSON
=
show
===
ShowContent
.
PanelJSON
;
const
canEdit
=
dashboard
.
meta
.
canEdit
;
const
canEdit
=
dashboard
.
meta
.
canEdit
;
...
@@ -141,7 +141,9 @@ export class InspectJSONTab extends PureComponent<Props, State> {
...
@@ -141,7 +141,9 @@ export class InspectJSONTab extends PureComponent<Props, State> {
width=
"100%"
width=
"100%"
height=
{
height
}
height=
{
height
}
language=
"json"
language=
"json"
value=
{
this
.
state
.
text
}
showLineNumbers=
{
true
}
showMiniMap=
{
text
&&
text
.
length
>
100
}
value=
{
text
||
''
}
readOnly=
{
!
isPanelJSON
}
readOnly=
{
!
isPanelJSON
}
onBlur=
{
this
.
onTextChanged
}
onBlur=
{
this
.
onTextChanged
}
/>
/>
...
...
public/app/plugins/panel/text/TextPanelEditor.tsx
View file @
d4239e6f
...
@@ -26,6 +26,7 @@ export const TextPanelEditor: FC<StandardEditorProps<string, any, TextOptions>>
...
@@ -26,6 +26,7 @@ export const TextPanelEditor: FC<StandardEditorProps<string, any, TextOptions>>
language=
{
language
}
language=
{
language
}
width=
{
width
}
width=
{
width
}
showMiniMap=
{
false
}
showMiniMap=
{
false
}
showLineNumbers=
{
false
}
height=
"200px"
height=
"200px"
/>
/>
);
);
...
...
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