-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ TASK-1024 ] feat: pii masking (#1358)
add a new action that gives the user the ability to mask PII categories
- Loading branch information
1 parent
b762c3a
commit ef7322c
Showing
8 changed files
with
103 additions
and
1 deletion.
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
67 changes: 67 additions & 0 deletions
67
frontend/webapp/components/overview/actions/actions.forms/pii-masking/index.tsx
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,67 @@ | ||
import { KeyvalCheckbox } from '@/design.system'; | ||
import React, { useEffect } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const piiCategoriesCheckbox = [ | ||
{ | ||
id: 'CREDIT_CARD', | ||
label: 'Credit Card', | ||
}, | ||
]; | ||
|
||
const FormWrapper = styled.div` | ||
width: 375px; | ||
`; | ||
|
||
interface PiiMasking { | ||
piiCategories: string[]; | ||
} | ||
|
||
interface PiiMaskingProps { | ||
data: PiiMasking; | ||
onChange: (key: string, value: PiiMasking | null) => void; | ||
setIsFormValid?: (isValid: boolean) => void; | ||
} | ||
const ACTION_DATA_KEY = 'actionData'; | ||
export function PiiMaskingForm({ | ||
data, | ||
onChange, | ||
setIsFormValid, | ||
}: PiiMaskingProps): React.JSX.Element { | ||
useEffect(() => { | ||
onChange(ACTION_DATA_KEY, { | ||
piiCategories: ['CREDIT_CARD'], | ||
}); | ||
setIsFormValid && setIsFormValid(true); | ||
}, []); | ||
|
||
function handleOnChange(value: string): void { | ||
let piiCategories: string[] = []; | ||
|
||
if (piiCategories.includes(value)) { | ||
piiCategories = piiCategories.filter((category) => category !== value); | ||
} else { | ||
piiCategories.push(value); | ||
} | ||
|
||
onChange(ACTION_DATA_KEY, { | ||
piiCategories, | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<FormWrapper> | ||
{piiCategoriesCheckbox.map((checkbox) => ( | ||
<KeyvalCheckbox | ||
disabled | ||
key={checkbox?.id} | ||
value={data?.piiCategories?.includes(checkbox?.id)} | ||
onChange={() => handleOnChange(checkbox?.id)} | ||
label={checkbox?.label} | ||
/> | ||
))} | ||
</FormWrapper> | ||
</> | ||
); | ||
} |
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