66
77import {
88 EuiButton ,
9+ EuiCodeBlock ,
910 EuiFlexGroup ,
1011 EuiFlexItem ,
11- EuiLink ,
12- EuiLoadingSpinner ,
1312 EuiModal ,
1413 EuiModalBody ,
1514 EuiModalFooter ,
@@ -18,18 +17,18 @@ import {
1817 EuiOverlayMask ,
1918 EuiPanel ,
2019 EuiSpacer ,
20+ EuiTabbedContent ,
2121 EuiText ,
2222 EuiTextColor ,
2323} from '@elastic/eui' ;
2424import React from 'react' ;
2525import { connect } from 'react-redux' ;
2626import styled from 'styled-components' ;
27+ import { InstallationType } from '../../../common/installation' ;
2728import { LanguageServer , LanguageServerStatus } from '../../../common/language_server' ;
2829import { requestInstallLanguageServer } from '../../actions/language_server' ;
2930import { RootState } from '../../reducers' ;
3031import { JavaIcon , TypeScriptIcon } from '../shared/icons' ;
31- const JAVA_URL =
32- 'https://download.elasticsearch.org/code/java-langserver/snapshot/java_languageserver-1.0.0-SNAPSHOT-darwin.zip' ;
3332
3433const LanguageServerState = styled ( EuiTextColor ) `
3534 color: ${ props => props . color } ;
@@ -55,25 +54,17 @@ const LanguageServerLi = (props: {
5554 let state = null ;
5655 if ( status === LanguageServerStatus . RUNNING ) {
5756 state = < LanguageServerState > Running ...</ LanguageServerState > ;
58- button = (
59- < EuiButton size = "s" color = "secondary" onClick = { onInstallClick } >
60- Re-install
61- </ EuiButton >
62- ) ;
6357 } else if ( status === LanguageServerStatus . NOT_INSTALLED ) {
6458 state = < LanguageServerState color = { 'subdued' } > Not Installed</ LanguageServerState > ;
65- button = props . loading ? (
66- < EuiButton size = "s" color = "secondary" >
67- < EuiLoadingSpinner size = "s" />
68- Installing
69- </ EuiButton >
70- ) : (
59+ } else if ( status === LanguageServerStatus . READY ) {
60+ state = < LanguageServerState color = { 'subdued' } > Installed</ LanguageServerState > ;
61+ }
62+ if ( props . languageServer . installationType === InstallationType . Plugin ) {
63+ button = (
7164 < EuiButton size = "s" color = "secondary" onClick = { onInstallClick } >
72- Install
65+ Setup
7366 </ EuiButton >
7467 ) ;
75- } else if ( status === LanguageServerStatus . READY ) {
76- state = < LanguageServerState color = { 'subdued' } > Installed</ LanguageServerState > ;
7768 }
7869 return (
7970 < EuiFlexItem >
@@ -108,6 +99,7 @@ interface State {
10899 showingInstruction : boolean ;
109100 name ?: string ;
110101 url ?: string ;
102+ pluginName ?: string ;
111103}
112104
113105class AdminLanguageSever extends React . PureComponent < Props , State > {
@@ -116,22 +108,22 @@ class AdminLanguageSever extends React.PureComponent<Props, State> {
116108 this . state = { showingInstruction : false } ;
117109 }
118110
119- public toggleInstruction = ( showingInstruction : boolean , name ?: string , url ?: string ) => {
120- this . setState ( { showingInstruction, name, url } ) ;
111+ public toggleInstruction = (
112+ showingInstruction : boolean ,
113+ name ?: string ,
114+ url ?: string ,
115+ pluginName ?: string
116+ ) => {
117+ this . setState ( { showingInstruction, name, url, pluginName } ) ;
121118 } ;
122119
123120 public render ( ) {
124121 const languageServers = this . props . languageServers . map ( ls => (
125122 < LanguageServerLi
126123 languageServer = { ls }
127124 key = { ls . name }
128- requestInstallLanguageServer = {
129- ( ) =>
130- this . toggleInstruction (
131- true ,
132- ls . name ,
133- JAVA_URL
134- ) /*this.props.requestInstallLanguageServer*/
125+ requestInstallLanguageServer = { ( ) =>
126+ this . toggleInstruction ( true , ls . name , ls . downloadUrl , ls . pluginName )
135127 }
136128 loading = { this . props . installLoading [ ls . name ] }
137129 />
@@ -156,6 +148,7 @@ class AdminLanguageSever extends React.PureComponent<Props, State> {
156148 < LanguageServerInstruction
157149 show = { this . state . showingInstruction }
158150 name = { this . state . name ! }
151+ pluginName = { this . state . pluginName ! }
159152 url = { this . state . url ! }
160153 close = { ( ) => this . toggleInstruction ( false ) }
161154 />
@@ -164,36 +157,57 @@ class AdminLanguageSever extends React.PureComponent<Props, State> {
164157 }
165158}
166159
160+ const SupportedOS = [
161+ { id : 'win' , name : 'Windows' } ,
162+ { id : 'linux' , name : 'Linux' } ,
163+ { id : 'darwin' , name : 'macOS' } ,
164+ ] ;
165+
167166const LanguageServerInstruction = ( props : {
168167 name : string ;
168+ pluginName : string ;
169169 url : string ;
170170 show : boolean ;
171171 close : ( ) => void ;
172172} ) => {
173+ const tabs = SupportedOS . map ( ( { id, name } ) => {
174+ const url = props . url ? props . url . replace ( '$OS' , id ) : '' ;
175+ const installCode = `bin/kibana-plugin install ${ url } ` ;
176+ return {
177+ id,
178+ name,
179+ content : (
180+ < EuiText grow = { false } >
181+ < h3 > Install</ h3 >
182+ < p >
183+ Stop your kibana Code node, then use the following command to install ${ props . name } { ' ' }
184+ Language Server plugin:
185+ < EuiCodeBlock language = "shell" > { installCode } </ EuiCodeBlock >
186+ </ p >
187+ < h3 > Uninstall</ h3 >
188+ < p >
189+ Stop your kibana Code node, then use the following command to remove ${ props . name } { ' ' }
190+ Language Server plugin:
191+ < pre >
192+ < code > bin/kibana-plugin remove { props . pluginName } </ code >
193+ </ pre >
194+ </ p >
195+ </ EuiText >
196+ ) ,
197+ } ;
198+ } ) ;
199+
173200 return (
174201 < React . Fragment >
175202 { ' ' }
176203 { props . show && (
177204 < EuiOverlayMask >
178- < EuiModal onClose = { props . close } >
205+ < EuiModal onClose = { props . close } maxWidth = { false } >
179206 < EuiModalHeader >
180207 < EuiModalHeaderTitle > Install Instruction</ EuiModalHeaderTitle >
181208 </ EuiModalHeader >
182209 < EuiModalBody >
183- < EuiText grow = { false } >
184- < h3 > Download</ h3 >
185- < p >
186- Download { props . name } language server plugin from
187- < EuiLink href = { props . url } > here.</ EuiLink >
188- </ p >
189- < h3 > Install</ h3 >
190- < p >
191- Stop your kibana code node. Install it using kibana-plugin command.
192- < pre >
193- < code > bin/kibana-plugin install { JAVA_URL } </ code >
194- </ pre >
195- </ p >
196- </ EuiText >
210+ < EuiTabbedContent tabs = { tabs } initialSelectedTab = { tabs [ 1 ] } size = { 'm' } />
197211 </ EuiModalBody >
198212 < EuiModalFooter >
199213 < EuiButton onClick = { props . close } fill >
0 commit comments