- Restriction UI warning

- create folder restriction
- fixed UI bugs
This commit is contained in:
Čarodej
2022-01-05 12:48:07 +01:00
parent c7c11fe5b9
commit b4887cea0e
21 changed files with 306 additions and 71 deletions

View File

@@ -5,24 +5,35 @@ use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\Auth;
use Domain\Folders\Requests\CreateFolderRequest;
use App\Users\Exceptions\InvalidUserActionException;
class CreateFolderAction
{
/**
* Create new folder
*
* @throws InvalidUserActionException
*/
public function __invoke(
CreateFolderRequest $request,
?Share $shared = null,
): Folder|array {
// Get user model
$user = $shared
? $shared->user
: Auth::user();
// Check if user can create folder
if (! $user->canCreateFolder()) {
throw new InvalidUserActionException();
}
/*
* check if exist parent team folder, if yes,
* then get folder to detect whether it is team_folder
* Check if exist parent team folder, if yes,
* then get the latest parent folder to detect whether it is team_folder
*/
if ($request->has('parent_id')) {
$isTeamFolder = Folder::find(
$request->input('parent_id')
)
$isTeamFolder = Folder::find($request->input('parent_id'))
->getLatestParent()
->team_folder;
}
@@ -34,7 +45,7 @@ class CreateFolderAction
'color' => $request->input('color') ?? null,
'emoji' => $request->input('emoji') ?? null,
'author' => $shared ? 'visitor' : 'user',
'user_id' => $shared ? $shared->user_id : Auth::id(),
'user_id' => $user->id,
'team_folder' => $isTeamFolder ?? false,
]);
}