Fixed required for + localization (#2784)

This commit is contained in:
Erik Jan de Wit 2022-06-13 11:42:17 +02:00 committed by GitHub
parent 4eb0b90d75
commit 741c09cca1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -347,6 +347,11 @@
"required": "Required", "required": "Required",
"requiredFor": "Required for", "requiredFor": "Required for",
"requiredWhen": "Required when", "requiredWhen": "Required when",
"requiredForLabel": {
"both": "Both users and admins",
"users": "Only users",
"admins": "Only admins"
},
"whoCanEdit": "Who can edit?", "whoCanEdit": "Who can edit?",
"whoCanView": "Who can view?", "whoCanView": "Who can view?",
"user": "User", "user": "User",

View file

@ -162,6 +162,7 @@ export default function NewAttributeSettings() {
return attribute; return attribute;
} }
delete attribute.required;
return Object.assign( return Object.assign(
{ {
...attribute, ...attribute,

View file

@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
/* eslint-disable prettier/prettier */
import React, { useState } from "react"; import React, { useState } from "react";
import { import {
Divider, Divider,
@ -24,9 +22,9 @@ import { isEqual } from "lodash-es";
import "../../realm-settings-section.css"; import "../../realm-settings-section.css";
const REQUIRED_FOR = [ const REQUIRED_FOR = [
{ label: "Both users and admins", value: ["admin", "user"] }, { label: "requiredForLabel.both", value: ["admin", "user"] },
{ label: "Only users", value: ["user"] }, { label: "requiredForLabel.users", value: ["user"] },
{ label: "Only admins", value: ["admin"] }, { label: "requiredForLabel.admins", value: ["admin"] },
] as const; ] as const;
export const AttributeGeneralSettings = () => { export const AttributeGeneralSettings = () => {
@ -292,7 +290,7 @@ export const AttributeGeneralSettings = () => {
onChange={() => { onChange={() => {
onChange(option.value); onChange(option.value);
}} }}
label={option.label} label={t(option.label)}
className="kc-requiredFor-option" className="kc-requiredFor-option"
/> />
))} ))}