generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from SAP/feature/CDCTOOLBOX-415-V2
Feature/cdctoolbox 415 v2
- Loading branch information
Showing
21 changed files
with
385 additions
and
70 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
3 changes: 1 addition & 2 deletions
3
src/components/configuration-tree/configuration-tree.styles.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
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
36 changes: 36 additions & 0 deletions
36
src/components/risk-based-authentication-rules-buttons/dataTest.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,36 @@ | ||
/* | ||
* Copyright: Copyright 2023 SAP SE or an SAP affiliate company and cdc-tools-chrome-extension contributors | ||
* License: Apache-2.0 | ||
*/ | ||
|
||
export const treeNodeExample = { | ||
id: 'testNode1', | ||
name: 'testNode1', | ||
value: false, | ||
} | ||
|
||
export const setRbaRulesOperation = jest.fn() | ||
|
||
export const dispatch = jest.fn() | ||
|
||
export const t = (key) => key | ||
|
||
export const eventMerge = { | ||
detail: { | ||
selectedOption: { | ||
dataset: { id: 'merge' }, | ||
}, | ||
}, | ||
} | ||
|
||
export const eventReplace = { | ||
detail: { | ||
selectedOption: { | ||
dataset: { id: 'replace' }, | ||
}, | ||
}, | ||
} | ||
|
||
export const replaceValue = { operation: 'replace' } | ||
|
||
export const mergeValue = { operation: 'merge' } |
32 changes: 32 additions & 0 deletions
32
...-based-authentication-rules-buttons/risk-based-authentication-rules-buttons.component.jsx
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,32 @@ | ||
/* | ||
* Copyright: Copyright 2023 SAP SE or an SAP affiliate company and cdc-tools-chrome-extension contributors | ||
* License: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react' | ||
import { withTranslation } from 'react-i18next' | ||
import { Option, Select } from '@ui5/webcomponents-react' | ||
import { useDispatch } from 'react-redux' | ||
import { handleRadioButtonChange } from './utils' | ||
import { createUseStyles } from 'react-jss' | ||
import styles from './risk-based-authentication-rules-buttons.style' | ||
|
||
const useStyles = createUseStyles(styles, { name: 'RiskBasedAuthenticationRulesButtons' }) | ||
const RiskBasedAuthenticationRulesButtons = ({ treeNode, setRbaRulesOperation, t }) => { | ||
const dispatch = useDispatch() | ||
const classes = useStyles() | ||
return ( | ||
<span className={classes.rbaSelectButtonAlignment}> | ||
<Select | ||
className={`${classes.rbaButtonSize} ui5-content-density-compact`} | ||
onChange={(event) => handleRadioButtonChange(event, treeNode, setRbaRulesOperation, dispatch)} | ||
valueState="None" | ||
> | ||
<Option data-id="merge">{t('CONFIGURATION_TREE.BUTTON_MERGE')}</Option> | ||
<Option data-id="replace">{t('CONFIGURATION_TREE.BUTTON_REPLACE')}</Option> | ||
</Select> | ||
</span> | ||
) | ||
} | ||
|
||
export default withTranslation()(RiskBasedAuthenticationRulesButtons) |
11 changes: 11 additions & 0 deletions
11
.../risk-based-authentication-rules-buttons/risk-based-authentication-rules-buttons.style.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,11 @@ | ||
const styles = { | ||
rbaSelectButtonAlignment: { | ||
alignContent: 'center', | ||
marginLeft: '10px', | ||
}, | ||
rbaButtonSize: { | ||
width: '100px', | ||
}, | ||
} | ||
|
||
export default styles |
29 changes: 29 additions & 0 deletions
29
src/components/risk-based-authentication-rules-buttons/utils.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,29 @@ | ||
/* | ||
* Copyright: Copyright 2023 SAP SE or an SAP affiliate company and cdc-tools-chrome-extension contributors | ||
* License: Apache-2.0 | ||
*/ | ||
|
||
export const handleRadioButtonChange = (event, treeNode, setRbaRulesOperation, dispatch) => { | ||
const REPLACE_BUTTON_ID = 'replace' | ||
|
||
var selectedButton = 'merge' | ||
|
||
if (event.detail?.selectedOption?.dataset?.id) selectedButton = event.detail.selectedOption.dataset.id | ||
|
||
if (selectedButton === REPLACE_BUTTON_ID) { | ||
dispatch(setRbaRulesOperation({ checkBoxId: treeNode.id, operation: 'replace' })) | ||
} else { | ||
dispatch(setRbaRulesOperation({ checkBoxId: treeNode.id, operation: 'merge' })) | ||
} | ||
} | ||
|
||
export const handleRBACheckboxChange = (checkBoxId, value, setIsRBAChecked) => { | ||
if (checkBoxId === 'rba' || checkBoxId === 'RBA Rules') { | ||
setIsRBAChecked(value) | ||
} | ||
} | ||
|
||
export const shouldShowRBARulesButtons = (treeNode, isRBAChecked) => { | ||
const isRiskBasedAuth = treeNode.name === 'RBA Rules' | ||
return isRiskBasedAuth && isRBAChecked | ||
} |
23 changes: 23 additions & 0 deletions
23
src/components/risk-based-authentication-rules-buttons/utils.test.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,23 @@ | ||
/* | ||
* Copyright: Copyright 2023 SAP SE or an SAP affiliate company and cdc-tools-chrome-extension contributors | ||
* License: Apache-2.0 | ||
*/ | ||
|
||
import { handleRadioButtonChange } from './utils' | ||
import { treeNodeExample, setRbaRulesOperation, dispatch, eventMerge, eventReplace, replaceValue, mergeValue } from './dataTest' | ||
|
||
describe('handleRadioButtonChange function tests', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
test('should dispatch merge action when merge button is clicked', () => { | ||
handleRadioButtonChange(eventMerge, treeNodeExample, setRbaRulesOperation, dispatch) | ||
expect(dispatch).toHaveBeenCalledWith(setRbaRulesOperation({ checkBoxId: treeNodeExample.id, mergeValue })) | ||
}) | ||
|
||
test('should dispatch replace action when replace button is clicked', () => { | ||
handleRadioButtonChange(eventReplace, treeNodeExample, setRbaRulesOperation, dispatch) | ||
expect(dispatch).toHaveBeenCalledWith(setRbaRulesOperation({ checkBoxId: treeNodeExample.id, replaceValue })) | ||
}) | ||
}) |
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
Oops, something went wrong.