Skip to content

Commit

Permalink
Override settings option
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Sep 26, 2023
1 parent 637b020 commit 3d83c35
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 22 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@surfnet/sds": "^0.0.72",
"@surfnet/sds": "^0.0.83",
"dompurify": "^3.0.3",
"i18n-js": "^4.2.3",
"isomorphic-dompurify": "^1.5.0",
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/RadioButton.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.sds--radio-options {
margin: 25px 0 10px 0;
}
30 changes: 30 additions & 0 deletions client/src/components/RadioButtonGroup.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import "./RadioButton.scss";
import {RadioOptions} from "@surfnet/sds";

export default function RadioButtonGroup({
label,
name,
value,
onChange,
tooltip,
values,
labelResolver,
disabled = false
}) {

const internalOnChange = e => {
const id = e.target.id;
onChange(id ? id.replace(`${name}_`, "") : id);
}

return <RadioOptions label={label}
onChange={internalOnChange}
value={value}
name={name}
labels={values}
isMultiple={true}
labelResolver={labelResolver}
tooltip={tooltip}
disabled={disabled}/>
}
2 changes: 2 additions & 0 deletions client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const en = {
new: "Add role",
edit: "Edit role {{name}}",
urn: "URN",
advanced: "Advanced settings",
override: "Override of settings allowed?",
manage: "Service",
manageMetaData: "SURFconext entity",
provisioning: "Provisioning",
Expand Down
1 change: 1 addition & 0 deletions client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const nl = {
new: "Rol toevoegen",
edit: "Bewerk rol {{name}}",
urn: "URN",
advanced: "Advanced settings",
manage: "Dienst",
manageMetaData: "Entity",
provisioning: "Provisioning",
Expand Down
44 changes: 27 additions & 17 deletions client/src/pages/RoleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ErrorIndicator from "../components/ErrorIndicator";
import SelectField from "../components/SelectField";
import {providersToOptions, singleProviderToOption} from "../utils/Manage";
import ConfirmationDialog from "../components/ConfirmationDialog";
import RadioButtonGroup from "../components/RadioButtonGroup";

export const RoleForm = () => {

Expand Down Expand Up @@ -241,6 +242,24 @@ export const RoleForm = () => {
disabled={options.length === 1}
toolTip={I18n.t("tooltips.manageService")}
/>
<InputField name={I18n.t("roles.landingPage")}
value={role.landingPage || ""}
isUrl={true}
placeholder={I18n.t("roles.landingPagePlaceHolder")}
onBlur={e => validateValue("url", "landingPage", e.target.value)}
onChange={e => {
setRole(
{...role, landingPage: e.target.value});
setInvalidValues({...invalidValues, landingPage: false})
}}
/>
{invalidValues.landingPage &&
<ErrorIndicator msg={I18n.t("forms.invalid", {
attribute: I18n.t("roles.landingPage").toLowerCase(),
value: role.landingPage
})}/>}

<span className={"label"}>{I18n.t("roles.advanced")}</span>

<Checkbox name={I18n.t("invitations.enforceEmailEquality")}
value={role.enforceEmailEquality || false}
Expand Down Expand Up @@ -272,23 +291,14 @@ export const RoleForm = () => {
attribute: I18n.t("roles.defaultExpiryDays").toLowerCase()
})}/>}

<InputField name={I18n.t("roles.landingPage")}
value={role.landingPage || ""}
isUrl={true}
placeholder={I18n.t("roles.landingPagePlaceHolder")}
onBlur={e => validateValue("url", "landingPage", e.target.value)}
onChange={e => {
setRole(
{...role, landingPage: e.target.value});
setInvalidValues({...invalidValues, landingPage: false})
}}
/>
{invalidValues.landingPage &&
<ErrorIndicator msg={I18n.t("forms.invalid", {
attribute: I18n.t("roles.landingPage").toLowerCase(),
value: role.landingPage
})}/>}

<div className={"radio-button-group"}>
<RadioButtonGroup name={"overrideSettingsAllowed"}
label={I18n.t("roles.override")}
value={role.overrideSettingsAllowed ? "yes" : "no"}
values={["yes", "no"]}
onChange={value => setRole({...role, overrideSettingsAllowed: value === "yes"})}
labelResolver={label => I18n.t(`forms.${label}`)}/>
</div>

<section className="actions">
{!isNewRole &&
Expand Down
10 changes: 10 additions & 0 deletions client/src/pages/RoleForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
.role-form {
@include page;
@include form;

.radio-button-group {
grid-column-start: first;
}

span.label {
grid-column-start: first;
font-weight: 600;
margin-top: 32px;
}
}

}
8 changes: 4 additions & 4 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1789,10 +1789,10 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@surfnet/sds@^0.0.72":
version "0.0.72"
resolved "https://registry.yarnpkg.com/@surfnet/sds/-/sds-0.0.72.tgz#22d7149354f19b1fe826580f877c7316a59e0376"
integrity sha512-7y7dJ4C0+bnHdnvTlfCRYEAODynEF0PW7NliOrcHFRDt0eCo7iPellQr70ievJod/kYS8g9IAokU7EQQvV/A/A==
"@surfnet/sds@^0.0.83":
version "0.0.83"
resolved "https://registry.yarnpkg.com/@surfnet/sds/-/sds-0.0.83.tgz#8c5954e0a6165490b61b2d63656c0e05b32d60a7"
integrity sha512-925/wzA5FN5rJWjxvfwXI9exUQkVSFPVzHv4n3tTA3SCs6lIynJdSTXkeFJNliWr7YLrvrHZg9jUi3MqysiptA==

"@surma/rollup-plugin-off-main-thread@^2.2.3":
version "2.2.3"
Expand Down
3 changes: 3 additions & 0 deletions server/src/main/java/access/model/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class Role implements Serializable, Provisionable {
@Column(name = "block_expiry_date")
private boolean blockExpiryDate;

@Column(name = "override_settings_allowed")
private boolean overrideSettingsAllowed;

@Formula(value = "(SELECT COUNT(*) FROM user_roles ur WHERE ur.role_id=id)")
private Long userRoleCount;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `roles`
add `override_settings_allowed` bool DEFAULT 0;

0 comments on commit 3d83c35

Please sign in to comment.