-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(TDOPS-5510/inlineEdit): add data attributes from props (#5166)
* fix(TDOPS-5510/inlineEdit): add data attributes from props * fix(TDOPS-5510/inlineEdit): add data attributes from props * fix(TDOPS-5510/inlineEdit): add data attributes from props * fix(TDOPS-5510/inlineEdit): add data attributes from props
- Loading branch information
Showing
18 changed files
with
81 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@talend/react-faceted-search': patch | ||
'@talend/design-system': patch | ||
'@talend/react-components': patch | ||
'@talend/utils': patch | ||
--- | ||
|
||
fix(TDOPS-5510/inlineEdit): add data attributes from props |
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
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 |
---|---|---|
@@ -1,12 +1,6 @@ | ||
import { pick } from 'lodash'; | ||
import { USAGE_TRACKING_TAGS } from '../constants'; | ||
|
||
export const getApplyDataFeature = feature => { | ||
const formatedFeature = feature.toLowerCase().replace(' ', '_'); | ||
return USAGE_TRACKING_TAGS.BADGE_ADD.replace('#{badgeName}', formatedFeature); | ||
}; | ||
|
||
export const getDataAttributesFrom = props => { | ||
const dataAttributesKeys = Object.keys(props).filter(objectKey => objectKey.startsWith('data-')); | ||
return pick(props, dataAttributesKeys); | ||
}; |
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,23 +1,9 @@ | ||
import { getApplyDataFeature, getDataAttributesFrom } from './usage.helpers'; | ||
import { getApplyDataFeature } from './usage.helpers'; | ||
|
||
describe('helpers/usage', () => { | ||
it('should format an apply button data-feature based on formatedKey', () => { | ||
expect(getApplyDataFeature('name')).toEqual('filter.name.add'); | ||
expect(getApplyDataFeature('Connection type')).toEqual('filter.connection_type.add'); | ||
expect(getApplyDataFeature('UPPERCASE LABEL')).toEqual('filter.uppercase_label.add'); | ||
}); | ||
|
||
it('should get only data attributes from props', () => { | ||
const props = { | ||
key: 'a', | ||
id: 'b', | ||
other: 'c', | ||
'data-test': 'd', | ||
'data-feature': 'e', | ||
}; | ||
expect(getDataAttributesFrom(props)).toEqual({ | ||
'data-test': 'd', | ||
'data-feature': 'e', | ||
}); | ||
}); | ||
}); |
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,17 @@ | ||
import getDataAttrFromProps from './getDataAttrFromProps'; | ||
|
||
describe('getDataAttrFromProps tests', () => { | ||
it('should get only data attributes from props', () => { | ||
const props = { | ||
key: 'a', | ||
id: 'b', | ||
other: 'c', | ||
'data-test': 'd', | ||
'data-feature': 'e', | ||
}; | ||
expect(getDataAttrFromProps(props)).toEqual({ | ||
'data-test': 'd', | ||
'data-feature': 'e', | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
import { pick } from 'lodash'; | ||
|
||
/** | ||
* get data attributes from props | ||
* @param {object} props | ||
* @returns {object} | ||
*/ | ||
export default function getDataAttrFromProps(props: object) { | ||
const dataAttributesKeys: string[] = Object.keys(props).filter(objectKey => | ||
objectKey.startsWith('data-'), | ||
); | ||
return pick(props, dataAttributesKeys); | ||
} |
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,6 +1,7 @@ | ||
import * as date from './date'; | ||
import * as filters from './filters'; | ||
import getDataAttrFromProps from './getDataAttrFromProps'; | ||
import { randomUUID } from './uuid'; | ||
import validation from './validation'; | ||
|
||
export { date, validation, randomUUID, filters }; | ||
export { date, validation, randomUUID, filters, getDataAttrFromProps }; |