Skip to content

Commit

Permalink
Creating a service no longer generates a teamname urn
Browse files Browse the repository at this point in the history
Prior to this change, a teamname urn would be created by sp-dashboard.
This feature has been delegated to Invite.
This change removes the code needed to create a new urn.

See #1167
  • Loading branch information
johanib committed Nov 7, 2024
1 parent 9b26483 commit 46fae6a
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 290 deletions.
1 change: 0 additions & 1 deletion assets/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import './type_definitions.ts';
import './components/addFlashMessage.ts';
import './components/add_service.ts';
import './components/change_member_role.ts';
import './components/connection_request_widget.ts';
import './components/delete_member.ts';
Expand Down
29 changes: 0 additions & 29 deletions assets/js/components/add_service.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ class CreateServiceCommand implements Command
#[Assert\Uuid(strict: false)]
private string $manageId;

/**
* @var string
*/
#[SpDashboardAssert\UniqueTeamName()]
#[Assert\NotBlank]
private $teamName;

/**
* @var string
*/
Expand Down Expand Up @@ -99,14 +92,6 @@ public function setGuid($guid): void
$this->guid = $guid;
}

/**
* @param string $teamName
*/
public function setTeamName($teamName): void
{
$this->teamName = $teamName;
}

/**
* @param string $name
*/
Expand Down Expand Up @@ -166,14 +151,6 @@ public function getManageId(): string
return $this->manageId;
}

/**
* @return string
*/
public function getTeamName()
{
return $this->teamName;
}

/**
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function __construct(
private string $guid,
#[Assert\NotBlank]
private string $name,
#[SpDashboardAssert\ExistingTeamName]
#[SpDashboardAssert\UrnFormattedTeamName]
#[Assert\NotBlank]
private string $teamName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ public function __construct(
private readonly ServiceRepository $serviceRepository,
private readonly InviteRepository $inviteRepository,
private readonly TranslatorInterface $translator,
private readonly string $prefixPart1,
private readonly string $prefixPart2,
private readonly string $landingUrl,
) {
}

public function handle(CreateServiceCommand $command): void
{
$serviceName = $command->getName();
$teamName = strtolower($command->getTeamName());
$fullTeamName = $this->prefixPart1 . $this->prefixPart2 . $teamName;
$roleDescription = $this->translator->trans(
'invite.role_create.description',
[
Expand All @@ -55,7 +51,6 @@ public function handle(CreateServiceCommand $command): void
$service = new Service();
$service->setName($serviceName);
$service->setGuid($command->getGuid());
$service->setTeamName($fullTeamName);
$service->setProductionEntitiesEnabled($command->isProductionEntitiesEnabled());
$service->setPrivacyQuestionsEnabled($command->isPrivacyQuestionsEnabled());
$service->setClientCredentialClientsEnabled($command->isClientCredentialClientsEnabled());
Expand All @@ -66,6 +61,8 @@ public function handle(CreateServiceCommand $command): void
$service->setInstitutionId($command->getInstitutionId());
$service->setOrganizationNameEn($command->getOrganizationNameEn());
$service->setOrganizationNameNl($command->getOrganizationNameNl());

// If the service (team name) already exists in the sp-dashboard db, do not try to create it in Invite.
$this->serviceRepository->isUnique($service);

$roleName = sprintf('%s %s', $serviceName, $command->getOrganizationNameEn());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function handle(EditServiceCommand $command): void
$service->setInstitutionId($command->getInstitutionId());
$service->setOrganizationNameEn($command->getOrganizationNameEn());
$service->setOrganizationNameNl($command->getOrganizationNameNl());
$service->setTeamName($command->getTeamName());
$service->updateTeamName($command->getTeamName());

$this->serviceRepository->isUnique($service);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ public function setPrivacyQuestionsEnabled(bool $privacyQuestionsEnabled): void
$this->privacyQuestionsEnabled = $privacyQuestionsEnabled;
}

/**
* @param string $teamName
*/
public function setTeamName($teamName): void
public function updateTeamName(string $teamName): void
{
$this->teamName = $teamName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace Surfnet\ServiceProviderDashboard\Domain\Repository;

use Surfnet\ServiceProviderDashboard\Application\Exception\InvalidArgumentException;
use Surfnet\ServiceProviderDashboard\Domain\Entity\Service;

interface ServiceRepository
Expand All @@ -26,6 +27,8 @@ public function save(Service $service);

/**
* Is the proposed service entity unique? The id of the service is not taken into account in this test.
*
* @throws InvalidArgumentException
*/
public function isUnique(Service $service): bool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function createService(string $name, string $teamName): Service
{
$service = new Service();
$service->setName($name);
$service->setTeamName($teamName);
$service->updateTeamName($teamName);
$service->setGuid(Uuid::v4());
$service->setInstitutionId(Uuid::v4());
$service->setGuid(Uuid::v4());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => true,
]
)
->add(
'teamName',
null,
[
'label' => 'Team identifier',
'attr' => [
'class' => 'teamName',
'readonly' => true,
],
]
)
)
->add('save', SubmitType::class, ['attr' => ['class' => 'button']]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function save(Service $service): void
$this->getEntityManager()->flush($service);
}

/**
* @throws InvalidArgumentException
*/
public function isUnique(Service $service): bool
{
$this->isTeamNameUnique($service->getTeamName(), $service->getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ services:
tags:
- { name: tactician.handler, command: Surfnet\ServiceProviderDashboard\Application\Command\Service\CreateServiceCommand }
arguments:
$prefixPart1: '%env(team_prefix_default_stem_name)%'
$prefixPart2: '%env(team_prefix_group_name_context)%'
$inviteRepository: '@Surfnet\ServiceProviderDashboard\Infrastructure\Invite\InviteRepository'
$landingUrl: '%env(invite_landing_url)%'

Expand Down Expand Up @@ -286,21 +284,6 @@ services:
tags:
- { name: validator.constraint_validator, alias: unique_entity_id }

Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Validator\Constraints\UniqueTeamNameValidator:
arguments:
- '@Surfnet\ServiceProviderDashboard\Infrastructure\Teams\Client\QueryClient'
- '%env(team_prefix_group_name_context)%'
tags:
- { name: validator.constraint_validator, alias: unique_team_name }

Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Validator\Constraints\ExistingTeamNameValidator:
arguments:
- '@Surfnet\ServiceProviderDashboard\Infrastructure\Teams\Client\QueryClient'
- '%env(team_prefix_default_stem_name)%'
- '%env(team_prefix_group_name_context)%'
tags:
- { name: validator.constraint_validator, alias: existing_team_name }

Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Validator\Constraints\UrnFormattedTeamNameValidator:
arguments:
- '%env(team_prefix_default_stem_name)%'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ validator.entity_id.invalid_url: 'Invalid metadataUrl.'
validator.entity_id.invalid_entity_id: 'Invalid entityId.'
validator.entity_id.registry_failure: 'Failed checking registry.'
validator.entity_id.already_exists: 'Entity has already been registered.'
validator.team_name.registry_failure: 'Could not check registry for team name.'
validator.team_name.already_exists: 'Team name has already been registered.'
validator.team_name.does_not_exist: 'Team name does not exist. Please use an existing team name.'
validator.team_name.not_in_urn_format: 'Team name must be in the correct urn-format.'
validator.contact.not_valid: 'The contact information is not valid. Please fill the first name, last name, and email fields.'
validator.client_id.invalid_url: 'Invalid clientId.'
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 46fae6a

Please sign in to comment.