From 7de089ce5ae1ed09d569a22c62af6914bfab2f86 Mon Sep 17 00:00:00 2001 From: Tom Herold Date: Mon, 6 Feb 2023 17:28:36 +0100 Subject: [PATCH] convert owner name information to string --- .../organization/OrganizationService.scala | 4 ++-- .../organization/organization_edit_view.tsx | 2 +- .../admin/organization/pricing_plan_utils.ts | 11 ++++++++--- .../components/pricing_enforcers.tsx | 18 +++++++++++------- frontend/javascripts/types/api_flow_types.ts | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/models/organization/OrganizationService.scala b/app/models/organization/OrganizationService.scala index 754df7bfae0..6ba4849ed11 100644 --- a/app/models/organization/OrganizationService.scala +++ b/app/models/organization/OrganizationService.scala @@ -41,7 +41,7 @@ class OrganizationService @Inject()(organizationDAO: OrganizationDAO, for { usedStorageBytes <- organizationDAO.getUsedStorage(organization._id) owner <- userDAO.findOwnerByOrg(organization._id)(GlobalAccessContext) - ownerJson <- userService.compactWrites(owner) + ownerName = s"${owner.firstName} ${owner.lastName}" } yield Json.obj( "id" -> organization._id.toString, @@ -54,7 +54,7 @@ class OrganizationService @Inject()(organizationDAO: OrganizationDAO, "includedUsers" -> organization.includedUsers, "includedStorageBytes" -> organization.includedStorageBytes, "usedStorageBytes" -> usedStorageBytes, - "owner" -> ownerJson + "ownerName" -> ownerName ) ++ adminOnlyInfo } diff --git a/frontend/javascripts/admin/organization/organization_edit_view.tsx b/frontend/javascripts/admin/organization/organization_edit_view.tsx index 609de268056..839bf78c072 100644 --- a/frontend/javascripts/admin/organization/organization_edit_view.tsx +++ b/frontend/javascripts/admin/organization/organization_edit_view.tsx @@ -181,7 +181,7 @@ class OrganizationEditView extends React.PureComponent { } - value={`${this.props.organization.owner.firstName} ${this.props.organization.owner.lastName}`} + value={this.props.organization.ownerName} readOnly disabled /> diff --git a/frontend/javascripts/admin/organization/pricing_plan_utils.ts b/frontend/javascripts/admin/organization/pricing_plan_utils.ts index b6c74eeb118..e44a273df5b 100644 --- a/frontend/javascripts/admin/organization/pricing_plan_utils.ts +++ b/frontend/javascripts/admin/organization/pricing_plan_utils.ts @@ -89,10 +89,15 @@ export function getFeatureNotAvailabeInPlanMessage( requiredPricingPlan: PricingPlanEnum, organization: APIOrganization | null, ) { + let organizationOwnerName = ""; + // expected naming schema for owner: "(M. Mustermann)" | "" - const organizationOwnerName = organization - ? `(${organization.owner.firstName[0]}. ${organization.owner.lastName})` - : ""; + if (organization) { + { + const [firstName, ...rest] = organization.ownerName.split(" "); + organizationOwnerName = `(${firstName[0]}. ${rest.join(" ")})`; + } + } return messages["organization.plan.feature_not_available"]( requiredPricingPlan, diff --git a/frontend/javascripts/components/pricing_enforcers.tsx b/frontend/javascripts/components/pricing_enforcers.tsx index 91ec66da190..2772c241c16 100644 --- a/frontend/javascripts/components/pricing_enforcers.tsx +++ b/frontend/javascripts/components/pricing_enforcers.tsx @@ -14,6 +14,7 @@ import type { OxalisState } from "oxalis/store"; import { rgbToHex } from "libs/utils"; import { PRIMARY_COLOR } from "oxalis/constants"; import UpgradePricingPlanModal from "admin/organization/upgrade_plan_modal"; +import { APIOrganization, APIUser } from "types/api_flow_types"; const PRIMARY_COLOR_HEX = rgbToHex(PRIMARY_COLOR); @@ -31,10 +32,10 @@ const handleMenuClick: MenuClickEventHandler = (info) => { type RequiredPricingProps = { requiredPricingPlan: PricingPlanEnum }; -function getUpgradeNowButton() { - const activeUser = useSelector((state: OxalisState) => state.activeUser); - const activeOrganization = useSelector((state: OxalisState) => state.activeOrganization); - +function getUpgradeNowButton( + activeUser: APIUser | null | undefined, + activeOrganization: APIOrganization | undefined, +) { return activeUser && activeOrganization && isUserAllowedToRequestUpgrades(activeUser) ? (