}
const DEFAULT_CUSTOM_ROLE_PERMISSIONS: GitHubMapping['permissions'] = {
- user: false,
+ user: true,
codeViewer: false,
issueAdmin: false,
securityHotspotAdmin: false,
}
};
+ const haveEmptyCustomRoles = !!mapping?.some(
+ (el) => !el.isBaseRole && !Object.values(el.permissions).some(Boolean),
+ );
+
return (
- <Modal contentLabel={header} onRequestClose={onClose} shouldCloseOnEsc size="medium">
+ <Modal
+ contentLabel={header}
+ onRequestClose={onClose}
+ shouldCloseOnOverlayClick={false}
+ shouldCloseOnEsc={false}
+ size="medium"
+ >
<div className="modal-head">
<h2>{header}</h2>
</div>
<Spinner loading={isLoading} />
</div>
<div className="modal-foot">
- <SubmitButton onClick={onClose}>{translate('close')}</SubmitButton>
+ <div className="sw-flex sw-items-center sw-justify-end sw-h-8">
+ <Alert variant="error" className="sw-inline-block sw-mb-0 sw-mr-2">
+ {haveEmptyCustomRoles &&
+ translate(
+ 'settings.authentication.github.configuration.roles_mapping.empty_custom_role',
+ )}
+ </Alert>
+ <SubmitButton disabled={haveEmptyCustomRoles} onClick={onClose}>
+ {translate('close')}
+ </SubmitButton>
+ </div>
</div>
</Modal>
);
>
{translate('cancel')}
</ResetButtonLink>
- <Alert variant="warning" className="sw-w-[300px] sw-mb-0">
+ <Alert variant="warning" className="sw-mb-0">
{hasGithubProvisioningConfigChange &&
translate('settings.authentication.github.configuration.unsaved_changes')}
</Alert>
roleExistsError: byRole('dialog', {
name: 'settings.authentication.github.configuration.roles_mapping.dialog.title',
}).byText('settings.authentication.github.configuration.roles_mapping.role_exists'),
+ emptyRoleError: byRole('dialog', {
+ name: 'settings.authentication.github.configuration.roles_mapping.dialog.title',
+ }).byText('settings.authentication.github.configuration.roles_mapping.empty_custom_role'),
deleteCustomRoleCustom2: byRole('button', {
name: 'settings.authentication.github.configuration.roles_mapping.dialog.delete_custom_role.custom2',
}),
await user.click(github.customRoleAddBtn.get());
let custom3Checkboxes = github.mappingCheckbox.getAll(github.getMappingRowByRole('custom3'));
- expect(custom3Checkboxes[0]).not.toBeChecked();
+ expect(custom3Checkboxes[0]).toBeChecked();
expect(custom3Checkboxes[1]).not.toBeChecked();
expect(custom3Checkboxes[2]).not.toBeChecked();
expect(custom3Checkboxes[3]).not.toBeChecked();
expect(custom3Checkboxes[4]).not.toBeChecked();
expect(custom3Checkboxes[5]).not.toBeChecked();
+ await user.click(custom3Checkboxes[0]);
+ expect(await github.emptyRoleError.find()).toBeInTheDocument();
+ expect(github.mappingDialogClose.get()).toBeDisabled();
await user.click(custom3Checkboxes[1]);
+ expect(github.emptyRoleError.query()).not.toBeInTheDocument();
+ expect(github.mappingDialogClose.get()).toBeEnabled();
await user.click(github.mappingDialogClose.get());
expect(await github.saveGithubProvisioning.find()).toBeEnabled();
settings.authentication.github.configuration.roles_mapping.dialog.title=GitHub Roles Mapping
settings.authentication.github.configuration.roles_mapping.dialog.roles_column=Roles
settings.authentication.github.configuration.roles_mapping.dialog.add_custom_role=Add custom role:
-settings.authentication.github.configuration.roles_mapping.role_exists=Role already exists
settings.authentication.github.configuration.roles_mapping.dialog.custom_roles_description=When a custom role name added here matches an existing GitHub custom role in any of your organizations, the mapping applies to all users with this custom role. If an existing GitHub custom role has no exact match in this list, the permissions of its inherited base role are mapped.
settings.authentication.github.configuration.roles_mapping.dialog.delete_custom_role=Delete custom role {0}
+settings.authentication.github.configuration.roles_mapping.role_exists=Role already exists.
+settings.authentication.github.configuration.roles_mapping.empty_custom_role=Custom roles should have some permissions.
settings.authentication.github.configuration.unsaved_changes=You have unsaved changes.
# SAML