-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4033 - NationalData-DataSources Cycle 2029 (#4035)
* 4033 - NationalData-DataSources Cycle 2029: data/metadata clone (#4034) * 4033 - Do not import dataSources.text prop / Fix clone cycle props * 4033 - improve Objects.isEmpty + unit test * 4033 - fix DataSources grid * 4033 - Do not import dataSources.text value * 4033 - Dashboard cycle clone (#4039) * fix dashboard clone * Disable region level dashboard on all but fra 2020 * 4033 - NationalData->DataSources Cycle 2029 - Labels + clone props fix (#4048) * 4033: Fix DataSources labels * 4033: Use Objects.isNil to check props to clone --------- Co-authored-by: Miró Sorja <[email protected]>
- Loading branch information
Showing
16 changed files
with
148 additions
and
79 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
This file was deleted.
Oops, something went wrong.
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
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
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
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,30 @@ | ||
import { isEmpty } from 'utils/objects/isEmpty' | ||
|
||
const tests: Array<{ empty: boolean; value: any }> = [ | ||
{ empty: true, value: undefined }, | ||
{ empty: true, value: null }, | ||
{ empty: true, value: '' }, | ||
{ empty: true, value: ' ' }, | ||
{ empty: false, value: ' fdsafd a' }, | ||
{ empty: false, value: 'fdsafd ' }, | ||
{ empty: false, value: 'fdsafd' }, | ||
{ empty: false, value: { a: '' } }, | ||
{ empty: false, value: { a: '', b: '' } }, | ||
{ empty: false, value: { a: undefined } }, | ||
{ empty: true, value: {} }, | ||
{ empty: false, value: [1] }, | ||
{ empty: false, value: [1, 2, 3] }, | ||
{ empty: true, value: [] }, | ||
{ empty: false, value: [undefined] }, | ||
{ empty: false, value: [null] }, | ||
{ empty: false, value: [undefined, null] }, | ||
] | ||
|
||
describe('isEmpty', () => { | ||
tests.forEach(({ empty, value }) => { | ||
test(`${JSON.stringify(value)}-${empty}`, () => { | ||
const result = isEmpty(value) | ||
expect(result).toEqual(empty) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { isNil } from 'utils/objects/isNil' | ||
|
||
/** | ||
* Determines if the specified value is null, empty string, NaN, empty object or empty array. | ||
* | ||
* @param {any} value - Value to | ||
* @returns {boolean} True if the specified value is empty, false otherwise. | ||
*/ | ||
export const isEmpty = (value: any): boolean => | ||
value === undefined || | ||
value === null || | ||
value === '' || | ||
isNil(value) || | ||
Number.isNaN(value) || | ||
(value instanceof Object && Object.entries(value).length === 0) || | ||
(Array.isArray(value) && value.length === 0) | ||
(typeof value === 'object' && Object.keys(value).length === 0) || | ||
(typeof value === 'string' && value.trim().length === 0) |
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,4 @@ | ||
// @ts-expect-error | ||
import * as isNil from 'lodash.isnil' | ||
|
||
export { isNil } |