Skip to content

Commit

Permalink
Re-use Role Card component
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 1, 2023
1 parent 2c5a493 commit 4f9d600
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
21 changes: 6 additions & 15 deletions client/src/components/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import I18n from "../locale/I18n";
import Logo from "./Logo";
import {Card, CardType} from "@surfnet/sds";
import {isEmpty} from "../utils/Utils";
import {deriveRemoteApplicationAttributes, providerInfo} from "../utils/Manage";
import {deriveRemoteApplicationAttributes} from "../utils/Manage";
import {ReactComponent as SearchIcon} from "@surfnet/sds/icons/functional-icons/search.svg";
import {MoreLessText} from "./MoreLessText";
import {RoleCard} from "./RoleCard";
Expand Down Expand Up @@ -39,7 +39,7 @@ export const User = ({user, other}) => {
)
}

const renderSearch = (value, valueSetter, valueReference) => {
const renderSearch = (value, valueSetter, placeholder, valueReference) => {
return (
<div className={`search standalone`}>
<div className={"sds--text-field sds--text-field--has-icon"}>
Expand All @@ -50,7 +50,7 @@ export const User = ({user, other}) => {
onChange={e => valueSetter(e.target.value)}
value={value}
ref={valueReference}
placeholder={I18n.t(`users.applicationsSearchPlaceHolder`)}/>
placeholder={placeholder}/>
<span className="sds--text-field--icon">
<SearchIcon/>
</span>
Expand All @@ -73,16 +73,7 @@ export const User = ({user, other}) => {

const renderUserRole = (userRole, index) => {
const role = userRole.role;
const provider = role.application || providerInfo(null);
const logo = provider.data.metaDataFields["logo:0:url"];
const children =
<div key={index} className={"user-role"}>
<Logo src={logo} alt={"provider"} className={"provider"}/>
<RoleCard role={role} index={index} key={index}/>
</div>;
return (
<Card cardType={CardType.Big} children={children}/>
);
return <RoleCard role={role} index={index} key={index}/>
}

const filterApplication = application => {
Expand Down Expand Up @@ -130,7 +121,7 @@ export const User = ({user, other}) => {
<p>
{I18n.t(`users.${other ? "rolesInfoOther" : "rolesInfo"}`, {name: user.name})}
</p>
{renderSearch(query, setQuery, searchRef)}
{renderSearch(query, setQuery, I18n.t(`roles.searchPlaceHolder`, searchRef))}
</div>
{filteredUserRoles
.map((userRole, index) => renderUserRole(userRole, index))}
Expand All @@ -143,7 +134,7 @@ export const User = ({user, other}) => {
<p>
{I18n.t(`users.${other ? "applicationsInfoOther" : "applicationsInfo"}`, {name: user.name})}
</p>
{renderSearch(queryApplication, setQueryApplication)}
{renderSearch(queryApplication, setQueryApplication, I18n.t(`users.applicationsSearchPlaceHolder`))}
</div>
{filteredApplications
.map((application, index) => renderApplication(application, index))}
Expand Down
2 changes: 1 addition & 1 deletion client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const en = {
users: {
found: "{{count}} {{plural}} found",
moreResults: "There are more results than shown, please refine your search.",
applicationsSearchPlaceHolder: "Search for roles...",
applicationsSearchPlaceHolder: "Search for application...",
name_email: "Name / email",
name: "Name",
email: "Email",
Expand Down
2 changes: 1 addition & 1 deletion client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const nl = {
users: {
found: "{{count}} {{plural}} gevonden",
moreResults: "Er zijn meer resultaten dan getoond kunnen worden, vereng je zoekopdracht.",
applicationsSearchPlaceHolder: "Zoek rollen...",
applicationsSearchPlaceHolder: "Zoek applicaties...",
name_email: "Naam / e-mail",
name: "Naam",
email: "E-mail",
Expand Down

0 comments on commit 4f9d600

Please sign in to comment.