forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reporting/Config] allow string representations of duration settings (e…
…lastic#74202) * [Reporting/Config] use better schema methods * add createMockConfig * update documentation * fix observable.test * add docs links to common options page * make the schema match the docs * wording edits per feedback * self edits * todo comment * fix tests * feedback change 1 * schema utils * fix goof * use objects for the defaults when available * fix pollInterval * fix snapshots * Update report_listing.tsx * call new ByteSizeValue on server side only * revert xpack.reporting.poll * fix ts * fix snapshot * use correct input for duration * revert reorganize imports Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
a73443c
commit b49cb90
Showing
37 changed files
with
607 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ByteSizeValue } from '@kbn/config-schema'; | ||
import moment from 'moment'; | ||
|
||
/* | ||
* For cleaner code: use these functions when a config schema value could be | ||
* one type or another. This allows you to treat the value as one type. | ||
*/ | ||
|
||
export const durationToNumber = (value: number | moment.Duration): number => { | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
return value.asMilliseconds(); | ||
}; | ||
|
||
export const byteSizeValueToNumber = (value: number | ByteSizeValue) => { | ||
if (typeof value === 'number') { | ||
return value; | ||
} | ||
|
||
return value.getValueInBytes(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.