-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UiSettings validation & Kibana default route redirection #59694
Changes from 30 commits
b20ecc7
7e46aef
5b55b83
19dae10
012a715
cc96364
269e34e
f2b2dea
39e7405
b736ada
b01a668
5518bd0
7a5a354
850d78c
a7d0100
8ec9103
b21efe2
cb40a2b
2f8f956
f17a82f
6b5f699
9856d0b
6e389a6
84e3e5a
c72b5cc
ed8a9a9
1036d77
075fe07
3b8ad0c
57c9aef
2ad3292
400a167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) > [schema](./kibana-plugin-core-public.uisettingsparams.schema.md) | ||
|
||
## UiSettingsParams.schema property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
schema?: Type<T>; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PublicUiSettingsParams](./kibana-plugin-core-server.publicuisettingsparams.md) | ||
|
||
## PublicUiSettingsParams type | ||
|
||
A sub-set of [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) exposed to the client-side. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) > [schema](./kibana-plugin-core-server.uisettingsparams.schema.md) | ||
|
||
## UiSettingsParams.schema property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
schema?: Type<T>; | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,10 +152,14 @@ export class UiSettingsApi { | |
}, | ||
}); | ||
} catch (err) { | ||
if (err.response && err.response.status >= 300) { | ||
throw new Error(`Request failed with status code: ${err.response.status}`); | ||
if (err.response) { | ||
if (err.response.status === 400) { | ||
throw new Error(err.body.message); | ||
} | ||
if (err.response.status > 400) { | ||
throw new Error(`Request failed with status code: ${err.response.status}`); | ||
Comment on lines
+156
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably related to the changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really need typing for our errors so that we can evolve these 😢 |
||
} | ||
} | ||
|
||
throw err; | ||
} finally { | ||
this.loadingCount$.next(this.loadingCount$.getValue() - 1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { InternalCoreSetup } from '../internal_types'; | ||
import { CoreContext } from '../core_context'; | ||
import { Logger } from '../logging'; | ||
|
||
/** @internal */ | ||
export class CoreApp { | ||
private readonly logger: Logger; | ||
constructor(core: CoreContext) { | ||
this.logger = core.logger.get('core-app'); | ||
} | ||
setup(coreSetup: InternalCoreSetup) { | ||
this.logger.debug('Setting up core app.'); | ||
this.registerDefaultRoutes(coreSetup); | ||
} | ||
|
||
private registerDefaultRoutes(coreSetup: InternalCoreSetup) { | ||
const httpSetup = coreSetup.http; | ||
const router = httpSetup.createRouter('/'); | ||
router.get({ path: '/', validate: false }, async (context, req, res) => { | ||
const defaultRoute = await context.core.uiSettings.client.get<string>('defaultRoute'); | ||
const basePath = httpSetup.basePath.get(req); | ||
const url = `${basePath}${defaultRoute}`; | ||
|
||
return res.redirected({ | ||
headers: { | ||
location: url, | ||
}, | ||
}); | ||
}); | ||
router.get({ path: '/core', validate: false }, async (context, req, res) => | ||
res.ok({ body: { version: '0.0.1' } }) | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { CoreApp } from './core_app'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not introduced by this PR, but we may want to rename the exposed types to use the
UiSettings
prefix at some point. Outside of the scope of the PR though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to #48925