From 1273d5cff951ab26f42d0df73907e8a6abb52387 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Fri, 24 May 2024 13:04:47 +0200 Subject: [PATCH 01/22] Add new tab --- resources/translations/nl.json | 3 ++ .../Integrations/Detail/OrganizersInfo.tsx | 39 +++++++++++++++++++ resources/ts/Pages/Integrations/Detail.tsx | 7 ++++ 3 files changed, 49 insertions(+) create mode 100644 resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx diff --git a/resources/translations/nl.json b/resources/translations/nl.json index 21671102e..c56284fa4 100644 --- a/resources/translations/nl.json +++ b/resources/translations/nl.json @@ -216,6 +216,9 @@ "description": "Contacten kunnen de integratie aanpassen, activeren en verwijderen. Eens verwijderd heeft een contact geen toegang meer tot de integratie." } }, + "organizers_info": { + "title": "Organisaties" + }, "billing_info": { "title": { "billing": "Facturatiegegevens", diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx new file mode 100644 index 000000000..bd7ef9a2a --- /dev/null +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -0,0 +1,39 @@ +import React, { useContext } from "react"; +import { Heading } from "../../Heading"; +import { FormElement } from "../../FormElement"; +import { Input } from "../../Input"; +import { ButtonPrimary } from "../../ButtonPrimary"; +import { useTranslation } from "react-i18next"; +import { useForm } from "@inertiajs/react"; +import { Alert } from "../../Alert"; +import { IntegrationType } from "../../../types/IntegrationType"; +import { IntegrationStatus } from "../../../types/IntegrationStatus"; +import { PricingPlanContext } from "../../../Context/PricingPlan"; +import { formatCurrency } from "../../../utils/formatCurrency"; +import { formatPricing } from "../../../utils/formatPricing"; +import type { Integration } from "../../../types/Integration"; + +type Props = Integration; + +export const OrganizersInfo = ({ + id, + organization, + subscription, + coupon, + status, +}: Props) => { + const { t } = useTranslation(); + + console.log(organization); + return ( + <> + + {t("details.organizers_info.title")} + +

+ Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor + je acties kan uitvoeren in de UiTPAS API. +

+ + ); +}; diff --git a/resources/ts/Pages/Integrations/Detail.tsx b/resources/ts/Pages/Integrations/Detail.tsx index 45ba2ada3..05bac8967 100644 --- a/resources/ts/Pages/Integrations/Detail.tsx +++ b/resources/ts/Pages/Integrations/Detail.tsx @@ -23,6 +23,7 @@ import { PricingPlanProvider } from "../../Context/PricingPlan"; import { useIsMobile } from "../../hooks/useIsMobile"; import { CouponInfoProvider } from "../../Context/CouponInfo"; import type { Integration } from "../../types/Integration"; +import { OrganizersInfo } from "../../Components/Integrations/Detail/OrganizersInfo"; type Props = { integration: Integration; @@ -175,6 +176,12 @@ const Detail = ({ duplicateContactErrorMessage={duplicateContactErrorMessage} /> + + + Date: Tue, 11 Jun 2024 13:26:28 +0200 Subject: [PATCH 02/22] Set Organizers on Integration value object --- app/Domain/Integrations/Integration.php | 12 ++++++++++++ app/Domain/Integrations/Models/IntegrationModel.php | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/app/Domain/Integrations/Integration.php b/app/Domain/Integrations/Integration.php index 034a589bf..913946af2 100644 --- a/app/Domain/Integrations/Integration.php +++ b/app/Domain/Integrations/Integration.php @@ -31,6 +31,9 @@ final class Integration private ?Organization $organization; + /** @var array */ + private array $organizers; + /** @var array */ private array $uiTiDv1Consumers; @@ -57,6 +60,7 @@ public function __construct( $this->uiTiDv1Consumers = []; $this->auth0Clients = []; $this->keycloakClients = []; + $this->organizers = []; $this->organization = null; $this->keyVisibility = KeyVisibility::v2; $this->keyVisibilityUpgrade = null; @@ -122,6 +126,13 @@ public function withKeycloakClients(KeycloakClient ...$keycloakClients): self return $clone; } + public function withOrganizers(Organizer ...$organizers): self + { + $clone = clone $this; + $clone->organizers = $organizers; + return $clone; + } + public function withSubscription(Subscription $subscription): self { $clone = clone $this; @@ -226,6 +237,7 @@ public function toArray(): array 'contacts' => $this->contacts, 'urls' => $this->urls, 'organization' => $this->organization, + 'organizers' => $this->organizers, 'authClients' => $this->auth0Clients, 'legacyAuthConsumers' => $this->uiTiDv1Consumers, 'keycloakClients' => $this->keycloakClients, diff --git a/app/Domain/Integrations/Models/IntegrationModel.php b/app/Domain/Integrations/Models/IntegrationModel.php index 1f6ff7c3a..f9305ab58 100644 --- a/app/Domain/Integrations/Models/IntegrationModel.php +++ b/app/Domain/Integrations/Models/IntegrationModel.php @@ -350,6 +350,11 @@ public function toDomain(): Integration ->get() ->map(fn (KeycloakClientModel $keycloakClientModel) => $keycloakClientModel->toDomain()) ->toArray() + )->withOrganizers( + ...$this->organizers() + ->get() + ->map(fn (OrganizerModel $organizerModel) => $organizerModel->toDomain()) + ->toArray() ); if ($this->keyVisibilityUpgrade) { From 5c533eb1128c2a1ef89d160248bd2c46445f444f Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 11 Jun 2024 15:16:52 +0200 Subject: [PATCH 03/22] Add new Search Servie method to find organizers --- app/Search/Sapi3/Sapi3SearchService.php | 12 ++++++++++++ app/Search/Sapi3/SearchService.php | 1 + 2 files changed, 13 insertions(+) diff --git a/app/Search/Sapi3/Sapi3SearchService.php b/app/Search/Sapi3/Sapi3SearchService.php index fb169697b..6b7ed6f96 100644 --- a/app/Search/Sapi3/Sapi3SearchService.php +++ b/app/Search/Sapi3/Sapi3SearchService.php @@ -4,6 +4,7 @@ namespace App\Search\Sapi3; +use CultuurNet\SearchV3\Parameter\Id; use CultuurNet\SearchV3\Parameter\Label; use CultuurNet\SearchV3\SearchClientInterface; use CultuurNet\SearchV3\SearchQuery; @@ -24,4 +25,15 @@ public function searchUiTPASOrganizer(string $name): PagedCollection return $this->searchClient->searchOrganizers($searchQuery); } + + public function findUiTPASOrganizers(string ...$ids): PagedCollection + { + $searchQuery = new SearchQuery(); + $searchQuery->setEmbed(true); + foreach ($ids as $id) { + $searchQuery->addParameter(new Id($id)); + } + + return $this->searchClient->searchOrganizers($searchQuery); + } } diff --git a/app/Search/Sapi3/SearchService.php b/app/Search/Sapi3/SearchService.php index 4bce72119..66a8706e0 100644 --- a/app/Search/Sapi3/SearchService.php +++ b/app/Search/Sapi3/SearchService.php @@ -9,4 +9,5 @@ interface SearchService { public function searchUiTPASOrganizer(string $name): PagedCollection; + public function findUiTPASOrganizers(string ...$ids): PagedCollection; } From e7958a27f6649915b2acaf41670260f1ce0eccdf Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 11 Jun 2024 15:17:24 +0200 Subject: [PATCH 04/22] Work on fetching organizers --- .../Controllers/IntegrationController.php | 24 +++++++++++++++---- app/Domain/Integrations/Integration.php | 8 +++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/Domain/Integrations/Controllers/IntegrationController.php b/app/Domain/Integrations/Controllers/IntegrationController.php index ac8cb1c34..3688adf70 100644 --- a/app/Domain/Integrations/Controllers/IntegrationController.php +++ b/app/Domain/Integrations/Controllers/IntegrationController.php @@ -10,11 +10,11 @@ use App\Domain\Contacts\Repositories\ContactKeyVisibilityRepository; use App\Domain\Contacts\Repositories\ContactRepository; use App\Domain\Coupons\Repositories\CouponRepository; +use App\Domain\Integrations\FormRequests\KeyVisibilityUpgradeRequest; use App\Domain\Integrations\FormRequests\RequestActivationRequest; use App\Domain\Integrations\FormRequests\StoreContactRequest; use App\Domain\Integrations\FormRequests\StoreIntegrationRequest; use App\Domain\Integrations\FormRequests\StoreIntegrationUrlRequest; -use App\Domain\Integrations\FormRequests\KeyVisibilityUpgradeRequest; use App\Domain\Integrations\FormRequests\UpdateContactInfoRequest; use App\Domain\Integrations\FormRequests\UpdateIntegrationRequest; use App\Domain\Integrations\FormRequests\UpdateIntegrationUrlsRequest; @@ -23,25 +23,28 @@ use App\Domain\Integrations\IntegrationType; use App\Domain\Integrations\IntegrationUrl; use App\Domain\Integrations\KeyVisibility; +use App\Domain\Integrations\Mappers\KeyVisibilityUpgradeMapper; use App\Domain\Integrations\Mappers\OrganizationMapper; use App\Domain\Integrations\Mappers\StoreContactMapper; use App\Domain\Integrations\Mappers\StoreIntegrationMapper; use App\Domain\Integrations\Mappers\StoreIntegrationUrlMapper; -use App\Domain\Integrations\Mappers\KeyVisibilityUpgradeMapper; use App\Domain\Integrations\Mappers\UpdateContactInfoMapper; use App\Domain\Integrations\Mappers\UpdateIntegrationMapper; use App\Domain\Integrations\Mappers\UpdateIntegrationUrlsMapper; +use App\Domain\Integrations\Organizer; use App\Domain\Integrations\Repositories\IntegrationRepository; use App\Domain\Integrations\Repositories\IntegrationUrlRepository; use App\Domain\KeyVisibilityUpgrades\KeyVisibilityUpgrade; +use App\Domain\KeyVisibilityUpgrades\Repositories\KeyVisibilityUpgradeRepository; use App\Domain\Organizations\Repositories\OrganizationRepository; use App\Domain\Subscriptions\Repositories\SubscriptionRepository; -use App\Domain\KeyVisibilityUpgrades\Repositories\KeyVisibilityUpgradeRepository; use App\Http\Controllers\Controller; use App\ProjectAanvraag\ProjectAanvraagUrl; use App\Router\TranslatedRoute; +use App\Search\Sapi3\SearchService; use App\UiTiDv1\Repositories\UiTiDv1ConsumerRepository; use Carbon\Carbon; +use CultuurNet\SearchV3\ValueObjects\Organizer as SapiOrganizer; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\UniqueConstraintViolationException; use Illuminate\Http\RedirectResponse; @@ -67,8 +70,10 @@ public function __construct( private readonly Auth0ClientRepository $auth0ClientRepository, private readonly UiTiDv1ConsumerRepository $uitidV1ConsumerRepository, private readonly KeyVisibilityUpgradeRepository $keyVisibilityUpgradeRepository, + private readonly SearchService $searchClient, private readonly CurrentUser $currentUser - ) { + ) + { } public function index(Request $request): Response @@ -167,11 +172,22 @@ public function show(string $id): Response $integration = $this->integrationRepository->getById(Uuid::fromString($id)); $oldCredentialsExpirationDate = $this->getExpirationDateForOldCredentials($integration->getKeyVisibilityUpgrade()); + $organizerIds = collect($integration->organizers())->map(fn(Organizer $organizer) => $organizer->organizerId->toString()); + $organizers = collect($this->searchClient->findUiTPASOrganizers(...$organizerIds)->getMember()->getItems())->map(function (SapiOrganizer $organizer) { + $id = explode('/', $organizer->getId() ?? ''); + + return [ + 'id' => $id[count($id) - 1], + 'name' => $organizer->getName()->getValues(), + ]; + }); + return Inertia::render('Integrations/Detail', [ 'integration' => $integration->toArray(), 'oldCredentialsExpirationDate' => $oldCredentialsExpirationDate, 'email' => Auth::user()?->email, 'subscriptions' => $this->subscriptionRepository->all(), + 'organizers' => $organizers, ]); } diff --git a/app/Domain/Integrations/Integration.php b/app/Domain/Integrations/Integration.php index 913946af2..4b44cb5b4 100644 --- a/app/Domain/Integrations/Integration.php +++ b/app/Domain/Integrations/Integration.php @@ -177,6 +177,14 @@ public function organization(): ?Organization return $this->organization; } + /** + * @return array + */ + public function organizers(): array + { + return $this->organizers; + } + /** @return array */ public function uiTiDv1Consumers(): array { From 1794a2f5726cd7541f08686014e67028ab75ba64 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 11 Jun 2024 15:17:43 +0200 Subject: [PATCH 05/22] Work on layout of Organizers tab --- .../Integrations/Detail/OrganizersInfo.tsx | 51 +++++++++++-------- resources/ts/Pages/Integrations/Detail.tsx | 3 +- resources/ts/types/Organizer.ts | 5 ++ 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 resources/ts/types/Organizer.ts diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index bd7ef9a2a..c663d5b2e 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -1,30 +1,18 @@ -import React, { useContext } from "react"; +import React from "react"; import { Heading } from "../../Heading"; -import { FormElement } from "../../FormElement"; -import { Input } from "../../Input"; -import { ButtonPrimary } from "../../ButtonPrimary"; import { useTranslation } from "react-i18next"; -import { useForm } from "@inertiajs/react"; -import { Alert } from "../../Alert"; -import { IntegrationType } from "../../../types/IntegrationType"; -import { IntegrationStatus } from "../../../types/IntegrationStatus"; -import { PricingPlanContext } from "../../../Context/PricingPlan"; -import { formatCurrency } from "../../../utils/formatCurrency"; -import { formatPricing } from "../../../utils/formatPricing"; import type { Integration } from "../../../types/Integration"; +import { Card } from "../../Card"; +import { CopyText } from "../../CopyText"; +import { ButtonIcon } from "../../ButtonIcon"; +import { faPencil, faTrash } from "@fortawesome/free-solid-svg-icons"; type Props = Integration; -export const OrganizersInfo = ({ - id, - organization, - subscription, - coupon, - status, -}: Props) => { - const { t } = useTranslation(); +export const OrganizersInfo = (props: Props) => { + const { t, i18n } = useTranslation(); - console.log(organization); + console.log(props); return ( <> @@ -34,6 +22,29 @@ export const OrganizersInfo = ({ Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor je acties kan uitvoeren in de UiTPAS API.

+ + {props.organizers.map((organizer) => ( + +
+

{organizer.name[i18n.language]}

+ {organizer.id} +
+ + +
+
Permissies
+
+
    +
  • Tarieven opvragen
  • +
  • UITPAS prijzen ophalen
  • +
  • Organisatoren zoeken
  • +
  • Voordelen zoeken
  • +
  • Voordelen aanmaken en aanpassen
  • +
+
+
+
+ ))} ); }; diff --git a/resources/ts/Pages/Integrations/Detail.tsx b/resources/ts/Pages/Integrations/Detail.tsx index 05bac8967..8ff5240cc 100644 --- a/resources/ts/Pages/Integrations/Detail.tsx +++ b/resources/ts/Pages/Integrations/Detail.tsx @@ -38,6 +38,7 @@ const Detail = ({ email, subscriptions, oldCredentialsExpirationDate, + organizers, errors, }: Props) => { const { t } = useTranslation(); @@ -180,7 +181,7 @@ const Detail = ({ type="organisations" label={t("details.organizers_info.title")} > - +
Date: Fri, 14 Jun 2024 15:24:15 +0200 Subject: [PATCH 06/22] Tweak layout of organizers --- resources/ts/Components/CopyText.tsx | 2 +- .../Integrations/Detail/OrganizersInfo.tsx | 27 +++++++------------ resources/ts/types/Organizer.ts | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/resources/ts/Components/CopyText.tsx b/resources/ts/Components/CopyText.tsx index e0caf07e7..85bbd6b0d 100644 --- a/resources/ts/Components/CopyText.tsx +++ b/resources/ts/Components/CopyText.tsx @@ -23,7 +23,7 @@ export const CopyText = ({ children }: Props) => { }; return ( -
+
{ +export const OrganizersInfo = ({ organizers }: Props) => { const { t, i18n } = useTranslation(); - console.log(props); return ( <> @@ -22,25 +22,16 @@ export const OrganizersInfo = (props: Props) => { Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor je acties kan uitvoeren in de UiTPAS API.

- - {props.organizers.map((organizer) => ( - -
+ {organizers.map((organizer) => ( + +

{organizer.name[i18n.language]}

- {organizer.id}
- - + {organizer.id}
-
Permissies
-
    -
  • Tarieven opvragen
  • -
  • UITPAS prijzen ophalen
  • -
  • Organisatoren zoeken
  • -
  • Voordelen zoeken
  • -
  • Voordelen aanmaken en aanpassen
  • -
+ +
diff --git a/resources/ts/types/Organizer.ts b/resources/ts/types/Organizer.ts index e110ec4eb..9d7fc3090 100644 --- a/resources/ts/types/Organizer.ts +++ b/resources/ts/types/Organizer.ts @@ -1,5 +1,5 @@ export type Organizer = { id: string; - name: string; + name: { [key: string]: string }; description: string; }; From db19436f94dd1292cf1ed87e32d7c8fd51a5b163 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Fri, 14 Jun 2024 15:28:55 +0200 Subject: [PATCH 07/22] Add translations --- resources/translations/en.json | 4 ++++ resources/translations/nl.json | 3 ++- .../ts/Components/Integrations/Detail/OrganizersInfo.tsx | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/translations/en.json b/resources/translations/en.json index 6cf490257..2cbdabfd3 100644 --- a/resources/translations/en.json +++ b/resources/translations/en.json @@ -217,6 +217,10 @@ "description": "Contacts can edit, activate, and delete the integration. Once deleted, a contact no longer has access to the integration." } }, + "organizers_info": { + "title": "Organizers", + "description": "Below you see an overview of the UiTdatabank organizers for which you can execute actions in the UiTPAS API." + }, "billing_info": { "title": { "billing": "Billing information", diff --git a/resources/translations/nl.json b/resources/translations/nl.json index 59af96e0d..31f55bdb1 100644 --- a/resources/translations/nl.json +++ b/resources/translations/nl.json @@ -218,7 +218,8 @@ } }, "organizers_info": { - "title": "Organisaties" + "title": "Organisaties", + "description": "Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor je acties kan uitvoeren in de UiTPAS API." }, "billing_info": { "title": { diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index ef814a3c8..be806b1f1 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -18,10 +18,7 @@ export const OrganizersInfo = ({ organizers }: Props) => { {t("details.organizers_info.title")} -

- Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor - je acties kan uitvoeren in de UiTPAS API. -

+

{t("details.organizers_info.description")}

{organizers.map((organizer) => (
From 8aa488ebae573ce1c8f08996350c90e6de929d80 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 13:27:41 +0200 Subject: [PATCH 08/22] Split organizers by Test/Live --- .../Controllers/IntegrationController.php | 1 + .../Integrations/Detail/OrganizersInfo.tsx | 45 ++++++++++++++++--- resources/ts/types/Organizer.ts | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/app/Domain/Integrations/Controllers/IntegrationController.php b/app/Domain/Integrations/Controllers/IntegrationController.php index 3688adf70..304ddee14 100644 --- a/app/Domain/Integrations/Controllers/IntegrationController.php +++ b/app/Domain/Integrations/Controllers/IntegrationController.php @@ -179,6 +179,7 @@ public function show(string $id): Response return [ 'id' => $id[count($id) - 1], 'name' => $organizer->getName()->getValues(), + 'status' => $organizer->getWorkflowStatus() === 'ACTIVE' ? 'LIVE' : 'TEST', ]; }); diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index be806b1f1..97678da4c 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -7,18 +7,28 @@ import { CopyText } from "../../CopyText"; import { ButtonIcon } from "../../ButtonIcon"; import { faPencil, faTrash } from "@fortawesome/free-solid-svg-icons"; import { Organizer } from "../../../types/Organizer"; +import { groupBy } from "lodash"; +import { ButtonPrimary } from "../../ButtonPrimary"; type Props = Integration & { organizers: Organizer[] }; -export const OrganizersInfo = ({ organizers }: Props) => { +const OrganizersSection = ({ + sectionName, + organizers, +}: { + organizers: Organizer[]; + sectionName: Organizer["status"]; +}) => { const { t, i18n } = useTranslation(); + if (!organizers.length) { + return null; + } return ( <> - {t("details.organizers_info.title")} + {sectionName} -

{t("details.organizers_info.description")}

{organizers.map((organizer) => (
@@ -26,13 +36,34 @@ export const OrganizersInfo = ({ organizers }: Props) => {
{organizer.id}
-
- - -
+ {sectionName === "Live" && ( +
+ + +
+ )}
))} + {sectionName === "Live" && ( + Organisatie toevoegen + )} + + ); +}; + +export const OrganizersInfo = ({ organizers }: Props) => { + const { t } = useTranslation(); + const byStatus = groupBy(organizers, "status"); + + return ( + <> + + {t("details.organizers_info.title")} + +

{t("details.organizers_info.description")}

+ + ); }; diff --git a/resources/ts/types/Organizer.ts b/resources/ts/types/Organizer.ts index 9d7fc3090..2b0a3c806 100644 --- a/resources/ts/types/Organizer.ts +++ b/resources/ts/types/Organizer.ts @@ -2,4 +2,5 @@ export type Organizer = { id: string; name: { [key: string]: string }; description: string; + status: "Live" | "Test"; }; From b9858e65ca97236cd65df033b1eafe18d6afe892 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 14:55:41 +0200 Subject: [PATCH 09/22] Add button translation --- resources/translations/en.json | 3 ++- resources/translations/nl.json | 3 ++- .../Components/Integrations/Detail/OrganizersInfo.tsx | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/translations/en.json b/resources/translations/en.json index 2cbdabfd3..0bbd73762 100644 --- a/resources/translations/en.json +++ b/resources/translations/en.json @@ -219,7 +219,8 @@ }, "organizers_info": { "title": "Organizers", - "description": "Below you see an overview of the UiTdatabank organizers for which you can execute actions in the UiTPAS API." + "description": "Below you see an overview of the UiTdatabank organizers for which you can execute actions in the UiTPAS API.", + "add": "Add organizer" }, "billing_info": { "title": { diff --git a/resources/translations/nl.json b/resources/translations/nl.json index 31f55bdb1..33521c750 100644 --- a/resources/translations/nl.json +++ b/resources/translations/nl.json @@ -219,7 +219,8 @@ }, "organizers_info": { "title": "Organisaties", - "description": "Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor je acties kan uitvoeren in de UiTPAS API." + "description": "Hieronder vind je een overzicht van de UiTdatabank organisaties waarvoor je acties kan uitvoeren in de UiTPAS API.", + "add": "Organisatie toevoegen" }, "billing_info": { "title": { diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index 97678da4c..47dfb81ce 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -45,9 +45,13 @@ const OrganizersSection = ({
))} - {sectionName === "Live" && ( - Organisatie toevoegen - )} +
+ {sectionName === "Live" && ( + + {t("details.organizers_info.add")} + + )} +
); }; From 97a995d00f974d5843ec77bf21dbf5644ae362e4 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 14:57:26 +0200 Subject: [PATCH 10/22] Unify casing --- app/Domain/Integrations/Controllers/IntegrationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Domain/Integrations/Controllers/IntegrationController.php b/app/Domain/Integrations/Controllers/IntegrationController.php index 304ddee14..f0058a936 100644 --- a/app/Domain/Integrations/Controllers/IntegrationController.php +++ b/app/Domain/Integrations/Controllers/IntegrationController.php @@ -179,7 +179,7 @@ public function show(string $id): Response return [ 'id' => $id[count($id) - 1], 'name' => $organizer->getName()->getValues(), - 'status' => $organizer->getWorkflowStatus() === 'ACTIVE' ? 'LIVE' : 'TEST', + 'status' => $organizer->getWorkflowStatus() === 'ACTIVE' ? 'Live' : 'Test', ]; }); From 7eae3513ac623bf97e9ccb0178c669c5b019caf2 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 15:03:10 +0200 Subject: [PATCH 11/22] Linting --- .../Integrations/Controllers/IntegrationController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Domain/Integrations/Controllers/IntegrationController.php b/app/Domain/Integrations/Controllers/IntegrationController.php index f0058a936..cd05d6be9 100644 --- a/app/Domain/Integrations/Controllers/IntegrationController.php +++ b/app/Domain/Integrations/Controllers/IntegrationController.php @@ -72,8 +72,7 @@ public function __construct( private readonly KeyVisibilityUpgradeRepository $keyVisibilityUpgradeRepository, private readonly SearchService $searchClient, private readonly CurrentUser $currentUser - ) - { + ) { } public function index(Request $request): Response @@ -172,13 +171,14 @@ public function show(string $id): Response $integration = $this->integrationRepository->getById(Uuid::fromString($id)); $oldCredentialsExpirationDate = $this->getExpirationDateForOldCredentials($integration->getKeyVisibilityUpgrade()); - $organizerIds = collect($integration->organizers())->map(fn(Organizer $organizer) => $organizer->organizerId->toString()); - $organizers = collect($this->searchClient->findUiTPASOrganizers(...$organizerIds)->getMember()->getItems())->map(function (SapiOrganizer $organizer) { + $organizerIds = collect($integration->organizers())->map(fn (Organizer $organizer) => $organizer->organizerId->toString()); + $uitpasOrganizers = $this->searchClient->findUiTPASOrganizers(...$organizerIds)->getMember()?->getItems(); + $organizers = collect($uitpasOrganizers)->map(function (SapiOrganizer $organizer) { $id = explode('/', $organizer->getId() ?? ''); return [ 'id' => $id[count($id) - 1], - 'name' => $organizer->getName()->getValues(), + 'name' => $organizer->getName()?->getValues() ?? $id, 'status' => $organizer->getWorkflowStatus() === 'ACTIVE' ? 'Live' : 'Test', ]; }); From 40a2274ac4f39ace62521b3d21fdfe1733a7122f Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 15:10:27 +0200 Subject: [PATCH 12/22] Revert unused integration resource change --- app/Domain/Integrations/Integration.php | 20 ------------------- .../Integrations/Models/IntegrationModel.php | 5 ----- 2 files changed, 25 deletions(-) diff --git a/app/Domain/Integrations/Integration.php b/app/Domain/Integrations/Integration.php index 4b44cb5b4..034a589bf 100644 --- a/app/Domain/Integrations/Integration.php +++ b/app/Domain/Integrations/Integration.php @@ -31,9 +31,6 @@ final class Integration private ?Organization $organization; - /** @var array */ - private array $organizers; - /** @var array */ private array $uiTiDv1Consumers; @@ -60,7 +57,6 @@ public function __construct( $this->uiTiDv1Consumers = []; $this->auth0Clients = []; $this->keycloakClients = []; - $this->organizers = []; $this->organization = null; $this->keyVisibility = KeyVisibility::v2; $this->keyVisibilityUpgrade = null; @@ -126,13 +122,6 @@ public function withKeycloakClients(KeycloakClient ...$keycloakClients): self return $clone; } - public function withOrganizers(Organizer ...$organizers): self - { - $clone = clone $this; - $clone->organizers = $organizers; - return $clone; - } - public function withSubscription(Subscription $subscription): self { $clone = clone $this; @@ -177,14 +166,6 @@ public function organization(): ?Organization return $this->organization; } - /** - * @return array - */ - public function organizers(): array - { - return $this->organizers; - } - /** @return array */ public function uiTiDv1Consumers(): array { @@ -245,7 +226,6 @@ public function toArray(): array 'contacts' => $this->contacts, 'urls' => $this->urls, 'organization' => $this->organization, - 'organizers' => $this->organizers, 'authClients' => $this->auth0Clients, 'legacyAuthConsumers' => $this->uiTiDv1Consumers, 'keycloakClients' => $this->keycloakClients, diff --git a/app/Domain/Integrations/Models/IntegrationModel.php b/app/Domain/Integrations/Models/IntegrationModel.php index f9305ab58..1f6ff7c3a 100644 --- a/app/Domain/Integrations/Models/IntegrationModel.php +++ b/app/Domain/Integrations/Models/IntegrationModel.php @@ -350,11 +350,6 @@ public function toDomain(): Integration ->get() ->map(fn (KeycloakClientModel $keycloakClientModel) => $keycloakClientModel->toDomain()) ->toArray() - )->withOrganizers( - ...$this->organizers() - ->get() - ->map(fn (OrganizerModel $organizerModel) => $organizerModel->toDomain()) - ->toArray() ); if ($this->keyVisibilityUpgrade) { From 861d7bb9cf39b7738933f70579b2ac33734cc60c Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 15:11:44 +0200 Subject: [PATCH 13/22] Linting --- resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx | 2 +- resources/ts/Pages/Integrations/Detail.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index 47dfb81ce..4d624b1d5 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -6,7 +6,7 @@ import { Card } from "../../Card"; import { CopyText } from "../../CopyText"; import { ButtonIcon } from "../../ButtonIcon"; import { faPencil, faTrash } from "@fortawesome/free-solid-svg-icons"; -import { Organizer } from "../../../types/Organizer"; +import type { Organizer } from "../../../types/Organizer"; import { groupBy } from "lodash"; import { ButtonPrimary } from "../../ButtonPrimary"; diff --git a/resources/ts/Pages/Integrations/Detail.tsx b/resources/ts/Pages/Integrations/Detail.tsx index 8ff5240cc..59a737a4d 100644 --- a/resources/ts/Pages/Integrations/Detail.tsx +++ b/resources/ts/Pages/Integrations/Detail.tsx @@ -38,7 +38,6 @@ const Detail = ({ email, subscriptions, oldCredentialsExpirationDate, - organizers, errors, }: Props) => { const { t } = useTranslation(); From d2bb60a16e101e0004f3e51d87f282c3639a2364 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 15:13:14 +0200 Subject: [PATCH 14/22] Add missing prop --- resources/ts/Pages/Integrations/Detail.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/ts/Pages/Integrations/Detail.tsx b/resources/ts/Pages/Integrations/Detail.tsx index 59a737a4d..79861aa11 100644 --- a/resources/ts/Pages/Integrations/Detail.tsx +++ b/resources/ts/Pages/Integrations/Detail.tsx @@ -24,6 +24,7 @@ import { useIsMobile } from "../../hooks/useIsMobile"; import { CouponInfoProvider } from "../../Context/CouponInfo"; import type { Integration } from "../../types/Integration"; import { OrganizersInfo } from "../../Components/Integrations/Detail/OrganizersInfo"; +import type { Organizer } from "../../types/Organizer"; type Props = { integration: Integration; @@ -31,6 +32,7 @@ type Props = { subscriptions: Subscription[]; oldCredentialsExpirationDate: string; errors: Record; + organizers: Organizer[]; }; const Detail = ({ @@ -38,6 +40,7 @@ const Detail = ({ email, subscriptions, oldCredentialsExpirationDate, + organizers, errors, }: Props) => { const { t } = useTranslation(); From 8fca50cdf0af16ddbb2e8f4ffe351c2331212012 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 27 Jun 2024 15:14:43 +0200 Subject: [PATCH 15/22] Revert "Revert unused integration resource change" This reverts commit 40a2274ac4f39ace62521b3d21fdfe1733a7122f. --- app/Domain/Integrations/Integration.php | 20 +++++++++++++++++++ .../Integrations/Models/IntegrationModel.php | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/app/Domain/Integrations/Integration.php b/app/Domain/Integrations/Integration.php index 034a589bf..4b44cb5b4 100644 --- a/app/Domain/Integrations/Integration.php +++ b/app/Domain/Integrations/Integration.php @@ -31,6 +31,9 @@ final class Integration private ?Organization $organization; + /** @var array */ + private array $organizers; + /** @var array */ private array $uiTiDv1Consumers; @@ -57,6 +60,7 @@ public function __construct( $this->uiTiDv1Consumers = []; $this->auth0Clients = []; $this->keycloakClients = []; + $this->organizers = []; $this->organization = null; $this->keyVisibility = KeyVisibility::v2; $this->keyVisibilityUpgrade = null; @@ -122,6 +126,13 @@ public function withKeycloakClients(KeycloakClient ...$keycloakClients): self return $clone; } + public function withOrganizers(Organizer ...$organizers): self + { + $clone = clone $this; + $clone->organizers = $organizers; + return $clone; + } + public function withSubscription(Subscription $subscription): self { $clone = clone $this; @@ -166,6 +177,14 @@ public function organization(): ?Organization return $this->organization; } + /** + * @return array + */ + public function organizers(): array + { + return $this->organizers; + } + /** @return array */ public function uiTiDv1Consumers(): array { @@ -226,6 +245,7 @@ public function toArray(): array 'contacts' => $this->contacts, 'urls' => $this->urls, 'organization' => $this->organization, + 'organizers' => $this->organizers, 'authClients' => $this->auth0Clients, 'legacyAuthConsumers' => $this->uiTiDv1Consumers, 'keycloakClients' => $this->keycloakClients, diff --git a/app/Domain/Integrations/Models/IntegrationModel.php b/app/Domain/Integrations/Models/IntegrationModel.php index 1f6ff7c3a..f9305ab58 100644 --- a/app/Domain/Integrations/Models/IntegrationModel.php +++ b/app/Domain/Integrations/Models/IntegrationModel.php @@ -350,6 +350,11 @@ public function toDomain(): Integration ->get() ->map(fn (KeycloakClientModel $keycloakClientModel) => $keycloakClientModel->toDomain()) ->toArray() + )->withOrganizers( + ...$this->organizers() + ->get() + ->map(fn (OrganizerModel $organizerModel) => $organizerModel->toDomain()) + ->toArray() ); if ($this->keyVisibilityUpgrade) { From be688f1132d224812c7af2ca2eb0ebd35bdc61fd Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Mon, 1 Jul 2024 13:46:21 +0200 Subject: [PATCH 16/22] Add missing key for search-related tests --- .env.ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.ci b/.env.ci index 220adebbe..76464fc9f 100644 --- a/.env.ci +++ b/.env.ci @@ -195,4 +195,4 @@ KEYCLOAK_PROD_SCOPE_ENTRY_API_ID='d8a54568-26da-412b-a441-d5e2fad84478' #publiq- KEYCLOAK_PROD_SCOPE_UITPAS_ID='bcfb28cc-454f-488a-b080-6a29d9c0158e'#uitpas-scope SEARCH_BASE_URI=https://search-acc.uitdatabank.be/ -SEARCH_API_KEY= +SEARCH_API_KEY=deb306a6-6f46-4c98-89ce-b03ec4fd11e2 From b4358d790c0a62303c57bd13ba772c09600cb92e Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 2 Jul 2024 12:37:03 +0200 Subject: [PATCH 17/22] Fixed integrations listing extra organizers when none are linked --- app/Search/Sapi3/Sapi3SearchService.php | 4 ++++ .../ts/Components/Integrations/Detail/OrganizersInfo.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Search/Sapi3/Sapi3SearchService.php b/app/Search/Sapi3/Sapi3SearchService.php index 520098750..d2e60497f 100644 --- a/app/Search/Sapi3/Sapi3SearchService.php +++ b/app/Search/Sapi3/Sapi3SearchService.php @@ -31,6 +31,10 @@ public function findUiTPASOrganizers(string ...$ids): PagedCollection { $searchQuery = new SearchQuery(); $searchQuery->setEmbed(true); + if (empty($ids)) { + return new PagedCollection(); + } + foreach ($ids as $id) { $searchQuery->addParameter(new Id($id)); } diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index 4d624b1d5..2cc0f816d 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -20,7 +20,7 @@ const OrganizersSection = ({ sectionName: Organizer["status"]; }) => { const { t, i18n } = useTranslation(); - if (!organizers.length) { + if (!organizers?.length) { return null; } From e00376a39d5bdc00b5f1d98b2922098e232b7e4e Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Wed, 3 Jul 2024 15:24:04 +0200 Subject: [PATCH 18/22] Make Integrations index the default Nova admin page --- app/Providers/NovaServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index a82e8b80b..53b742cf2 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -5,6 +5,7 @@ namespace App\Providers; use App\Nova\Dashboards\Main; +use App\Nova\Resources\Integration; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Schema; use Laravel\Nova\Dashboard; @@ -53,5 +54,6 @@ protected function dashboards(): array public function register(): void { + Nova::initialPath('/resources/' . Integration::uriKey()); } } From 302735eb899754e8ae98e03f615cfbdb2cbcf0fa Mon Sep 17 00:00:00 2001 From: JonasVHG <4658984+JonasVHG@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:54:52 +0200 Subject: [PATCH 19/22] Check if both auth0 & keycloak are enabled. --- app/Auth0/Auth0ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Auth0/Auth0ServiceProvider.php b/app/Auth0/Auth0ServiceProvider.php index e82458486..cf76e5019 100644 --- a/app/Auth0/Auth0ServiceProvider.php +++ b/app/Auth0/Auth0ServiceProvider.php @@ -93,7 +93,7 @@ public function register(): void ); }); - if (config(KeycloakConfig::KEYCLOAK_CREATION_ENABLED)) { + if (config(KeycloakConfig::KEYCLOAK_CREATION_ENABLED) || config('auth0.enabled')) { // By default, the Auth0 integration is enabled. For testing purposes this can be disabled inside the .env file. // May always be registered even if there are no configured tenants, because in that case the cluster SDK will From 83ea2d90724e6a395d13ca552b934b97f43680a8 Mon Sep 17 00:00:00 2001 From: Koen Eelen Date: Thu, 4 Jul 2024 13:21:28 +0200 Subject: [PATCH 20/22] Remove keycloak flag for auth0 creation check, it has nothing to do with it --- app/Auth0/Auth0ServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Auth0/Auth0ServiceProvider.php b/app/Auth0/Auth0ServiceProvider.php index cf76e5019..f0a28b91d 100644 --- a/app/Auth0/Auth0ServiceProvider.php +++ b/app/Auth0/Auth0ServiceProvider.php @@ -93,7 +93,7 @@ public function register(): void ); }); - if (config(KeycloakConfig::KEYCLOAK_CREATION_ENABLED) || config('auth0.enabled')) { + if (config('auth0.enabled')) { // By default, the Auth0 integration is enabled. For testing purposes this can be disabled inside the .env file. // May always be registered even if there are no configured tenants, because in that case the cluster SDK will From e38c8d2a89837c7a34b728b861e0848d1ddc9185 Mon Sep 17 00:00:00 2001 From: Koen Eelen Date: Thu, 4 Jul 2024 13:24:52 +0200 Subject: [PATCH 21/22] remove unused import --- app/Auth0/Auth0ServiceProvider.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Auth0/Auth0ServiceProvider.php b/app/Auth0/Auth0ServiceProvider.php index f0a28b91d..30432294d 100644 --- a/app/Auth0/Auth0ServiceProvider.php +++ b/app/Auth0/Auth0ServiceProvider.php @@ -4,12 +4,12 @@ namespace App\Auth0; -use App\Auth0\Jobs\UnblockClient; -use App\Auth0\Jobs\UnblockClientHandler; use App\Auth0\Jobs\BlockClient; use App\Auth0\Jobs\BlockClientHandler; use App\Auth0\Jobs\CreateMissingClients; use App\Auth0\Jobs\CreateMissingClientsHandler; +use App\Auth0\Jobs\UnblockClient; +use App\Auth0\Jobs\UnblockClientHandler; use App\Auth0\Listeners\BlockClients; use App\Auth0\Listeners\CreateClients; use App\Auth0\Listeners\UnblockClients; @@ -26,7 +26,6 @@ use App\Domain\Integrations\Events\IntegrationUrlCreated; use App\Domain\Integrations\Events\IntegrationUrlDeleted; use App\Domain\Integrations\Events\IntegrationUrlUpdated; -use App\Keycloak\KeycloakConfig; use Auth0\SDK\Configuration\SdkConfiguration; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Event; @@ -56,15 +55,14 @@ public function register(): void // Filter out tenants with missing config (consider them disabled) $tenantsConfig = array_filter( config('auth0.tenants'), - static fn (array $tenantConfig) => - $tenantConfig['domain'] !== '' && + static fn (array $tenantConfig) => $tenantConfig['domain'] !== '' && $tenantConfig['clientId'] !== '' && $tenantConfig['clientSecret'] !== '' ); // Create Auth0Tenant objects based on the tenants config keys $tenants = array_map( - static fn (string|int $tenant) => Auth0Tenant::from((string) $tenant), + static fn (string|int $tenant) => Auth0Tenant::from((string)$tenant), array_keys($tenantsConfig) ); From 60df9df99385c50de0a9ff3ca33509eb9547e5a6 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 4 Jul 2024 13:50:40 +0200 Subject: [PATCH 22/22] Update CopyText usage --- resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx index 2cc0f816d..912c028a7 100644 --- a/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx +++ b/resources/ts/Components/Integrations/Detail/OrganizersInfo.tsx @@ -34,7 +34,7 @@ const OrganizersSection = ({

{organizer.name[i18n.language]}

- {organizer.id} +
{sectionName === "Live" && (