mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datagrid Panel: Edit data within your dashboards (#66353)
* wip * Datagrid WIP: snapshotting when data edited, better UI for adding column/rows, refactors * wip * WIP * wip * Add series selector * Delete selection on key press * wip * Multiple row select and delete * wip * draggable rows/columns, better column width calculator * bug fixes * scrollbars * add feature flag * bugfixes * bugfixes * bugfixes * bugfixes * Add possibility to rename column * Input fixes * bugfixes * bugfixes * performance optimisations * WIP component refactoring and optimisations * comment bit of code to remove error for testing * fix column move and payload types * WIP refactors and tests * e2e tests * queryGroup subscription refactor * queryGroup - add component on update, fix failing tests * refactor querygroup * querygroup refactor * tests * fix codeowners validation * lint fixes * revert convertFieldType modification in favor of already merged mod + re-add mistakenly deleted line * remove //ts-ignores * Minor style tweaks * fix * align colors with theme * fixes * refactor * add test for convertFieldType transformer and write todo --------- Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
@@ -100,6 +100,27 @@ describe('field convert type', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('can convert proper numeric strings to numbers, but also treat edge-cases', () => {
|
||||
const options = { targetField: 'stringy nums', destinationType: FieldType.number };
|
||||
|
||||
//there are scenarios where string fields have numeric values, or the strings are non-numeric and cannot pe converted
|
||||
const stringyNumbers = {
|
||||
name: 'stringy nums',
|
||||
type: FieldType.string,
|
||||
values: ['10', '1asd2', '30', 14, 10, '23', '', null],
|
||||
config: {},
|
||||
};
|
||||
|
||||
const numbers = convertFieldType(stringyNumbers, options);
|
||||
|
||||
expect(numbers).toEqual({
|
||||
name: 'stringy nums',
|
||||
type: FieldType.number,
|
||||
values: [10, null, 30, 14, 10, 23, 0, 0],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('can convert strings with commas to numbers', () => {
|
||||
const options = { targetField: 'stringy nums', destinationType: FieldType.number };
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ function fieldToNumberField(field: Field): Field {
|
||||
for (let n = 0; n < numValues.length; n++) {
|
||||
let toBeConverted = numValues[n];
|
||||
|
||||
if (valuesAsStrings && toBeConverted != null) {
|
||||
if (valuesAsStrings && toBeConverted != null && typeof toBeConverted === 'string') {
|
||||
// some numbers returned from datasources have commas
|
||||
// strip the commas, coerce the string to a number
|
||||
toBeConverted = toBeConverted.replace(/,/g, '');
|
||||
|
||||
@@ -98,4 +98,5 @@ export interface FeatureToggles {
|
||||
pluginsAPIManifestKey?: boolean;
|
||||
advancedDataSourcePicker?: boolean;
|
||||
opensearchDetectVersion?: boolean;
|
||||
enableDatagridEditing?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user