From 34c4e9dad0719546fe5f89b700842e4337da1deb Mon Sep 17 00:00:00 2001 From: Bart Van Remortele Date: Thu, 1 Aug 2019 16:45:44 +0200 Subject: [PATCH] Add custom formatting for Date Nanos format --- .../editors/date_nanos/date_nanos.js | 28 +++++++++++++++++++ .../editors/date_nanos/index.js | 20 +++++++++++++ .../field_format_editor/register.js | 2 ++ 3 files changed, 50 insertions(+) create mode 100644 src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js create mode 100644 src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js new file mode 100644 index 0000000000000..8a9e1f7a6e092 --- /dev/null +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js @@ -0,0 +1,28 @@ +/* + * 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 { DateFormatEditor } from '../date'; + +export class DateNanosFormatEditor extends DateFormatEditor { + static formatId = 'date_nanos'; + + constructor(props) { + super(props); + } +} diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js new file mode 100644 index 0000000000000..b82541a21c8ba --- /dev/null +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js @@ -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 { DateNanosFormatEditor } from './date_nanos'; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/register.js b/src/legacy/ui/public/field_editor/components/field_format_editor/register.js index 78dea8f952dbc..3062a3ba8ac14 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/register.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/register.js @@ -21,6 +21,7 @@ import { RegistryFieldFormatEditorsProvider } from 'ui/registry/field_format_edi import { BytesFormatEditor } from './editors/bytes'; import { ColorFormatEditor } from './editors/color'; import { DateFormatEditor } from './editors/date'; +import { DateNanosFormatEditor } from './editors/date_nanos'; import { DurationFormatEditor } from './editors/duration'; import { NumberFormatEditor } from './editors/number'; import { PercentFormatEditor } from './editors/percent'; @@ -32,6 +33,7 @@ import { UrlFormatEditor } from './editors/url/url'; RegistryFieldFormatEditorsProvider.register(() => BytesFormatEditor); RegistryFieldFormatEditorsProvider.register(() => ColorFormatEditor); RegistryFieldFormatEditorsProvider.register(() => DateFormatEditor); +RegistryFieldFormatEditorsProvider.register(() => DateNanosFormatEditor); RegistryFieldFormatEditorsProvider.register(() => DurationFormatEditor); RegistryFieldFormatEditorsProvider.register(() => NumberFormatEditor); RegistryFieldFormatEditorsProvider.register(() => PercentFormatEditor);