diff --git a/x-pack/plugins/code/index.ts b/x-pack/plugins/code/index.ts index 4c39012e4e584..1b48a6b011832 100644 --- a/x-pack/plugins/code/index.ts +++ b/x-pack/plugins/code/index.ts @@ -21,7 +21,6 @@ export const code = (kibana: any) => uiExports: { app: { title: 'Code', - description: 'Code Search Plugin', main: 'plugins/code/app', euiIconType: 'codeApp', }, diff --git a/x-pack/plugins/code/public/components/admin_page/admin.tsx b/x-pack/plugins/code/public/components/admin_page/admin.tsx index d594c459d140a..20ee4ff8ea86a 100644 --- a/x-pack/plugins/code/public/components/admin_page/admin.tsx +++ b/x-pack/plugins/code/public/components/admin_page/admin.tsx @@ -4,13 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ +import { EuiTab, EuiTabs } from '@elastic/eui'; import React from 'react'; - import { connect } from 'react-redux'; - -import { EuiTab, EuiTabs } from '@elastic/eui'; - import styled from 'styled-components'; +import url from 'url'; import theme from '@elastic/eui/dist/eui_theme_light.json'; import { parse as parseQuery } from 'querystring'; @@ -91,7 +89,7 @@ class AdminPage extends React.PureComponent { public getAdminTabClickHandler = (tab: AdminTabs) => () => { this.setState({ tab }); - this.props.history.push(`/admin?tab=${tab}`); + this.props.history.push(url.format({ pathname: '/admin', query: { tab } })); }; public renderTabs() { diff --git a/x-pack/plugins/code/public/components/diff_page/diff.tsx b/x-pack/plugins/code/public/components/diff_page/diff.tsx index ab8424a739660..4492f370c1ed6 100644 --- a/x-pack/plugins/code/public/components/diff_page/diff.tsx +++ b/x-pack/plugins/code/public/components/diff_page/diff.tsx @@ -10,8 +10,8 @@ import React, { MouseEvent } from 'react'; import { connect } from 'react-redux'; import { Link, RouteComponentProps, withRouter } from 'react-router-dom'; import styled from 'styled-components'; -import { SearchScope } from 'x-pack/plugins/code/model'; import { CommitDiff, FileDiff } from '../../../common/git_diff'; +import { SearchScope } from '../../../model'; import { changeSearchScope } from '../../actions'; import { RootState } from '../../reducers'; import { SearchBar } from '../search_page/search_bar'; diff --git a/x-pack/plugins/code/public/components/main/content.tsx b/x-pack/plugins/code/public/components/main/content.tsx index 66ad7919114bc..7edccea5a8258 100644 --- a/x-pack/plugins/code/public/components/main/content.tsx +++ b/x-pack/plugins/code/public/components/main/content.tsx @@ -14,6 +14,7 @@ import { connect } from 'react-redux'; import { RouteComponentProps } from 'react-router-dom'; import { withRouter } from 'react-router-dom'; import styled from 'styled-components'; +import chrome from 'ui/chrome'; import { RepositoryUtils } from '../../../common/repository_utils'; import { FileTree, FileTreeItemType, SearchScope, WorkerReservedProgress } from '../../../model'; @@ -157,7 +158,7 @@ class CodeContent extends React.PureComponent { public openRawFile = () => { const { path, resource, org, repo, revision } = this.props.match.params; const repoUri = `${resource}/${org}/${repo}`; - window.open(`../api/code/repo/${repoUri}/blob/${revision}/${path}`); + window.open(chrome.addBasePath(`/app/code/repo/${repoUri}/raw/${revision}/${path}`)); }; public renderButtons = () => { diff --git a/x-pack/plugins/code/public/components/main/search_bar.tsx b/x-pack/plugins/code/public/components/main/search_bar.tsx index 4de5eafa42155..438254a966236 100644 --- a/x-pack/plugins/code/public/components/main/search_bar.tsx +++ b/x-pack/plugins/code/public/components/main/search_bar.tsx @@ -4,9 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ +import { ParsedUrlQuery } from 'querystring'; import React from 'react'; import { RouteComponentProps, withRouter } from 'react-router-dom'; import styled from 'styled-components'; +import url from 'url'; + import { SearchScope } from '../../../model'; import { MainRouteParams, SearchScopeText } from '../../common/types'; import { @@ -40,20 +43,21 @@ export class CodeSearchBar extends React.Component { new RepositorySuggestionsProvider(), ]; - public onSubmit = (query: string) => { + public onSubmit = (queryString: string) => { const { history } = this.props; - if (query.trim().length === 0) { + if (queryString.trim().length === 0) { return; } - let qs = ''; + const query: ParsedUrlQuery = { + q: queryString, + }; if (this.props.repoScope) { - qs = `&repoScope=${this.props.repoScope.join(',')}`; + query.repoScope = this.props.repoScope.join(','); } if (this.state.searchScope === SearchScope.REPOSITORY) { - history.push(`/search?q=${query}&scope=${SearchScope.REPOSITORY}${qs}`); - } else { - history.push(`/search?q=${query}${qs}`); + query.scope = SearchScope.REPOSITORY; } + history.push(url.format({ pathname: '/search', query })); }; public onSelect = (item: AutocompleteSuggestion) => { diff --git a/x-pack/plugins/code/public/components/query_bar/components/typeahead/suggestions_component.tsx b/x-pack/plugins/code/public/components/query_bar/components/typeahead/suggestions_component.tsx index fc855929f26ee..a52a04b974339 100644 --- a/x-pack/plugins/code/public/components/query_bar/components/typeahead/suggestions_component.tsx +++ b/x-pack/plugins/code/public/components/query_bar/components/typeahead/suggestions_component.tsx @@ -8,7 +8,7 @@ import { EuiFlexGroup, EuiText, EuiToken, IconType } from '@elastic/eui'; import { isEmpty } from 'lodash'; import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -import Url from 'url'; +import url from 'url'; import { AutocompleteSuggestion, @@ -102,7 +102,7 @@ export class SuggestionsComponent extends Component { ); - const viewMoreUrl = Url.format({ + const viewMoreUrl = url.format({ pathname: '/search', query: { q: this.props.query, diff --git a/x-pack/plugins/code/public/components/query_bar/suggestions/file_suggestions_provider.ts b/x-pack/plugins/code/public/components/query_bar/suggestions/file_suggestions_provider.ts index 008937b5c2bd9..38226f03ddb27 100644 --- a/x-pack/plugins/code/public/components/query_bar/suggestions/file_suggestions_provider.ts +++ b/x-pack/plugins/code/public/components/query_bar/suggestions/file_suggestions_provider.ts @@ -28,7 +28,7 @@ export class FileSuggestionsProvider extends AbstractSuggestionsProvider { queryParams.repoScope = repoScope.join(','); } const res = await kfetch({ - pathname: `../api/code/suggestions/doc`, + pathname: `/api/code/suggestions/doc`, method: 'get', query: queryParams, }); diff --git a/x-pack/plugins/code/public/components/query_bar/suggestions/repository_suggestions_provider.ts b/x-pack/plugins/code/public/components/query_bar/suggestions/repository_suggestions_provider.ts index 6407670cdc086..3079a2c7f0429 100644 --- a/x-pack/plugins/code/public/components/query_bar/suggestions/repository_suggestions_provider.ts +++ b/x-pack/plugins/code/public/components/query_bar/suggestions/repository_suggestions_provider.ts @@ -29,7 +29,7 @@ export class RepositorySuggestionsProvider extends AbstractSuggestionsProvider { queryParams.repoScope = repoScope.join(','); } const res = await kfetch({ - pathname: `../api/code/suggestions/repo`, + pathname: `/api/code/suggestions/repo`, method: 'get', query: queryParams, }); diff --git a/x-pack/plugins/code/public/components/query_bar/suggestions/symbol_suggestions_provider.ts b/x-pack/plugins/code/public/components/query_bar/suggestions/symbol_suggestions_provider.ts index 11bb739a0c5f1..f1f80b6a1edf4 100644 --- a/x-pack/plugins/code/public/components/query_bar/suggestions/symbol_suggestions_provider.ts +++ b/x-pack/plugins/code/public/components/query_bar/suggestions/symbol_suggestions_provider.ts @@ -33,7 +33,7 @@ export class SymbolSuggestionsProvider extends AbstractSuggestionsProvider { queryParams.repoScope = repoScope.join(','); } const res = await kfetch({ - pathname: `../api/code/suggestions/symbol`, + pathname: `/api/code/suggestions/symbol`, method: 'get', query: queryParams, }); diff --git a/x-pack/plugins/code/public/components/search_page/pagination.tsx b/x-pack/plugins/code/public/components/search_page/pagination.tsx index 671d1678efd3b..bc3ee4384b9b9 100644 --- a/x-pack/plugins/code/public/components/search_page/pagination.tsx +++ b/x-pack/plugins/code/public/components/search_page/pagination.tsx @@ -7,7 +7,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPagination } from '@elastic/eui'; import querystring from 'querystring'; import React from 'react'; -import Url from 'url'; +import url from 'url'; import { history } from '../../utils/url'; @@ -22,7 +22,7 @@ export class Pagination extends React.PureComponent { const { query } = this.props; const queries = querystring.parse(history.location.search.replace('?', '')); history.push( - Url.format({ + url.format({ pathname: '/search', query: { ...queries, diff --git a/x-pack/plugins/code/public/components/search_page/scope_tabs.tsx b/x-pack/plugins/code/public/components/search_page/scope_tabs.tsx index 24d8c8b723658..71135e1dbb385 100644 --- a/x-pack/plugins/code/public/components/search_page/scope_tabs.tsx +++ b/x-pack/plugins/code/public/components/search_page/scope_tabs.tsx @@ -8,7 +8,7 @@ import { EuiTab, EuiTabs } from '@elastic/eui'; import querystring from 'querystring'; import React from 'react'; import styled from 'styled-components'; -import Url from 'url'; +import url from 'url'; import { SearchScope } from '../../../model'; import { history } from '../../utils/url'; @@ -32,7 +32,7 @@ export class ScopeTabs extends React.PureComponent { const { query } = this.props; const queries = querystring.parse(history.location.search.replace('?', '')); history.push( - Url.format({ + url.format({ pathname: '/search', query: { ...queries, diff --git a/x-pack/plugins/code/public/components/search_page/search.tsx b/x-pack/plugins/code/public/components/search_page/search.tsx index 67f2925fca100..b3927a8ff8f1d 100644 --- a/x-pack/plugins/code/public/components/search_page/search.tsx +++ b/x-pack/plugins/code/public/components/search_page/search.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { connect } from 'react-redux'; import styled from 'styled-components'; import chrome from 'ui/chrome'; -import Url from 'url'; +import url from 'url'; import theme from '@elastic/eui/dist/eui_theme_light.json'; import { DocumentSearchResult, SearchScope } from '../../../model'; @@ -92,7 +92,7 @@ class SearchPage extends React.PureComponent { const queries = querystring.parse(history.location.search.replace('?', '')); return () => { history.push( - Url.format({ + url.format({ pathname: '/search', query: { ...queries, @@ -121,7 +121,7 @@ class SearchPage extends React.PureComponent { const queries = querystring.parse(history.location.search.replace('?', '')); return () => { history.push( - Url.format({ + url.format({ pathname: '/search', query: { ...queries, diff --git a/x-pack/plugins/code/public/components/search_page/search_bar.tsx b/x-pack/plugins/code/public/components/search_page/search_bar.tsx index bc3c8d1c477d4..6515ddf2d0b7f 100644 --- a/x-pack/plugins/code/public/components/search_page/search_bar.tsx +++ b/x-pack/plugins/code/public/components/search_page/search_bar.tsx @@ -6,7 +6,7 @@ import querystring from 'querystring'; import React from 'react'; -import Url from 'url'; +import url from 'url'; import { SearchScope } from '../../../model'; import { SearchScopeText } from '../../common/types'; @@ -34,7 +34,7 @@ export class SearchBar extends React.PureComponent { // Update the url and push to history as well. const queries = querystring.parse(history.location.search.replace('?', '')); history.push( - Url.format({ + url.format({ pathname: '/search', query: { ...queries, diff --git a/x-pack/plugins/code/public/components/symbol_tree/code_symbol_tree.tsx b/x-pack/plugins/code/public/components/symbol_tree/code_symbol_tree.tsx index bb6961f1c0a7f..08e274f4a5c67 100644 --- a/x-pack/plugins/code/public/components/symbol_tree/code_symbol_tree.tsx +++ b/x-pack/plugins/code/public/components/symbol_tree/code_symbol_tree.tsx @@ -10,7 +10,9 @@ import theme from '@elastic/eui/dist/eui_theme_light.json'; import React from 'react'; import { Link } from 'react-router-dom'; import styled from 'styled-components'; +import url from 'url'; import { Location, SymbolKind } from 'vscode-languageserver-types/lib/umd/main'; + import { RepositoryUtils } from '../../../common/repository_utils'; import { EuiSideNavItem } from '../../common/types'; import { SymbolWithMembers } from '../../reducers/symbol'; @@ -100,7 +102,10 @@ export class CodeSymbolTree extends React.PureComponent diff --git a/x-pack/plugins/code/public/monaco/definition/definition_provider.ts b/x-pack/plugins/code/public/monaco/definition/definition_provider.ts index 252534d132910..d0787904ebb8a 100644 --- a/x-pack/plugins/code/public/monaco/definition/definition_provider.ts +++ b/x-pack/plugins/code/public/monaco/definition/definition_provider.ts @@ -12,7 +12,7 @@ import { Location } from 'vscode-languageserver-types'; import { LspRestClient, TextDocumentMethods } from '../../../common/lsp_client'; export function provideDefinition(monaco: any, model: editor.ITextModel, position: any) { - const lspClient = new LspRestClient('../api/lsp'); + const lspClient = new LspRestClient('/api/code/lsp'); const lspMethods = new TextDocumentMethods(lspClient); function handleLocation(location: Location): languages.Location { return { @@ -27,7 +27,7 @@ export function provideDefinition(monaco: any, model: editor.ITextModel, positio } async function handleQname(qname: string) { - const res: any = await kfetch({ pathname: `/api/lsp/symbol/${qname}` }); + const res: any = await kfetch({ pathname: `/api/code/lsp/symbol/${qname}` }); if (res.symbols) { return res.symbols.map((s: DetailSymbolInformation) => handleLocation(s.symbolInformation.location) diff --git a/x-pack/plugins/code/public/monaco/editor_service.ts b/x-pack/plugins/code/public/monaco/editor_service.ts index e79f3b987836a..e38fb1f93587c 100644 --- a/x-pack/plugins/code/public/monaco/editor_service.ts +++ b/x-pack/plugins/code/public/monaco/editor_service.ts @@ -35,7 +35,7 @@ export class EditorService extends StandaloneCodeEditorServiceImpl { public static async findSymbolByQname(qname: string) { try { const response = await kfetch({ - pathname: `/api/lsp/symbol/${qname}`, + pathname: `/api/code/lsp/symbol/${qname}`, method: 'GET', }); return response as SymbolSearchResult; diff --git a/x-pack/plugins/code/public/monaco/hover/hover_computer.ts b/x-pack/plugins/code/public/monaco/hover/hover_computer.ts index d315b7b342715..3dbea3712f30e 100644 --- a/x-pack/plugins/code/public/monaco/hover/hover_computer.ts +++ b/x-pack/plugins/code/public/monaco/hover/hover_computer.ts @@ -16,7 +16,7 @@ export class HoverComputer implements Computer { private uri: string | null = null; constructor() { - const lspClient = new LspRestClient('../api/lsp'); + const lspClient = new LspRestClient('/api/code/lsp'); this.lspMethods = new TextDocumentMethods(lspClient); } diff --git a/x-pack/plugins/code/public/monaco/textmodel_resolver.ts b/x-pack/plugins/code/public/monaco/textmodel_resolver.ts index 3501fedfba5ed..1336bc03a4262 100644 --- a/x-pack/plugins/code/public/monaco/textmodel_resolver.ts +++ b/x-pack/plugins/code/public/monaco/textmodel_resolver.ts @@ -5,6 +5,8 @@ */ import { editor, IDisposable, Uri } from 'monaco-editor'; +import chrome from 'ui/chrome'; + import { ImmortalReference } from './immortal_reference'; export interface IReference extends IDisposable { @@ -52,7 +54,9 @@ export class TextModelResolverService implements ITextModelService { const repo = `${resource.authority}${resource.path}`; const revision = resource.query; const file = resource.fragment; - const response = await fetch(`../api/code/repo/${repo}/blob/${revision}/${file}`); + const response = await fetch( + chrome.addBasePath(`/api/code/repo/${repo}/blob/${revision}/${file}`) + ); if (response.status === 200) { const contentType = response.headers.get('Content-Type'); diff --git a/x-pack/plugins/code/public/sagas/blame.ts b/x-pack/plugins/code/public/sagas/blame.ts index 752feac5df1eb..ccda71d797bac 100644 --- a/x-pack/plugins/code/public/sagas/blame.ts +++ b/x-pack/plugins/code/public/sagas/blame.ts @@ -12,7 +12,7 @@ import { loadBlame, loadBlameFailed, LoadBlamePayload, loadBlameSuccess } from ' import { blamePattern } from './patterns'; function requestBlame(repoUri: string, revision: string, path: string) { - return kfetch({ pathname: `../api/code/repo/${repoUri}/blame/${revision}/${path}` }); + return kfetch({ pathname: `/api/code/repo/${repoUri}/blame/${revision}/${path}` }); } function* handleFetchBlame(action: Action) { diff --git a/x-pack/plugins/code/public/sagas/commit.ts b/x-pack/plugins/code/public/sagas/commit.ts index 5c9b8345cb520..a8576bc84cc23 100644 --- a/x-pack/plugins/code/public/sagas/commit.ts +++ b/x-pack/plugins/code/public/sagas/commit.ts @@ -11,7 +11,7 @@ import { commitRoutePattern } from './patterns'; function requestCommit(repo: string, commitId: string) { return kfetch({ - pathname: `../api/code/repo/${repo}/diff/${commitId}`, + pathname: `/api/code/repo/${repo}/diff/${commitId}`, }); } diff --git a/x-pack/plugins/code/public/sagas/editor.ts b/x-pack/plugins/code/public/sagas/editor.ts index fa5f13febd920..c07f7416c948d 100644 --- a/x-pack/plugins/code/public/sagas/editor.ts +++ b/x-pack/plugins/code/public/sagas/editor.ts @@ -48,7 +48,7 @@ function* handleReferences(action: Action) { function requestFindReferences(params: TextDocumentPositionParams) { return kfetch({ - pathname: `../api/lsp/findReferences`, + pathname: `/api/code/lsp/findReferences`, method: 'POST', body: JSON.stringify(params), }); @@ -120,7 +120,7 @@ function* handleFile(repoUri: string, file: string, revision: string) { } function fetchRepo(repoUri: string) { - return kfetch({ pathname: `../api/code/repo/${repoUri}` }); + return kfetch({ pathname: `/api/code/repo/${repoUri}` }); } function* loadRepoSaga(action: any) { diff --git a/x-pack/plugins/code/public/sagas/file.ts b/x-pack/plugins/code/public/sagas/file.ts index 306eea687de34..98d063a2c7548 100644 --- a/x-pack/plugins/code/public/sagas/file.ts +++ b/x-pack/plugins/code/public/sagas/file.ts @@ -6,7 +6,10 @@ import { Action } from 'redux-actions'; import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects'; +import chrome from 'ui/chrome'; import { kfetch } from 'ui/kfetch'; +import Url from 'url'; + import { FileTree } from '../../model'; import { fetchDirectory, @@ -90,7 +93,7 @@ function requestRepoTree({ query.parents = true; } return kfetch({ - pathname: `../api/code/repo/${uri}/tree/${revision}/${path}`, + pathname: `/api/code/repo/${uri}/tree/${revision}/${path}`, query, }); } @@ -110,7 +113,7 @@ function* handleFetchBranches(action: Action) { function requestBranches({ uri }: FetchRepoPayload) { return kfetch({ - pathname: `../api/code/repo/${uri}/references`, + pathname: `/api/code/repo/${uri}/references`, }); } @@ -155,7 +158,7 @@ function requestCommits( ) { const pathStr = path ? `/${path}` : ''; const options: any = { - pathname: `../api/code/repo/${uri}/history/${revision}${pathStr}`, + pathname: `/api/code/repo/${uri}/history/${revision}${pathStr}`, }; if (loadMore) { options.query = { after: 1 }; @@ -171,11 +174,13 @@ export async function requestFile( line?: string ): Promise { const { uri, revision, path } = payload; - let url = `../api/code/repo/${uri}/blob/${revision}/${path}`; + const url = `/api/code/repo/${uri}/blob/${revision}/${path}`; + const query: any = {}; if (line) { - url += '?line=' + line; + query.line = line; } - const response: Response = await fetch(url); + const response: Response = await fetch(chrome.addBasePath(Url.format({ pathname: url, query }))); + if (response.status >= 200 && response.status < 300) { const contentType = response.headers.get('Content-Type'); diff --git a/x-pack/plugins/code/public/sagas/language_server.ts b/x-pack/plugins/code/public/sagas/language_server.ts index 737a8dd88847b..b5130c504290b 100644 --- a/x-pack/plugins/code/public/sagas/language_server.ts +++ b/x-pack/plugins/code/public/sagas/language_server.ts @@ -18,13 +18,13 @@ import { function fetchLangServers() { return kfetch({ - pathname: '../api/code/install', + pathname: '/api/code/install', }); } function installLanguageServer(languageServer: string) { return kfetch({ - pathname: `../api/code/install/${languageServer}`, + pathname: `/api/code/install/${languageServer}`, method: 'POST', }); } diff --git a/x-pack/plugins/code/public/sagas/project_config.ts b/x-pack/plugins/code/public/sagas/project_config.ts index a1ab4cb65f0af..e95ab66292e57 100644 --- a/x-pack/plugins/code/public/sagas/project_config.ts +++ b/x-pack/plugins/code/public/sagas/project_config.ts @@ -19,7 +19,7 @@ import { loadConfigsFailed, loadConfigsSuccess } from '../actions/project_config function putProjectConfig(repoUri: string, config: RepositoryConfig) { return kfetch({ - pathname: `../api/code/repo/config/${repoUri}`, + pathname: `/api/code/repo/config/${repoUri}`, method: 'PUT', body: JSON.stringify(config), }); @@ -41,7 +41,7 @@ export function* watchSwitchProjectLanguageServer() { function fetchConfigs(repoUri: string) { return kfetch({ - pathname: `../api/code/repo/config/${repoUri}`, + pathname: `/api/code/repo/config/${repoUri}`, }); } diff --git a/x-pack/plugins/code/public/sagas/project_status.ts b/x-pack/plugins/code/public/sagas/project_status.ts index 50be3d51fcdb6..bdd6ea4335ff7 100644 --- a/x-pack/plugins/code/public/sagas/project_status.ts +++ b/x-pack/plugins/code/public/sagas/project_status.ts @@ -31,7 +31,7 @@ import { cloneCompletedPattern } from './status'; function fetchStatus(repoUri: string) { return kfetch({ - pathname: `../api/code/repo/status/${repoUri}`, + pathname: `/api/code/repo/status/${repoUri}`, }); } diff --git a/x-pack/plugins/code/public/sagas/repository.ts b/x-pack/plugins/code/public/sagas/repository.ts index dbe20a0092c3d..74bd9c4139fa7 100644 --- a/x-pack/plugins/code/public/sagas/repository.ts +++ b/x-pack/plugins/code/public/sagas/repository.ts @@ -35,7 +35,7 @@ import { history } from '../utils/url'; import { adminRoutePattern } from './patterns'; function requestRepos(): any { - return kfetch({ pathname: '../api/code/repos' }); + return kfetch({ pathname: '/api/code/repos' }); } function* handleFetchRepos() { @@ -48,11 +48,11 @@ function* handleFetchRepos() { } function requestDeleteRepo(uri: string) { - return kfetch({ pathname: `../api/code/repo/${uri}`, method: 'delete' }); + return kfetch({ pathname: `/api/code/repo/${uri}`, method: 'delete' }); } function requestIndexRepo(uri: string) { - return kfetch({ pathname: `../api/code/repo/index/${uri}`, method: 'post' }); + return kfetch({ pathname: `/api/code/repo/index/${uri}`, method: 'post' }); } function* handleDeleteRepo(action: Action) { @@ -87,7 +87,7 @@ function* handleIndexRepo(action: Action) { function requestImportRepo(uri: string) { return kfetch({ - pathname: '../api/code/repo', + pathname: '/api/code/repo', method: 'post', body: JSON.stringify({ url: uri }), }); @@ -117,7 +117,7 @@ function* handleFetchRepoConfigs() { } function requestRepoConfigs() { - return kfetch({ pathname: '../api/code/workspace', method: 'get' }); + return kfetch({ pathname: '/api/code/workspace', method: 'get' }); } function* handleInitCmd(action: Action) { @@ -127,7 +127,7 @@ function* handleInitCmd(action: Action) { function requestRepoInitCmd(repoUri: string) { return kfetch({ - pathname: `../api/code/workspace/${repoUri}/master`, + pathname: `/api/code/workspace/${repoUri}/master`, query: { force: true }, method: 'post', }); @@ -139,7 +139,7 @@ function* handleGotoRepo(action: Action) { } function requestRepo(uri: string) { - return kfetch({ pathname: `../api/code/repo${uri}`, method: 'get' }); + return kfetch({ pathname: `/api/code/repo${uri}`, method: 'get' }); } export function* watchImportRepo() { diff --git a/x-pack/plugins/code/public/sagas/search.ts b/x-pack/plugins/code/public/sagas/search.ts index 03dc71112ded9..91f0ecafd3543 100644 --- a/x-pack/plugins/code/public/sagas/search.ts +++ b/x-pack/plugins/code/public/sagas/search.ts @@ -52,7 +52,7 @@ function requestDocumentSearch(payload: DocumentSearchPayload) { if (query && query.length > 0) { return kfetch({ - pathname: `../api/code/search/doc`, + pathname: `/api/code/search/doc`, method: 'get', query: queryParams, }); @@ -76,7 +76,7 @@ function* handleDocumentSearch(action: Action) { function requestRepositorySearch(q: string) { return kfetch({ - pathname: `../api/code/search/repo`, + pathname: `/api/code/search/repo`, method: 'get', query: { q }, }); diff --git a/x-pack/plugins/code/public/sagas/structure.ts b/x-pack/plugins/code/public/sagas/structure.ts index d68f6154ef52a..f574cf6ab9175 100644 --- a/x-pack/plugins/code/public/sagas/structure.ts +++ b/x-pack/plugins/code/public/sagas/structure.ts @@ -9,7 +9,7 @@ import { LspRestClient, TextDocumentMethods } from '../../common/lsp_client'; import { loadStructure, loadStructureFailed, loadStructureSuccess } from '../actions'; function requestStructure(uri?: string) { - const lspClient = new LspRestClient('../api/lsp'); + const lspClient = new LspRestClient('/api/code/lsp'); const lspMethods = new TextDocumentMethods(lspClient); return lspMethods.documentSymbol.send({ textDocument: { diff --git a/x-pack/plugins/code/public/sagas/user.ts b/x-pack/plugins/code/public/sagas/user.ts index 3f2223d14d450..d7e95915a34c2 100644 --- a/x-pack/plugins/code/public/sagas/user.ts +++ b/x-pack/plugins/code/public/sagas/user.ts @@ -12,7 +12,7 @@ import { loadUserProfile, loadUserProfileFailed, loadUserProfileSuccess } from ' function requestUserProfile() { return kfetch({ - pathname: `../api/security/v1/me`, + pathname: `/api/security/v1/me`, method: 'get', }); } diff --git a/x-pack/plugins/code/server/routes/file.ts b/x-pack/plugins/code/server/routes/file.ts index 54be1a5a03de5..2f8ac4d828674 100644 --- a/x-pack/plugins/code/server/routes/file.ts +++ b/x-pack/plugins/code/server/routes/file.ts @@ -109,13 +109,13 @@ export function fileRoute(server: hapi.Server, options: ServerOptions) { }); server.route({ - path: '/api/code/repo/{uri*3}/raw/{rev}/{path*}', + path: '/app/code/repo/{uri*3}/raw/{ref}/{path*}', method: 'GET', async handler(req, h: hapi.ResponseToolkit) { const fileResolver = new GitOperations(options.repoPath); - const { uri, path, rev } = req.params; + const { uri, path, ref } = req.params; try { - const blob = await fileResolver.fileContent(uri, path, rev); + const blob = await fileResolver.fileContent(uri, path, ref); if (blob.isBinary()) { return h.response(blob.content()).type('application/octet-stream'); } else { diff --git a/x-pack/plugins/code/server/routes/lsp.ts b/x-pack/plugins/code/server/routes/lsp.ts index 76b1ad029eaa9..f0c43584aebb6 100644 --- a/x-pack/plugins/code/server/routes/lsp.ts +++ b/x-pack/plugins/code/server/routes/lsp.ts @@ -36,7 +36,7 @@ export function lspRoute( ) { const log = new Logger(server); server.route({ - path: '/api/lsp/textDocument/{method}', + path: '/api/code/lsp/textDocument/{method}', async handler(req, h: hapi.ResponseToolkit) { if (typeof req.payload === 'object' && req.payload != null) { const method = req.params.method; @@ -78,7 +78,7 @@ export function lspRoute( }); server.route({ - path: '/api/lsp/findReferences', + path: '/api/code/lsp/findReferences', method: 'POST', async handler(req, h: hapi.ResponseToolkit) { try { @@ -171,7 +171,7 @@ export function lspRoute( export function symbolByQnameRoute(server: hapi.Server, log: Logger) { server.route({ - path: '/api/lsp/symbol/{qname}', + path: '/api/code/lsp/symbol/{qname}', method: 'GET', async handler(req) { try { diff --git a/x-pack/plugins/code/server/routes/redirect.ts b/x-pack/plugins/code/server/routes/redirect.ts index 842e4ace0941d..ec779f60a0c8e 100644 --- a/x-pack/plugins/code/server/routes/redirect.ts +++ b/x-pack/plugins/code/server/routes/redirect.ts @@ -54,7 +54,7 @@ export function redirectRoute(server: hapi.Server, redirect: string, log: Logger handler: proxyHandler, }); server.route({ - path: '/api/lsp/{p*}', + path: '/api/code/lsp/{p*}', method: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], handler: proxyHandler, });