@@ -1,10 +1,19 @@
|
||||
<?php
|
||||
|
||||
use App\FolderRole;
|
||||
use App\FolderVisibility;
|
||||
use App\Mail\InvitationMail;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Todo;
|
||||
use App\Models\User;
|
||||
use App\TodoStatus;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
@@ -40,6 +49,18 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public string $colorDraft = '';
|
||||
|
||||
#[Locked]
|
||||
public ?int $sharingFolderId = null;
|
||||
|
||||
public string $inviteEmail = '';
|
||||
|
||||
public string $inviteRole = 'viewer';
|
||||
|
||||
public string $shareVisibility = 'private';
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $collaboratorRoles = [];
|
||||
|
||||
public bool $showTodoForm = false;
|
||||
|
||||
#[Locked]
|
||||
@@ -55,8 +76,15 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function createTopLevelFolder(): void
|
||||
{
|
||||
$organization = auth()->user()->currentOrganization()->first();
|
||||
|
||||
abort_unless(
|
||||
$organization !== null && auth()->user()->can('create', [Folder::class, $organization]),
|
||||
403
|
||||
);
|
||||
|
||||
$validated = $this->validate([
|
||||
'newFolderName' => $this->folderNameRules(parentId: null),
|
||||
'newFolderName' => $this->folderNameRules($organization->id, parentId: null),
|
||||
'newFolderColor' => $this->folderColorRules(),
|
||||
]);
|
||||
|
||||
@@ -72,7 +100,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function startChildCreate(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
$this->folderForAction($folderId, 'createChild');
|
||||
|
||||
$this->creatingChildOf = $folderId;
|
||||
$this->reset('newChildName', 'newChildColor');
|
||||
@@ -86,18 +114,19 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function createChildFolder(): void
|
||||
{
|
||||
$this->folderForUser($this->creatingChildOf);
|
||||
$parent = $this->folderForAction($this->creatingChildOf ?? 0, 'createChild');
|
||||
|
||||
$validated = $this->validate([
|
||||
'newChildName' => $this->folderNameRules(parentId: $this->creatingChildOf),
|
||||
'newChildName' => $this->folderNameRules($parent->organization_id, parentId: $parent->id),
|
||||
'newChildColor' => $this->folderColorRules(),
|
||||
]);
|
||||
|
||||
Folder::create([
|
||||
'user_id' => auth()->id(),
|
||||
'organization_id' => $parent->organization_id,
|
||||
'name' => $validated['newChildName'],
|
||||
'color' => filled($validated['newChildColor']) ? $validated['newChildColor'] : null,
|
||||
'parent_id' => $this->creatingChildOf,
|
||||
'parent_id' => $parent->id,
|
||||
]);
|
||||
|
||||
$this->reset('creatingChildOf', 'newChildName', 'newChildColor');
|
||||
@@ -105,7 +134,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function startRename(int $folderId): void
|
||||
{
|
||||
$folder = $this->folderForUser($folderId);
|
||||
$folder = $this->folderForAction($folderId, 'update');
|
||||
|
||||
$this->renamingFolderId = $folder->id;
|
||||
$this->renameName = $folder->name;
|
||||
@@ -119,10 +148,10 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function saveRename(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->renamingFolderId);
|
||||
$folder = $this->folderForAction($this->renamingFolderId ?? 0, 'update');
|
||||
|
||||
$validated = $this->validate([
|
||||
'renameName' => $this->folderNameRules(parentId: $folder->parent_id, ignoreId: $folder->id),
|
||||
'renameName' => $this->folderNameRules($folder->organization_id, parentId: $folder->parent_id, ignoreId: $folder->id),
|
||||
]);
|
||||
|
||||
$folder->update(['name' => $validated['renameName']]);
|
||||
@@ -132,7 +161,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function confirmFolderDelete(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
$this->folderForAction($folderId, 'delete');
|
||||
|
||||
$this->confirmingFolderDelete = $folderId;
|
||||
$this->modal('confirm-folder-delete')->show();
|
||||
@@ -140,7 +169,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function deleteFolder(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->confirmingFolderDelete);
|
||||
$folder = $this->folderForAction($this->confirmingFolderDelete ?? 0, 'delete');
|
||||
|
||||
if ($this->expandedFolderId === $folder->id) {
|
||||
$this->expandedFolderId = null;
|
||||
@@ -154,14 +183,14 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function toggleExpandFolder(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
$this->visibleFolder($folderId);
|
||||
|
||||
$this->expandedFolderId = $this->expandedFolderId === $folderId ? null : $folderId;
|
||||
}
|
||||
|
||||
public function startColorEdit(int $folderId): void
|
||||
{
|
||||
$folder = $this->folderForUser($folderId);
|
||||
$folder = $this->folderForAction($folderId, 'update');
|
||||
|
||||
$this->colorEditingFolderId = $folder->id;
|
||||
$this->colorDraft = $folder->color ?? '';
|
||||
@@ -171,7 +200,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function saveFolderColor(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->colorEditingFolderId ?? 0);
|
||||
$folder = $this->folderForAction($this->colorEditingFolderId ?? 0, 'update');
|
||||
|
||||
$validated = $this->validate([
|
||||
'colorDraft' => $this->folderColorRules(),
|
||||
@@ -185,21 +214,179 @@ new #[Title('Folders')] class extends Component
|
||||
$this->modal('folder-color')->close();
|
||||
}
|
||||
|
||||
public function startShare(int $folderId): void
|
||||
{
|
||||
$folder = $this->folderForAction($folderId, 'manageShares');
|
||||
|
||||
$this->sharingFolderId = $folder->id;
|
||||
$this->shareVisibility = $folder->visibility->value;
|
||||
$this->collaboratorRoles = $folder->shares()
|
||||
->get()
|
||||
->mapWithKeys(fn (User $user): array => [$user->id => (string) $user->pivot->role])
|
||||
->all();
|
||||
$this->reset('inviteEmail', 'inviteRole');
|
||||
$this->resetErrorBag('inviteEmail', 'inviteRole');
|
||||
$this->modal('folder-share')->show();
|
||||
}
|
||||
|
||||
public function closeShare(): void
|
||||
{
|
||||
$this->reset('sharingFolderId', 'inviteEmail', 'inviteRole', 'collaboratorRoles');
|
||||
$this->modal('folder-share')->close();
|
||||
}
|
||||
|
||||
public function updatedCollaboratorRoles(string $value, string $key): void
|
||||
{
|
||||
$this->updateCollaboratorRole((int) $key, $value);
|
||||
}
|
||||
|
||||
public function updatedShareVisibility(string $value): void
|
||||
{
|
||||
$this->updateVisibility($value);
|
||||
}
|
||||
|
||||
public function updateVisibility(string $visibility): void
|
||||
{
|
||||
$folder = $this->folderForAction($this->sharingFolderId ?? 0, 'manageShares');
|
||||
|
||||
$validated = validator(
|
||||
['shareVisibility' => $visibility],
|
||||
['shareVisibility' => ['required', Rule::enum(FolderVisibility::class)]],
|
||||
)->validate();
|
||||
|
||||
// Personal workspaces hold a single member, so there is nothing to
|
||||
// share a folder with. Only ever move such a folder back to private.
|
||||
if ($validated['shareVisibility'] === FolderVisibility::Workspace->value
|
||||
&& $folder->organization?->isPersonal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$folder->update(['visibility' => $validated['shareVisibility']]);
|
||||
|
||||
unset($this->sharingFolder);
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Folder sharing updated.'));
|
||||
}
|
||||
|
||||
public function inviteCollaborator(): void
|
||||
{
|
||||
$folder = $this->folderForAction($this->sharingFolderId ?? 0, 'manageShares');
|
||||
|
||||
$validated = $this->validate([
|
||||
'inviteEmail' => ['required', 'string', 'email', 'max:255'],
|
||||
'inviteRole' => ['required', Rule::enum(FolderRole::class)],
|
||||
]);
|
||||
|
||||
$email = Str::lower($validated['inviteEmail']);
|
||||
|
||||
if ($folder->shares()->where('users.email', $email)->exists()) {
|
||||
$this->addError('inviteEmail', __('That person already has access to this folder.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Str::lower((string) $folder->user?->email) === $email) {
|
||||
$this->addError('inviteEmail', __('That person already owns this folder.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$invitation = Invitation::updateOrCreate(
|
||||
[
|
||||
'inviteable_type' => Folder::class,
|
||||
'inviteable_id' => $folder->id,
|
||||
'email' => $email,
|
||||
],
|
||||
[
|
||||
'inviter_id' => auth()->id(),
|
||||
'role' => $validated['inviteRole'],
|
||||
'token' => Str::random(64),
|
||||
'expires_at' => now()->addDays(Invitation::EXPIRY_DAYS),
|
||||
'accepted_at' => null,
|
||||
'accepted_by_id' => null,
|
||||
],
|
||||
);
|
||||
|
||||
Mail::to($email)->send(new InvitationMail($invitation));
|
||||
|
||||
$this->reset('inviteEmail', 'inviteRole');
|
||||
unset($this->sharingInvitations);
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Invitation sent to :email.', ['email' => $email]));
|
||||
}
|
||||
|
||||
public function updateCollaboratorRole(int $userId, string $role): void
|
||||
{
|
||||
$folder = $this->folderForAction($this->sharingFolderId ?? 0, 'manageShares');
|
||||
|
||||
if ($userId === $folder->user_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$validated = validator(
|
||||
['role' => $role],
|
||||
['role' => ['required', Rule::enum(FolderRole::class)]],
|
||||
)->validate();
|
||||
|
||||
$folder->shares()->updateExistingPivot($userId, ['role' => $validated['role']]);
|
||||
|
||||
unset($this->sharingCollaborators);
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Collaborator role updated.'));
|
||||
}
|
||||
|
||||
public function removeCollaborator(int $userId): void
|
||||
{
|
||||
$folder = $this->folderForAction($this->sharingFolderId ?? 0, 'manageShares');
|
||||
|
||||
if ($userId === $folder->user_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$folder->shares()->detach($userId);
|
||||
|
||||
unset($this->sharingCollaborators);
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Collaborator removed.'));
|
||||
}
|
||||
|
||||
public function revokeFolderInvitation(int $invitationId): void
|
||||
{
|
||||
$folder = $this->folderForAction($this->sharingFolderId ?? 0, 'manageShares');
|
||||
|
||||
$invitation = $folder->invitations()->whereKey($invitationId)->firstOrFail();
|
||||
|
||||
abort_unless(auth()->user()->can('delete', $invitation), 403);
|
||||
|
||||
$invitation->delete();
|
||||
|
||||
unset($this->sharingInvitations);
|
||||
|
||||
Flux::toast(variant: 'success', text: __('Invitation revoked.'));
|
||||
}
|
||||
|
||||
public function moveTodoToFolder(int $todoId, int $folderId): void
|
||||
{
|
||||
$todo = Todo::query()->forUser(auth()->id())->findOrFail($todoId);
|
||||
$todo = Todo::query()
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->with('folder')
|
||||
->findOrFail($todoId);
|
||||
|
||||
$folder = Folder::query()->forUser(auth()->id())->findOrFail($folderId);
|
||||
abort_unless(auth()->user()->can('update', $todo), 403);
|
||||
|
||||
$folder = $this->visibleFolder($folderId);
|
||||
|
||||
abort_unless(auth()->user()->can('create', [Todo::class, $folder]), 403);
|
||||
|
||||
$todo->update(['folder_id' => $folder->id]);
|
||||
}
|
||||
|
||||
public function moveFolderToTopLevel(int $folderId): void
|
||||
{
|
||||
$folder = $this->folderForUser($folderId);
|
||||
$folder = $this->folderForAction($folderId, 'update');
|
||||
|
||||
$hasSiblingConflict = Folder::query()
|
||||
->forUser(auth()->id())
|
||||
->where('organization_id', $folder->organization_id)
|
||||
->whereNull('parent_id')
|
||||
->whereKeyNot($folder->id)
|
||||
->where('name', $folder->name)
|
||||
@@ -214,8 +401,8 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function moveFolderToFolder(int $folderId, int $targetFolderId): void
|
||||
{
|
||||
$folder = $this->folderForUser($folderId);
|
||||
$target = $this->folderForUser($targetFolderId);
|
||||
$folder = $this->folderForAction($folderId, 'update');
|
||||
$target = $this->folderForAction($targetFolderId, 'createChild');
|
||||
|
||||
if ($folder->id === $target->id || $this->isDescendantOf($target, $folder)) {
|
||||
return;
|
||||
@@ -251,7 +438,7 @@ new #[Title('Folders')] class extends Component
|
||||
public function todosForFolder(int $folderId): Collection
|
||||
{
|
||||
return Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->where('folder_id', $folderId)
|
||||
->active()
|
||||
->priority()
|
||||
@@ -260,7 +447,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function startTodoCreate(int $folderId): void
|
||||
{
|
||||
$this->folderForUser($folderId);
|
||||
$this->folderForTodoCreate($folderId);
|
||||
|
||||
$this->todoFolderId = $folderId;
|
||||
$this->reset('todoDescription', 'todoStatus', 'todoDueDate', 'todoNotes');
|
||||
@@ -270,7 +457,7 @@ new #[Title('Folders')] class extends Component
|
||||
|
||||
public function saveFolderTodo(): void
|
||||
{
|
||||
$folder = $this->folderForUser($this->todoFolderId ?? 0);
|
||||
$folder = $this->folderForTodoCreate($this->todoFolderId ?? 0);
|
||||
|
||||
$validated = $this->validate([
|
||||
'todoDescription' => ['required', 'string', 'max:255'],
|
||||
@@ -286,7 +473,7 @@ new #[Title('Folders')] class extends Component
|
||||
'status' => TodoStatus::from($validated['todoStatus']),
|
||||
'due_date' => filled($validated['todoDueDate']) ? Carbon::parse($validated['todoDueDate']) : null,
|
||||
'notes' => filled($validated['todoNotes']) ? $validated['todoNotes'] : null,
|
||||
'position' => Todo::nextPositionFor(auth()->user()),
|
||||
'position' => Todo::nextPositionFor($folder),
|
||||
]);
|
||||
|
||||
$this->reset('showTodoForm', 'todoFolderId', 'todoDescription', 'todoStatus', 'todoDueDate', 'todoNotes');
|
||||
@@ -295,7 +482,7 @@ new #[Title('Folders')] class extends Component
|
||||
#[Computed]
|
||||
public function folderTree(): Collection
|
||||
{
|
||||
return Folder::treeForUser(auth()->id());
|
||||
return Folder::treeForVisibleTo(auth()->id(), $this->activeWorkspaceId());
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
@@ -305,7 +492,10 @@ new #[Title('Folders')] class extends Component
|
||||
return null;
|
||||
}
|
||||
|
||||
return Folder::query()->with('parent')->forUser(auth()->id())->find($this->todoFolderId);
|
||||
return Folder::query()
|
||||
->with('parent')
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->find($this->todoFolderId);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
@@ -324,12 +514,43 @@ new #[Title('Folders')] class extends Component
|
||||
public function openCounts(): Collection
|
||||
{
|
||||
return Todo::query()
|
||||
->forUser(auth()->id())
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->active()
|
||||
->pluck('folder_id')
|
||||
->countBy();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function sharingFolder(): ?Folder
|
||||
{
|
||||
if ($this->sharingFolderId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Folder::query()
|
||||
->with('organization')
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->find($this->sharingFolderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, User>
|
||||
*/
|
||||
#[Computed]
|
||||
public function sharingCollaborators(): Collection
|
||||
{
|
||||
return $this->sharingFolder?->shares()->orderBy('name')->get() ?? collect();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Invitation>
|
||||
*/
|
||||
#[Computed]
|
||||
public function sharingInvitations(): Collection
|
||||
{
|
||||
return $this->sharingFolder?->invitations()->pending()->orderBy('email')->get() ?? collect();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
@@ -341,7 +562,7 @@ new #[Title('Folders')] class extends Component
|
||||
/**
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
private function folderNameRules(?int $parentId = null, ?int $ignoreId = null): array
|
||||
private function folderNameRules(int $organizationId, ?int $parentId = null, ?int $ignoreId = null): array
|
||||
{
|
||||
return [
|
||||
'required',
|
||||
@@ -350,14 +571,39 @@ new #[Title('Folders')] class extends Component
|
||||
Rule::unique('folders', 'name')
|
||||
->ignore($ignoreId)
|
||||
->where(fn ($query) => $query
|
||||
->where('user_id', auth()->id())
|
||||
->where('organization_id', $organizationId)
|
||||
->where('parent_id', $parentId)),
|
||||
];
|
||||
}
|
||||
|
||||
private function folderForUser(int $folderId): Folder
|
||||
private function activeWorkspaceId(): int
|
||||
{
|
||||
return Folder::query()->forUser(auth()->id())->findOrFail($folderId);
|
||||
return (int) auth()->user()->current_organization_id;
|
||||
}
|
||||
|
||||
private function visibleFolder(int $folderId): Folder
|
||||
{
|
||||
return Folder::query()
|
||||
->visibleTo(auth()->id(), $this->activeWorkspaceId())
|
||||
->findOrFail($folderId);
|
||||
}
|
||||
|
||||
private function folderForAction(int $folderId, string $ability): Folder
|
||||
{
|
||||
$folder = $this->visibleFolder($folderId);
|
||||
|
||||
abort_unless(auth()->user()->can($ability, $folder), 403);
|
||||
|
||||
return $folder;
|
||||
}
|
||||
|
||||
private function folderForTodoCreate(int $folderId): Folder
|
||||
{
|
||||
$folder = $this->visibleFolder($folderId);
|
||||
|
||||
abort_unless(auth()->user()->can('create', [Todo::class, $folder]), 403);
|
||||
|
||||
return $folder;
|
||||
}
|
||||
}; ?>
|
||||
|
||||
@@ -465,22 +711,36 @@ new #[Title('Folders')] class extends Component
|
||||
</form>
|
||||
@else
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<div
|
||||
x-data="{ dragging: false }"
|
||||
draggable="true"
|
||||
class="inline-flex shrink-0 cursor-grab text-zinc-400 dark:text-zinc-500"
|
||||
:class="dragging && 'opacity-40'"
|
||||
@dragstart="dragging = true; window.__mtFolderDrag = { folderId: {{ $node['folder']->id }} }; $dispatch('folder-drag-start')"
|
||||
@dragend="dragging = false; window.__mtFolderDrag = null; $dispatch('folder-drag-end')"
|
||||
title="{{ __('Drag to move this folder') }}"
|
||||
data-test="drag-folder-{{ $node['folder']->id }}"
|
||||
>
|
||||
<flux:icon.chevrons-up-down variant="micro" />
|
||||
</div>
|
||||
@can('update', $node['folder'])
|
||||
<div
|
||||
x-data="{ dragging: false }"
|
||||
draggable="true"
|
||||
class="inline-flex shrink-0 cursor-grab text-zinc-400 dark:text-zinc-500"
|
||||
:class="dragging && 'opacity-40'"
|
||||
@dragstart="dragging = true; window.__mtFolderDrag = { folderId: {{ $node['folder']->id }} }; $dispatch('folder-drag-start')"
|
||||
@dragend="dragging = false; window.__mtFolderDrag = null; $dispatch('folder-drag-end')"
|
||||
title="{{ __('Drag to move this folder') }}"
|
||||
data-test="drag-folder-{{ $node['folder']->id }}"
|
||||
>
|
||||
<flux:icon.chevrons-up-down variant="micro" />
|
||||
</div>
|
||||
@endcan
|
||||
<x-folder-dot :color="$node['folder']->color" data-test="folder-dot-{{ $node['folder']->id }}" />
|
||||
<flux:heading size="sm" class="truncate" data-test="folder-name-{{ $node['folder']->id }}">
|
||||
{{ $node['folder']->name }}
|
||||
</flux:heading>
|
||||
<span
|
||||
class="truncate text-xs text-zinc-400 dark:text-zinc-500"
|
||||
title="{{ __('Workspace') }}"
|
||||
data-test="folder-workspace-{{ $node['folder']->id }}"
|
||||
>
|
||||
{{ $node['folder']->organization?->name }}
|
||||
</span>
|
||||
@if ($node['folder']->visibility === \App\FolderVisibility::Workspace || $node['folder']->shares_count > 0)
|
||||
<flux:badge size="sm" color="zinc" icon="users" data-test="folder-shared-{{ $node['folder']->id }}">
|
||||
{{ __('Shared') }}
|
||||
</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<flux:badge
|
||||
@@ -500,15 +760,28 @@ new #[Title('Folders')] class extends Component
|
||||
<flux:spacer />
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<flux:tooltip :content="__('Choose color')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="swatch"
|
||||
wire:click="startColorEdit({{ $node['folder']->id }})"
|
||||
data-test="color-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@can('manageShares', $node['folder'])
|
||||
<flux:tooltip :content="__('Share')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="user-plus"
|
||||
wire:click="startShare({{ $node['folder']->id }})"
|
||||
data-test="share-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@endcan
|
||||
@can('update', $node['folder'])
|
||||
<flux:tooltip :content="__('Choose color')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="swatch"
|
||||
wire:click="startColorEdit({{ $node['folder']->id }})"
|
||||
data-test="color-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@endcan
|
||||
<flux:tooltip :content="__('View todos')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
@@ -519,42 +792,48 @@ new #[Title('Folders')] class extends Component
|
||||
data-test="view-todos-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Add todo')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="document-plus"
|
||||
wire:click="startTodoCreate({{ $node['folder']->id }})"
|
||||
data-test="add-todo-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Add sub-folder')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="folder-plus"
|
||||
wire:click="startChildCreate({{ $node['folder']->id }})"
|
||||
data-test="add-child-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Rename')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="pencil-square"
|
||||
wire:click="startRename({{ $node['folder']->id }})"
|
||||
data-test="rename-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Delete')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="trash"
|
||||
wire:click="confirmFolderDelete({{ $node['folder']->id }})"
|
||||
data-test="delete-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@can('create', [App\Models\Todo::class, $node['folder']])
|
||||
<flux:tooltip :content="__('Add todo')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="document-plus"
|
||||
wire:click="startTodoCreate({{ $node['folder']->id }})"
|
||||
data-test="add-todo-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@endcan
|
||||
@can('createChild', $node['folder'])
|
||||
<flux:tooltip :content="__('Add sub-folder')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="folder-plus"
|
||||
wire:click="startChildCreate({{ $node['folder']->id }})"
|
||||
data-test="add-child-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@endcan
|
||||
@can('update', $node['folder'])
|
||||
<flux:tooltip :content="__('Rename')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="pencil-square"
|
||||
wire:click="startRename({{ $node['folder']->id }})"
|
||||
data-test="rename-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
<flux:tooltip :content="__('Delete')">
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="trash"
|
||||
wire:click="confirmFolderDelete({{ $node['folder']->id }})"
|
||||
data-test="delete-folder-{{ $node['folder']->id }}"
|
||||
/>
|
||||
</flux:tooltip>
|
||||
@endcan
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@@ -739,4 +1018,129 @@ new #[Title('Folders')] class extends Component
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
|
||||
<flux:modal name="folder-share" class="md:w-2xl">
|
||||
@if ($this->sharingFolder !== null)
|
||||
<div class="space-y-6" data-test="folder-share-panel">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Share folder') }}</flux:heading>
|
||||
<flux:text class="mt-2">
|
||||
{{ __('Manage who can access ":name" and what they can do.', ['name' => $this->sharingFolder->name]) }}
|
||||
</flux:text>
|
||||
</div>
|
||||
|
||||
@if ($this->sharingFolder->organization !== null && ! $this->sharingFolder->organization->isPersonal())
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Visibility') }}</flux:label>
|
||||
<flux:select wire:model.live="shareVisibility" data-test="visibility-select">
|
||||
@foreach (FolderVisibility::cases() as $visibility)
|
||||
<flux:select.option value="{{ $visibility->value }}">{{ $visibility->label() }}</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:error name="shareVisibility" />
|
||||
<flux:description>
|
||||
{{ __('Workspace folders are visible to every member of :name.', ['name' => $this->sharingFolder->organization->name]) }}
|
||||
</flux:description>
|
||||
</flux:field>
|
||||
@else
|
||||
<flux:callout icon="lock-closed" data-test="personal-share-notice">
|
||||
{{ __('This folder is only visible to you. Personal workspaces cannot hold other members.') }}
|
||||
</flux:callout>
|
||||
@endif
|
||||
|
||||
<div class="space-y-3">
|
||||
<flux:heading size="sm">{{ __('Collaborators') }}</flux:heading>
|
||||
|
||||
<div class="flex items-center justify-between gap-3" data-test="folder-owner-row">
|
||||
<flux:text>{{ $this->sharingFolder->user?->name }}</flux:text>
|
||||
<flux:badge size="sm" color="blue">{{ __('Owner') }}</flux:badge>
|
||||
</div>
|
||||
|
||||
@forelse ($this->sharingCollaborators as $collaborator)
|
||||
<div class="flex flex-wrap items-center justify-between gap-3" data-test="collaborator-row-{{ $collaborator->id }}">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<flux:text class="truncate">{{ $collaborator->name }}</flux:text>
|
||||
<flux:text size="sm" class="truncate text-zinc-500 dark:text-zinc-400">{{ $collaborator->email }}</flux:text>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<flux:select
|
||||
size="sm"
|
||||
wire:model.live="collaboratorRoles.{{ $collaborator->id }}"
|
||||
data-test="collaborator-role-{{ $collaborator->id }}"
|
||||
>
|
||||
@foreach (FolderRole::assignable() as $role)
|
||||
<flux:select.option value="{{ $role->value }}">{{ $role->label() }}</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="trash"
|
||||
wire:click="removeCollaborator({{ $collaborator->id }})"
|
||||
data-test="remove-collaborator-{{ $collaborator->id }}"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<flux:text size="sm" class="text-zinc-500 dark:text-zinc-400">{{ __('No one else has access yet.') }}</flux:text>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<form wire:submit="inviteCollaborator" class="space-y-3">
|
||||
<flux:heading size="sm">{{ __('Invite by email') }}</flux:heading>
|
||||
<div class="flex flex-wrap items-start gap-3">
|
||||
<div class="min-w-56 flex-1">
|
||||
<flux:input
|
||||
wire:model="inviteEmail"
|
||||
type="email"
|
||||
placeholder="name@example.com"
|
||||
data-test="invite-email-input"
|
||||
/>
|
||||
<flux:error name="inviteEmail" />
|
||||
</div>
|
||||
<div>
|
||||
<flux:select wire:model="inviteRole" data-test="invite-role-select">
|
||||
@foreach (FolderRole::assignable() as $role)
|
||||
<flux:select.option value="{{ $role->value }}">{{ $role->label() }}</flux:select.option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:error name="inviteRole" />
|
||||
</div>
|
||||
<flux:button type="submit" variant="primary" icon="paper-airplane" data-test="invite-collaborator-button">
|
||||
{{ __('Send invite') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@if ($this->sharingInvitations->isNotEmpty())
|
||||
<div class="space-y-3">
|
||||
<flux:heading size="sm">{{ __('Pending invitations') }}</flux:heading>
|
||||
@foreach ($this->sharingInvitations as $invitation)
|
||||
<div class="flex flex-wrap items-center justify-between gap-3" data-test="invitation-row-{{ $invitation->id }}">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<flux:text class="truncate">{{ $invitation->email }}</flux:text>
|
||||
<flux:badge size="sm">{{ $invitation->roleLabel() }}</flux:badge>
|
||||
</div>
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="x-mark"
|
||||
wire:click="revokeFolderInvitation({{ $invitation->id }})"
|
||||
data-test="revoke-invitation-{{ $invitation->id }}"
|
||||
>
|
||||
{{ __('Revoke') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:button variant="ghost" wire:click="closeShare" data-test="close-share-button">
|
||||
{{ __('Done') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</flux:modal>
|
||||
</div>
|
||||
Reference in New Issue
Block a user