-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
316 additions
and
58 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
27 changes: 27 additions & 0 deletions
27
src/legacy/ui/public/agg_types/buckets/_inline_comp_wrapper.js
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,27 @@ | ||
/* | ||
* 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 React from 'react'; | ||
|
||
const wrapWithInlineComp = Component => props => ( | ||
<div className={`visEditorAggParam--half visEditorAggParam--half-${props.aggParam.name}`}> | ||
<Component {...props} /> | ||
</div>); | ||
|
||
export { wrapWithInlineComp }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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 React, { useEffect } from 'react'; | ||
import { EuiFormRow, EuiSelect } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { AggParamEditorProps } from 'ui/vis/editors/default'; | ||
import { SelectValueProp, SelectParamEditorProps } from '../param_types/select'; | ||
|
||
function OrderParamEditor({ | ||
aggParam, | ||
value, | ||
showValidation, | ||
setValue, | ||
setValidity, | ||
setTouched, | ||
}: AggParamEditorProps<SelectValueProp> & SelectParamEditorProps) { | ||
const label = i18n.translate('common.ui.aggTypes.orderLabel', { | ||
defaultMessage: 'Order', | ||
}); | ||
const isValid = !!value; | ||
|
||
useEffect( | ||
() => { | ||
setValidity(isValid); | ||
}, | ||
[isValid] | ||
); | ||
|
||
return ( | ||
<EuiFormRow | ||
label={label} | ||
fullWidth={true} | ||
isInvalid={showValidation ? !isValid : false} | ||
className="visEditorSidebar__aggParamFormRow" | ||
> | ||
<EuiSelect | ||
options={aggParam.options.raw} | ||
value={value.value} | ||
onChange={ev => setValue(aggParam.options.byValue[ev.target.value])} | ||
fullWidth={true} | ||
isInvalid={showValidation ? !isValid : false} | ||
onBlur={setTouched} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
|
||
export { OrderParamEditor }; |
36 changes: 0 additions & 36 deletions
36
src/legacy/ui/public/agg_types/controls/order_and_size.html
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
/* | ||
* 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 React, { useEffect } from 'react'; | ||
import { isUndefined } from 'lodash'; | ||
import { AggParamEditorProps } from 'ui/vis/editors/default'; | ||
import { EuiFormRow, EuiFieldNumber } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
function SizeParamEditor({ | ||
value, | ||
setValue, | ||
showValidation, | ||
setValidity, | ||
setTouched, | ||
}: AggParamEditorProps<number | ''>) { | ||
const label = i18n.translate('common.ui.aggTypes.sizeLabel', { | ||
defaultMessage: 'Size', | ||
}); | ||
const isValid = Number(value) > 0; | ||
|
||
useEffect( | ||
() => { | ||
setValidity(isValid); | ||
}, | ||
[isValid] | ||
); | ||
|
||
return ( | ||
<EuiFormRow | ||
label={label} | ||
fullWidth={true} | ||
isInvalid={showValidation ? !isValid : false} | ||
className="visEditorSidebar__aggParamFormRow" | ||
> | ||
<EuiFieldNumber | ||
value={isUndefined(value) ? '' : value} | ||
onChange={ev => setValue(ev.target.value === '' ? '' : parseFloat(ev.target.value))} | ||
fullWidth={true} | ||
isInvalid={showValidation ? !isValid : false} | ||
onBlur={setTouched} | ||
min={1} | ||
data-test-subj="sizeParamEditor" | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
|
||
export { SizeParamEditor }; |
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,39 @@ | ||
/* | ||
* 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 { IndexedArray } from '../../indexed_array'; | ||
|
||
interface SelectValueProp { | ||
value: string; | ||
text: string; | ||
} | ||
|
||
interface SelectOptions extends IndexedArray<SelectValueProp> { | ||
byValue: { | ||
[key: string]: SelectValueProp; | ||
}; | ||
} | ||
|
||
interface SelectParamEditorProps { | ||
aggParam: { | ||
options: SelectOptions; | ||
}; | ||
} | ||
|
||
export { SelectValueProp, SelectParamEditorProps }; |
Oops, something went wrong.