Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing the delimiter to separate role names in the filter. #33

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions control/SecurityRoleManager/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<property name="entityLogicalName" display-name-key="entityLogicalName_Display_Key" description-key="entityLogicalName_Desc_Key" of-type="SingleLine.Text" usage="input" required="true" />
<property name="businessUnitId" display-name-key="businessUnitId_Display_Key" description-key="businessUnitId_Desc_Key" of-type="Lookup.Simple" usage="bound" required="true" />
<property name="roleNamesFilter" display-name-key="roleNamesFilter_Display_Key" description-key="roleNamesFilter_Desc_Key" of-type="Multiple" usage="input" required="false" />
<property name="roleNamesFilterDelimiter" display-name-key="roleNamesFilterDelimiter_Display_Key" description-key="roleNamesFilterDelimiter_Desc_Key" of-type="SingleLine.Text" usage="input" required="false" />
<type-group name="any">
<type>Currency</type>
<type>DateAndTime.DateAndTime</type>
Expand Down
5 changes: 3 additions & 2 deletions control/SecurityRoleManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ export class SecurityRoleManager implements ComponentFramework.StandardControl<I

const businessUnit = context.parameters.businessUnitId.raw?.[0]

const roleNamesFilterDelimiter = context.parameters.roleNamesFilterDelimiter.raw ?? ''
const roleNamesFilter = parseCsvString(
context.parameters.roleNamesFilter.raw ?? '',
'\n'
context.parameters.roleNamesFilter.raw ?? '',
roleNamesFilterDelimiter.length > 0 ? roleNamesFilterDelimiter : '\n'
)

const props: IAppProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
<data name="roleNamesFilter_Desc_Key" xml:space="preserve">
<value>Specify a list of roles to include on the form. Enter each role name on a new line. Note: If the role names are updated, they must also be changed here.</value>
</data>
<data name="roleNamesFilterDelimiter_Display_Key" xml:space="preserve">
<value>Role Names Filter Delimiter</value>
</data>
<data name="roleNamesFilterDelimiter_Desc_Key" xml:space="preserve">
<value>Character used to separate the list of security roles being filtered. Make sure to use a character that is not in the security role names that exist in your environment.</value>
</data>
<data name="SecurityRoles" xml:space="preserve">
<value>Security Roles</value>
</data>
Expand Down
7 changes: 7 additions & 0 deletions control/SecurityRoleManager/utilities/parsecsvstring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ describe('parseCsvString', () => {
const result = parseCsvString(str, '\n')
expect(result).toStrictEqual(['Hello', 'World'])
})

it('should parse array containing new line, when comma is used as separator', () => {
const str = `Hello,
World`
const result = parseCsvString(str, ',')
expect(result).toStrictEqual(['Hello', 'World'])
})
})
10 changes: 8 additions & 2 deletions docs/installation-and-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
- Select `Security Role Manager` under the Add Control option.
![Select Security Role Manager](./res/configuration-select-securityrolemanager.png)
- Configure the input properties for the control:
![Configure the input properties for the control](./res/configuration-properties.png)
![Configure the input properties for the control (1)](./res/configuration-properties-1.png)
![Configure the input properties for the control (2)](./res/configuration-properties-2.png)
- EntityId:
- For `systemuser`, select the `systemuserid` field
- For `team`, select the `teamid` field
Expand All @@ -48,8 +49,13 @@
- RoleNamesFilter (optional, added in `v2.1.0`):
- If you would like to filter the list of roles that are shown on the form, enter the names of roles to be shown.
- Select `Bind to a static value`, type each security role name on a new line. Using the [maker portal](#maker-portal) will have a multi-line text box for updating the role names.
- **Note: The names must match with security role names. If roles are renamed elsewhere, they must be updated here also.**
- **Note: The names must match with security role names. If roles are renamed elsewhere, they must be updated here also or the filtering will not pick up that role anymore.**
![Role Names Filter](./res/configuration-properties-rolenamesfilter.png)
- RoleNamesFilterDelimiter (optional, added in `v2.2.0`):
- If you need to specify the character used to separate `RoleNamesFilter`, provide the delimiter (otherwise a new line will be used).
- Select `Bind to a static value`, type the character to use.
- **Note: Make sure that the character used to separate the role names does not exist in any of the security roles in your environment.**
![Role Names Filter](./res/configuration-properties-rolenamesfilterdelimiter.png)
- Save, Publish, Refresh the form.
![Save, Publish, Refresh the form](./res/configuration-save-publish.png)

Expand Down
Binary file added docs/res/configuration-properties-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.