Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doctrine proxy and UI for organization members #130

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
excludes_analyse:
- src/Entity/Organization.php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with this, but I had to add default null because of doctrine/common#886, so I exclude this file from analysis (I only hope temporarily). Another option is downgrade php ...

ignoreErrors:
-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function overview(Organization $organization): Response
public function packages(Organization $organization, Request $request): Response
{
$count = $this->packageQuery->count($organization->id());
if ($count === 0) {
if ($count === 0 && $organization->isOwner($this->getUser()->id()->toString())) {
return $this->redirectToRoute('organization_package_new', ['organization' => $organization->alias()]);
}

Expand Down
16 changes: 8 additions & 8 deletions src/Entity/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,46 @@ class Organization
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
*/
private UuidInterface $id;
private ?UuidInterface $id = null;

/**
* @ORM\Column(type="datetime_immutable")
*/
private \DateTimeImmutable $createdAt;
private ?\DateTimeImmutable $createdAt = null;

/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
private ?string $name = null;

/**
* @ORM\Column(type="string", unique=true, length=255)
*/
private string $alias;
private ?string $alias = null;

/**
* @var Collection<int,Package>|Package[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Package", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $packages;
private ?Collection $packages = null;

/**
* @var Collection<int,Token>|Token[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Token", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $tokens;
private ?Collection $tokens = null;

/**
* @var Collection<int,Invitation>|Invitation[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Invitation", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $invitations;
private ?Collection $invitations = null;

/**
* @var Collection<int,Member>|Member[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Member", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $members;
private ?Collection $members = null;

public function __construct(UuidInterface $id, User $owner, string $name, string $alias)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Form/Type/Organization/InviteMemberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'constraints' => [
new NotNull(),
],
'attr' => [
'class' => 'form-control selectpicker',
'data-style' => 'btn-secondary',
],
])
->add('invite', SubmitType::class)
;
Expand Down
6 changes: 3 additions & 3 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
</li>
<li class="nav-item">
<a class="nav-link {{ current_route == 'organization_members' ? 'active' : '' }}" href="{{ path('organization_members', {"organization":organization.alias}) }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
<span class="nav-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
</span>
<span class="d-none d-sm-block">Members</span>
</a>
</li>
Expand Down
4 changes: 4 additions & 0 deletions templates/organization/packages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
</span>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">no packages added</td>
</tr>
{% endfor %}
</tbody>
</table>
Expand Down