Skip to content

Commit 9890ab7

Browse files
authored
Merge pull request #5132 from neos/feature/4255-new-workspace-management-ui
FEATURE: New workspace module (fusion & htmx) v1
2 parents f20b28c + f3fe1d0 commit 9890ab7

File tree

100 files changed

+3898
-1232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3898
-1232
lines changed

Neos.ContentRepository.Core/Classes/Feature/SubtreeTagging/Dto/SubtreeTags.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
*/
2828
private array $tags;
2929

30-
3130
private function __construct(SubtreeTag ...$tags)
3231
{
3332
$tagsByValue = [];
@@ -83,6 +82,11 @@ public function intersection(self $other): self
8382
return self::fromArray(array_intersect_key($this->tags, $other->tags));
8483
}
8584

85+
public function difference(self $other): self
86+
{
87+
return self::fromArray(array_diff_key($this->tags, $other->tags));
88+
}
89+
8690
public function merge(self $other): self
8791
{
8892
return self::fromArray(array_merge($this->tags, $other->tags));
@@ -106,6 +110,11 @@ public function toStringArray(): array
106110
return $this->map(static fn (SubtreeTag $tag) => $tag->value);
107111
}
108112

113+
public function equals(SubtreeTags $other): bool
114+
{
115+
return count($this->tags) === count($other->tags) && array_diff_key($this->tags, $other->tags) === [];
116+
}
117+
109118
public function getIterator(): \Traversable
110119
{
111120
yield from array_values($this->tags);

Neos.ContentRepository.Core/Classes/Projection/ContentGraph/NodeTags.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ public function toStringArray(): array
117117
return $this->map(static fn (SubtreeTag $tag) => $tag->value);
118118
}
119119

120+
public function equals(NodeTags $other): bool
121+
{
122+
return $this->tags->equals($other->tags)
123+
&& $this->inheritedTags->equals($other->inheritedTags);
124+
}
125+
120126
public function getIterator(): Traversable
121127
{
122128
foreach ($this->tags as $tag) {

Neos.ContentRepository.Core/Tests/Unit/Feature/SubtreeTagging/Dto/SubtreeTagsTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,44 @@ public function intersectionTests(array $tags1, array $tags2, array $expectedRes
132132
self::assertSame($expectedResult, SubtreeTags::fromStrings(...$tags1)->intersection(SubtreeTags::fromStrings(...$tags2))->toStringArray());
133133
}
134134

135+
public static function differenceDataProvider(): iterable
136+
{
137+
yield 'empty' => ['tags1' => [], 'tags2' => [], 'expectedResult' => []];
138+
yield 'one empty' => ['tags1' => [], 'tags2' => ['foo'], 'expectedResult' => []];
139+
yield 'two empty' => ['tags1' => ['foo'], 'tags2' => [], 'expectedResult' => ['foo']];
140+
yield 'no intersection' => ['tags1' => ['foo', 'bar'], 'tags2' => ['baz', 'foos'], 'expectedResult' => ['foo', 'bar']];
141+
yield 'with intersection' => ['tags1' => ['foo', 'bar', 'baz'], 'tags2' => ['baz', 'bars', 'foo'], 'expectedResult' => ['bar']];
142+
yield 'with intersection reversed' => ['tags1' => ['baz', 'bars', 'foo'], 'tags2' => ['foo', 'bar', 'baz'], 'expectedResult' => ['bars']];
143+
}
144+
145+
/**
146+
* @test
147+
* @dataProvider differenceDataProvider
148+
*/
149+
public function differenceTests(array $tags1, array $tags2, array $expectedResult): void
150+
{
151+
self::assertSame($expectedResult, SubtreeTags::fromStrings(...$tags1)->difference(SubtreeTags::fromStrings(...$tags2))->toStringArray());
152+
}
153+
154+
155+
public static function equalsDataProvider(): iterable
156+
{
157+
yield 'empty' => ['tags1' => [], 'tags2' => [], 'expectedResult' => true];
158+
yield 'one empty' => ['tags1' => [], 'tags2' => ['foo'], 'expectedResult' => false];
159+
yield 'other empty' => ['tags1' => ['foo'], 'tags2' => [], 'expectedResult' => false];
160+
yield 'equals' => ['tags1' => ['foo', 'bar'], 'tags2' => ['foo', 'bar'], 'expectedResult' => true];
161+
yield 'equals reversed' => ['tags1' => ['foo', 'bar'], 'tags2' => ['bar', 'foo'], 'expectedResult' => true];
162+
}
163+
164+
/**
165+
* @test
166+
* @dataProvider equalsDataProvider
167+
*/
168+
public function equalsTests(array $tags1, array $tags2, bool $expectedResult): void
169+
{
170+
self::assertSame($expectedResult, SubtreeTags::fromStrings(...$tags1)->equals(SubtreeTags::fromStrings(...$tags2)));
171+
}
172+
135173
public static function mergeDataProvider(): iterable
136174
{
137175
yield 'empty' => ['tags1' => [], 'tags2' => [], 'expectedResult' => []];

Neos.Neos/Classes/Domain/Model/WorkspaceRoleAssignments.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ public static function createForSharedWorkspace(UserId $userId): self
8282
);
8383
}
8484

85+
/**
86+
* Default role assignment to be specified at creation via {@see WorkspaceService::createSharedWorkspace()}
87+
*
88+
* The specified user is manager
89+
*/
90+
public static function createForPrivateWorkspace(UserId $userId): self
91+
{
92+
return new self(
93+
WorkspaceRoleAssignment::createForUser(
94+
$userId,
95+
WorkspaceRole::MANAGER,
96+
)
97+
);
98+
}
99+
85100
public function isEmpty(): bool
86101
{
87102
return $this->assignments === [];

0 commit comments

Comments
 (0)