mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
- gate implementation
- protected shared view fix
This commit is contained in:
@@ -40,12 +40,13 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"friendsofphp/php-cs-fixer": "^3.0.0",
|
|
||||||
"barryvdh/laravel-ide-helper": "^2.10",
|
"barryvdh/laravel-ide-helper": "^2.10",
|
||||||
"facade/ignition": "^2.11.0",
|
"facade/ignition": "^2.11.0",
|
||||||
"fakerphp/faker": "^1.15.0",
|
"fakerphp/faker": "^1.15.0",
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.0.0",
|
||||||
"mockery/mockery": "^1.4.3",
|
"mockery/mockery": "^1.4.3",
|
||||||
"nunomaduro/collision": "^5.5.0",
|
"nunomaduro/collision": "^5.5.0",
|
||||||
|
"nunomaduro/larastan": "^0.7.12",
|
||||||
"phpunit/phpunit": "^9.5.6"
|
"phpunit/phpunit": "^9.5.6"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
165
composer.lock
generated
165
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "bcd10f3eae3b80b155c555c14b6c1224",
|
"content-hash": "cc6fc3139c683c235e4ceb5158a91874",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "amphp/amp",
|
"name": "amphp/amp",
|
||||||
@@ -12270,6 +12270,103 @@
|
|||||||
],
|
],
|
||||||
"time": "2021-07-26T20:39:06+00:00"
|
"time": "2021-07-26T20:39:06+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nunomaduro/larastan",
|
||||||
|
"version": "v0.7.12",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nunomaduro/larastan.git",
|
||||||
|
"reference": "b2da312efe88d501aeeb867ba857e8c4198d43c0"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nunomaduro/larastan/zipball/b2da312efe88d501aeeb867ba857e8c4198d43c0",
|
||||||
|
"reference": "b2da312efe88d501aeeb867ba857e8c4198d43c0",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"composer/composer": "^1.0 || ^2.0",
|
||||||
|
"ext-json": "*",
|
||||||
|
"illuminate/console": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/container": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/contracts": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/database": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/http": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/pipeline": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0",
|
||||||
|
"mockery/mockery": "^0.9 || ^1.0",
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"phpstan/phpstan": "^0.12.90",
|
||||||
|
"symfony/process": "^4.3 || ^5.0 || ^6.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0",
|
||||||
|
"phpunit/phpunit": "^7.3 || ^8.2 || ^9.3"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench"
|
||||||
|
},
|
||||||
|
"type": "phpstan-extension",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.6-dev"
|
||||||
|
},
|
||||||
|
"phpstan": {
|
||||||
|
"includes": [
|
||||||
|
"extension.neon"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"NunoMaduro\\Larastan\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nuno Maduro",
|
||||||
|
"email": "enunomaduro@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"PHPStan",
|
||||||
|
"code analyse",
|
||||||
|
"code analysis",
|
||||||
|
"larastan",
|
||||||
|
"laravel",
|
||||||
|
"package",
|
||||||
|
"php",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/nunomaduro/larastan/issues",
|
||||||
|
"source": "https://github.com/nunomaduro/larastan/tree/v0.7.12"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/canvural",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nunomaduro",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/nunomaduro",
|
||||||
|
"type": "patreon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2021-07-26T12:12:39+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "php-cs-fixer/diff",
|
"name": "php-cs-fixer/diff",
|
||||||
"version": "v2.0.2",
|
"version": "v2.0.2",
|
||||||
@@ -12322,6 +12419,70 @@
|
|||||||
},
|
},
|
||||||
"time": "2020-10-14T08:32:19+00:00"
|
"time": "2020-10-14T08:32:19+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "0.12.99",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||||
|
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.1|^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan-shim": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"phpstan",
|
||||||
|
"phpstan.phar"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.12-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"source": "https://github.com/phpstan/phpstan/tree/0.12.99"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/ondrejmirtes",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/phpstan",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/phpstan",
|
||||||
|
"type": "patreon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2021-09-12T20:09:55+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "react/promise",
|
"name": "react/promise",
|
||||||
"version": "v2.8.0",
|
"version": "v2.8.0",
|
||||||
@@ -12690,5 +12851,5 @@
|
|||||||
"platform-dev": {
|
"platform-dev": {
|
||||||
"ext-json": "*"
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.0.0"
|
"plugin-api-version": "2.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class TeamFolderInvitationFactory extends Factory
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->faker->uuid,
|
'id' => $this->faker->uuid,
|
||||||
'folder_id' => $this->faker->uuid,
|
'parent_id' => $this->faker->uuid,
|
||||||
'email' => $this->faker->email,
|
'email' => $this->faker->email,
|
||||||
'permission' => $this->faker->randomElement(['can-edit', 'can-view', 'can-view-and-download']),
|
'permission' => $this->faker->randomElement(['can-edit', 'can-view', 'can-view-and-download']),
|
||||||
'status' => $this->faker->randomElement(['pending', 'accepted', 'rejected']),
|
'status' => $this->faker->randomElement(['pending', 'accepted', 'rejected']),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class CreateFileManagerFiles extends Migration
|
|||||||
Schema::create('files', function (Blueprint $table) {
|
Schema::create('files', function (Blueprint $table) {
|
||||||
$table->uuid('id')->primary()->index();
|
$table->uuid('id')->primary()->index();
|
||||||
$table->uuid('user_id')->index();
|
$table->uuid('user_id')->index();
|
||||||
$table->uuid('folder_id')->nullable();
|
$table->uuid('parent_id')->nullable();
|
||||||
|
|
||||||
$table->text('thumbnail')->nullable();
|
$table->text('thumbnail')->nullable();
|
||||||
$table->text('name');
|
$table->text('name');
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CreateFavouritesFoldersTable extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('favourite_folder', function (Blueprint $table) {
|
Schema::create('favourite_folder', function (Blueprint $table) {
|
||||||
$table->uuid('user_id');
|
$table->uuid('user_id');
|
||||||
$table->uuid('folder_id');
|
$table->uuid('parent_id');
|
||||||
$table->charset = 'utf8mb4';
|
$table->charset = 'utf8mb4';
|
||||||
$table->collation = 'utf8mb4_unicode_ci';
|
$table->collation = 'utf8mb4_unicode_ci';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CreateTeamFolderInvitationsTable extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('team_folder_invitations', function (Blueprint $table) {
|
Schema::create('team_folder_invitations', function (Blueprint $table) {
|
||||||
$table->uuid('id')->primary();
|
$table->uuid('id')->primary();
|
||||||
$table->uuid('folder_id');
|
$table->uuid('parent_id');
|
||||||
$table->text('email');
|
$table->text('email');
|
||||||
$table->string('color')->nullable();
|
$table->string('color')->nullable();
|
||||||
$table->enum('permission', ['can-edit', 'can-view', 'can-view-and-download']);
|
$table->enum('permission', ['can-edit', 'can-view', 'can-view-and-download']);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CreateTeamFolderMembersTable extends Migration
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('team_folder_members', function (Blueprint $table) {
|
Schema::create('team_folder_members', function (Blueprint $table) {
|
||||||
$table->uuid('folder_id');
|
$table->uuid('parent_id');
|
||||||
$table->uuid('user_id');
|
$table->uuid('user_id');
|
||||||
$table->string('permission');
|
$table->string('permission');
|
||||||
$table->charset = 'utf8mb4';
|
$table->charset = 'utf8mb4';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<psalm
|
<psalm
|
||||||
errorLevel="4"
|
errorLevel="5"
|
||||||
findUnusedVariablesAndParams="true"
|
findUnusedVariablesAndParams="true"
|
||||||
resolveFromConfigFile="true"
|
resolveFromConfigFile="true"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
|||||||
2
public/js/main.js
vendored
2
public/js/main.js
vendored
File diff suppressed because one or more lines are too long
@@ -73,8 +73,8 @@
|
|||||||
"/chunks/settings-subscription.js": "/chunks/settings-subscription.js?id=b6fc82aff2f4a79a4905",
|
"/chunks/settings-subscription.js": "/chunks/settings-subscription.js?id=b6fc82aff2f4a79a4905",
|
||||||
"/chunks/settings~chunks/settings-password.js": "/chunks/settings~chunks/settings-password.js?id=9ce23d68ab14cd3672cf",
|
"/chunks/settings~chunks/settings-password.js": "/chunks/settings~chunks/settings-password.js?id=9ce23d68ab14cd3672cf",
|
||||||
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=651d5accf401908724c5",
|
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=651d5accf401908724c5",
|
||||||
"/chunks/shared.js": "/chunks/shared.js?id=89b540a879b4c36f4ace",
|
"/chunks/shared.js": "/chunks/shared.js?id=30e37fcce9200fc20803",
|
||||||
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=6dffc57f13abdd0cda24",
|
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=ac50ab7649bad5d43867",
|
||||||
"/chunks/shared/files.js": "/chunks/shared/files.js?id=f7d29daa21fc7df5fb8d",
|
"/chunks/shared/files.js": "/chunks/shared/files.js?id=f7d29daa21fc7df5fb8d",
|
||||||
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=8b19e65b3ef9aaef449e",
|
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=8b19e65b3ef9aaef449e",
|
||||||
"/chunks/sign-in.js": "/chunks/sign-in.js?id=9c8ddd399f8461ed6306",
|
"/chunks/sign-in.js": "/chunks/sign-in.js?id=9c8ddd399f8461ed6306",
|
||||||
@@ -101,60 +101,14 @@
|
|||||||
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~81c8aec0.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~81c8aec0.js?id=ca3b57f70682c1c315f7",
|
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~81c8aec0.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~81c8aec0.js?id=ca3b57f70682c1c315f7",
|
||||||
"/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~3c02639c.js": "/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~3c02639c.js?id=e31953d811b86273037b",
|
"/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~3c02639c.js": "/vendors~chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunk~3c02639c.js?id=e31953d811b86273037b",
|
||||||
"/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js": "/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js?id=90d4a5c68188a1bbce59",
|
"/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js": "/vendors~chunks/admin~chunks/platform~chunks/settings~chunks/shared.js?id=90d4a5c68188a1bbce59",
|
||||||
"/chunks/platform~chunks/shared.cb1aa30179d11be7dccf.hot-update.js": "/chunks/platform~chunks/shared.cb1aa30179d11be7dccf.hot-update.js",
|
"/js/main.7506b7c7052fac2f10a1.hot-update.js": "/js/main.7506b7c7052fac2f10a1.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.b982f815eaab5015f892.hot-update.js": "/chunks/platform~chunks/shared.b982f815eaab5015f892.hot-update.js",
|
"/chunks/shared.fa7768522abf1a7d54b3.hot-update.js": "/chunks/shared.fa7768522abf1a7d54b3.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.5722e8906a9eba233567.hot-update.js": "/chunks/platform~chunks/shared.5722e8906a9eba233567.hot-update.js",
|
"/chunks/shared.aba44bfa0d41183c7606.hot-update.js": "/chunks/shared.aba44bfa0d41183c7606.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.495381808384fd0640bc.hot-update.js": "/chunks/platform~chunks/shared.495381808384fd0640bc.hot-update.js",
|
"/chunks/shared.99c9a6c9787fabd5fae7.hot-update.js": "/chunks/shared.99c9a6c9787fabd5fae7.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.448f2d2676b39dc92824.hot-update.js": "/chunks/platform~chunks/shared.448f2d2676b39dc92824.hot-update.js",
|
"/chunks/shared.223373c5dc20fac518ee.hot-update.js": "/chunks/shared.223373c5dc20fac518ee.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.333b3cecc35a2b073830.hot-update.js": "/chunks/platform~chunks/shared.333b3cecc35a2b073830.hot-update.js",
|
"/chunks/shared/authenticate.b754c3efa0f6d09c6d5d.hot-update.js": "/chunks/shared/authenticate.b754c3efa0f6d09c6d5d.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.7a587439c69e3706b8a3.hot-update.js": "/chunks/platform~chunks/shared.7a587439c69e3706b8a3.hot-update.js",
|
"/chunks/shared/authenticate.f99485cf74326346a8b1.hot-update.js": "/chunks/shared/authenticate.f99485cf74326346a8b1.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.2ec5382f12ef526bcbdd.hot-update.js": "/chunks/platform~chunks/shared.2ec5382f12ef526bcbdd.hot-update.js",
|
"/chunks/shared.56ccba53201e5195af28.hot-update.js": "/chunks/shared.56ccba53201e5195af28.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.9b110a3a50c3298b46f9.hot-update.js": "/chunks/platform~chunks/shared.9b110a3a50c3298b46f9.hot-update.js",
|
"/chunks/shared.4d20e6443aee96d57755.hot-update.js": "/chunks/shared.4d20e6443aee96d57755.hot-update.js",
|
||||||
"/chunks/platform~chunks/shared.9d28a9271e904faa8b5e.hot-update.js": "/chunks/platform~chunks/shared.9d28a9271e904faa8b5e.hot-update.js",
|
"/chunks/shared.231c37d4d932d493e5ba.hot-update.js": "/chunks/shared.231c37d4d932d493e5ba.hot-update.js"
|
||||||
"/chunks/platform~chunks/shared.e71315b2abe2640cf551.hot-update.js": "/chunks/platform~chunks/shared.e71315b2abe2640cf551.hot-update.js",
|
|
||||||
"/chunks/platform~chunks/shared.e7f518e2d6c5a53496c6.hot-update.js": "/chunks/platform~chunks/shared.e7f518e2d6c5a53496c6.hot-update.js",
|
|
||||||
"/js/main.4b266bad00e78dd36b3d.hot-update.js": "/js/main.4b266bad00e78dd36b3d.hot-update.js",
|
|
||||||
"/js/main.844945c01d249c235cff.hot-update.js": "/js/main.844945c01d249c235cff.hot-update.js",
|
|
||||||
"/js/main.675725b6826e6865cdbf.hot-update.js": "/js/main.675725b6826e6865cdbf.hot-update.js",
|
|
||||||
"/js/main.7ba1b4bc5772f48db70c.hot-update.js": "/js/main.7ba1b4bc5772f48db70c.hot-update.js",
|
|
||||||
"/js/main.33a95bbab94bca89339a.hot-update.js": "/js/main.33a95bbab94bca89339a.hot-update.js",
|
|
||||||
"/chunks/platform~chunks/shared.5b2e2cd09d01a879b649.hot-update.js": "/chunks/platform~chunks/shared.5b2e2cd09d01a879b649.hot-update.js",
|
|
||||||
"/chunks/platform~chunks/shared.88cb2aaa58c930e730bb.hot-update.js": "/chunks/platform~chunks/shared.88cb2aaa58c930e730bb.hot-update.js",
|
|
||||||
"/chunks/recent-uploads.4b1bb3733a4d3fe5f537.hot-update.js": "/chunks/recent-uploads.4b1bb3733a4d3fe5f537.hot-update.js",
|
|
||||||
"/chunks/files.640fbb6c78bd7acc7e0b.hot-update.js": "/chunks/files.640fbb6c78bd7acc7e0b.hot-update.js",
|
|
||||||
"/chunks/shared/files.8ebede730f066866342b.hot-update.js": "/chunks/shared/files.8ebede730f066866342b.hot-update.js",
|
|
||||||
"/chunks/team-folders.fe2486db6d676a42b39f.hot-update.js": "/chunks/team-folders.fe2486db6d676a42b39f.hot-update.js",
|
|
||||||
"/chunks/team-folders.e667681d6153f69d4472.hot-update.js": "/chunks/team-folders.e667681d6153f69d4472.hot-update.js",
|
|
||||||
"/chunks/team-folders.eb7be77a54aa34b3b941.hot-update.js": "/chunks/team-folders.eb7be77a54aa34b3b941.hot-update.js",
|
|
||||||
"/chunks/team-folders.ce2683b78534a2a39769.hot-update.js": "/chunks/team-folders.ce2683b78534a2a39769.hot-update.js",
|
|
||||||
"/chunks/team-folders.2d6f75df6a0dc20e2f40.hot-update.js": "/chunks/team-folders.2d6f75df6a0dc20e2f40.hot-update.js",
|
|
||||||
"/chunks/app-language.ff287f12368bcd33984e.hot-update.js": "/chunks/app-language.ff287f12368bcd33984e.hot-update.js",
|
|
||||||
"/chunks/team-folders.1c71560f20910d65f386.hot-update.js": "/chunks/team-folders.1c71560f20910d65f386.hot-update.js",
|
|
||||||
"/js/main.0b112e70e3744362ebba.hot-update.js": "/js/main.0b112e70e3744362ebba.hot-update.js",
|
|
||||||
"/chunks/team-folders.ae5034b37cf3ec1375b5.hot-update.js": "/chunks/team-folders.ae5034b37cf3ec1375b5.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.968d44c5e06e15949b90.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.968d44c5e06e15949b90.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.0782d7370ecb23029ef3.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.0782d7370ecb23029ef3.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.9cac27b22abf3d45a553.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.9cac27b22abf3d45a553.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.a0bc3c678b7fb796326f.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.a0bc3c678b7fb796326f.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.eff6a260c6925a615fa8.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.eff6a260c6925a615fa8.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.5b865c03d4b704fe3b4d.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.5b865c03d4b704fe3b4d.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.4806edd9ab8a4aa165c2.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.4806edd9ab8a4aa165c2.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.4806edd9ab8a4aa165c2.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.4806edd9ab8a4aa165c2.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.27cf8be8caf6ef3d2458.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.27cf8be8caf6ef3d2458.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.2334dab520bb88b3a449.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~d04310d2.2334dab520bb88b3a449.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.17de2a0ce854792fb711.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.17de2a0ce854792fb711.hot-update.js",
|
|
||||||
"/chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~chunks/share~b068369d.6cb065e11483b02f8776.hot-update.js": "/chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~chunks/share~b068369d.6cb065e11483b02f8776.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.805ea9e4152ce2298930.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.805ea9e4152ce2298930.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.e8ee3be9849d0c5530ee.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.e8ee3be9849d0c5530ee.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.3a1a25dc65817ddda03f.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.3a1a25dc65817ddda03f.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.3d6cb492a2615ccac133.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.3d6cb492a2615ccac133.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.40362d56557d10b49702.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.40362d56557d10b49702.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.64cd2c0643cce6c3f753.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.64cd2c0643cce6c3f753.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.063d5dcbdac51cf7aae4.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.063d5dcbdac51cf7aae4.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.b1244bfdd2b12666adaf.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.b1244bfdd2b12666adaf.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.0dba8b3a2ed386af47fd.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.0dba8b3a2ed386af47fd.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.55e249cfc4e18ad9757c.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.55e249cfc4e18ad9757c.hot-update.js",
|
|
||||||
"/chunks/team-folders.b55311fef809aae5da00.hot-update.js": "/chunks/team-folders.b55311fef809aae5da00.hot-update.js",
|
|
||||||
"/chunks/team-folders.a1b126740c322ccb2631.hot-update.js": "/chunks/team-folders.a1b126740c322ccb2631.hot-update.js",
|
|
||||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.dec26a25bf049b770974.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~26d67489.dec26a25bf049b770974.hot-update.js"
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
resources/js/helpers/functionHelpers.js
vendored
6
resources/js/helpers/functionHelpers.js
vendored
@@ -90,7 +90,7 @@ const FunctionHelpers = {
|
|||||||
// Push items to file queue
|
// Push items to file queue
|
||||||
[...files].map(item => {
|
[...files].map(item => {
|
||||||
this.$store.commit('ADD_FILES_TO_QUEUE', {
|
this.$store.commit('ADD_FILES_TO_QUEUE', {
|
||||||
folder_id: store.getters.currentFolder ? store.getters.currentFolder.data.id : '',
|
parent_id: store.getters.currentFolder ? store.getters.currentFolder.data.id : '',
|
||||||
file: item,
|
file: item,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -111,7 +111,7 @@ const FunctionHelpers = {
|
|||||||
// Push items to file queue
|
// Push items to file queue
|
||||||
[...event.dataTransfer.items].map(item => {
|
[...event.dataTransfer.items].map(item => {
|
||||||
this.$store.commit('ADD_FILES_TO_QUEUE', {
|
this.$store.commit('ADD_FILES_TO_QUEUE', {
|
||||||
folder_id: parent_id ? parent_id : '',
|
parent_id: parent_id ? parent_id : '',
|
||||||
file: item.getAsFile(),
|
file: item.getAsFile(),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -160,7 +160,7 @@ const FunctionHelpers = {
|
|||||||
// Set form data
|
// Set form data
|
||||||
formData.set('filename', item.file.name);
|
formData.set('filename', item.file.name);
|
||||||
formData.set('file', chunk, source_name);
|
formData.set('file', chunk, source_name);
|
||||||
formData.set('folder_id', item.folder_id)
|
formData.set('parent_id', item.parent_id)
|
||||||
formData.set('is_last', isLast);
|
formData.set('is_last', isLast);
|
||||||
|
|
||||||
// Upload chunks
|
// Upload chunks
|
||||||
|
|||||||
2
resources/js/store/modules/fileFunctions.js
vendored
2
resources/js/store/modules/fileFunctions.js
vendored
@@ -185,7 +185,7 @@ const actions = {
|
|||||||
commit('SHIFT_FROM_FILE_QUEUE')
|
commit('SHIFT_FROM_FILE_QUEUE')
|
||||||
|
|
||||||
// Check if user is in uploading folder, if yes, than show new file
|
// Check if user is in uploading folder, if yes, than show new file
|
||||||
if ((! getters.currentFolder && !response.data.data.attributes.folder_id) || response.data.data.attributes.folder_id === getters.currentFolder.data.id) {
|
if ((! getters.currentFolder && !response.data.data.attributes.parent_id) || response.data.data.attributes.parent_id === getters.currentFolder.data.id) {
|
||||||
|
|
||||||
// Add uploaded item into view
|
// Add uploaded item into view
|
||||||
commit('ADD_NEW_ITEMS', response.data)
|
commit('ADD_NEW_ITEMS', response.data)
|
||||||
|
|||||||
@@ -24,10 +24,11 @@
|
|||||||
<DragUI />
|
<DragUI />
|
||||||
<Alert />
|
<Alert />
|
||||||
|
|
||||||
<NavigationSharePanel v-if="sharedDetail"/>
|
<NavigationSharePanel v-if="sharedDetail && $router.currentRoute.name === 'Public'"/>
|
||||||
|
|
||||||
<div @contextmenu.prevent.capture="contextMenu($event, undefined)" id="file-view">
|
<div @contextmenu.prevent.capture="contextMenu($event, undefined)" id="file-view">
|
||||||
<DesktopToolbar/>
|
<DesktopToolbar/>
|
||||||
|
<!--TODO: fix desktopbar on authentication screen-->
|
||||||
<router-view :key="$route.fullPath" />
|
<router-view :key="$route.fullPath" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,7 +102,7 @@
|
|||||||
|
|
||||||
let type = response.data.data.attributes.type
|
let type = response.data.data.attributes.type
|
||||||
let routeName = this.$router.currentRoute.name
|
let routeName = this.$router.currentRoute.name
|
||||||
let isProtected = response.data.data.attributes.is_protected
|
let isProtected = response.data.data.attributes.protected
|
||||||
|
|
||||||
// Show public file browser
|
// Show public file browser
|
||||||
if (type === 'folder' && !isProtected && routeName !== 'Public') {
|
if (type === 'folder' && !isProtected && routeName !== 'Public') {
|
||||||
|
|||||||
@@ -65,9 +65,9 @@
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
// Show file browser
|
// Show file browser
|
||||||
if (response.data.data.attributes.type === 'folder' && this.$router.currentRoute.name !== 'SharedFileBrowser') {
|
if (response.data.data.attributes.type === 'folder' && this.$router.currentRoute.name !== 'Public') {
|
||||||
this.$router.push({name: 'SharedFileBrowser'})
|
this.$router.replace({name: 'Public', params: {token: this.$route.params.token, id: response.data.data.attributes.item_id}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show single file
|
// Show single file
|
||||||
if (response.data.data.attributes.type !== 'folder' && this.$router.currentRoute.name !== 'SharedSingleFile') {
|
if (response.data.data.attributes.type !== 'folder' && this.$router.currentRoute.name !== 'SharedSingleFile') {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
@@ -38,8 +37,7 @@ class SetupDevEnvironment extends Command
|
|||||||
private SeedDefaultSettingsAction $seedDefaultSettings,
|
private SeedDefaultSettingsAction $seedDefaultSettings,
|
||||||
private SeedDefaultLanguageAction $seedDefaultLanguage,
|
private SeedDefaultLanguageAction $seedDefaultLanguage,
|
||||||
private SeedDefaultPagesAction $seedDefaultPages,
|
private SeedDefaultPagesAction $seedDefaultPages,
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setUpFaker();
|
$this->setUpFaker();
|
||||||
}
|
}
|
||||||
@@ -392,7 +390,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file['name'],
|
'name' => $file['name'],
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -435,7 +433,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $documents->id,
|
'parent_id' => $documents->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file['name'],
|
'name' => $file['name'],
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -468,7 +466,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $shared_folder->id,
|
'parent_id' => $shared_folder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file['name'],
|
'name' => $file['name'],
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -526,7 +524,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $peters_files->id,
|
'parent_id' => $peters_files->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file['name'],
|
'name' => $file['name'],
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -553,7 +551,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $videohive->id,
|
'parent_id' => $videohive->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -577,7 +575,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $video->id,
|
'parent_id' => $video->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -601,7 +599,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $audio->id,
|
'parent_id' => $audio->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -637,7 +635,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -669,7 +667,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $apartments->id,
|
'parent_id' => $apartments->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -705,7 +703,7 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
'folder_id' => $nature->id,
|
'parent_id' => $nature->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $file,
|
'name' => $file,
|
||||||
'basename' => $basename,
|
'basename' => $basename,
|
||||||
@@ -758,9 +756,9 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
collect([$members[0]->id, $members[1]->id])
|
collect([$members[0]->id, $members[1]->id])
|
||||||
->each(
|
->each(
|
||||||
fn($id) => DB::table('team_folder_members')
|
fn ($id) => DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
'folder_id' => $companyProjectFolder->id,
|
'parent_id' => $companyProjectFolder->id,
|
||||||
'user_id' => $id,
|
'user_id' => $id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
])
|
])
|
||||||
@@ -768,9 +766,9 @@ class SetupDevEnvironment extends Command
|
|||||||
|
|
||||||
collect([$members[2]->id, $members[3]->id])
|
collect([$members[2]->id, $members[3]->id])
|
||||||
->each(
|
->each(
|
||||||
fn($id) => DB::table('team_folder_members')
|
fn ($id) => DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
'folder_id' => $financeDocumentsFolder->id,
|
'parent_id' => $financeDocumentsFolder->id,
|
||||||
'user_id' => $id,
|
'user_id' => $id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
])
|
])
|
||||||
@@ -779,10 +777,10 @@ class SetupDevEnvironment extends Command
|
|||||||
// Create invitations
|
// Create invitations
|
||||||
collect([$members[4], $members[5]])
|
collect([$members[4], $members[5]])
|
||||||
->each(
|
->each(
|
||||||
fn($user) => TeamFolderInvitation::factory()
|
fn ($user) => TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'folder_id' => $companyProjectFolder->id,
|
'parent_id' => $companyProjectFolder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
])
|
])
|
||||||
@@ -795,7 +793,7 @@ class SetupDevEnvironment extends Command
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
$images = File::whereType('image')
|
$images = File::whereType('image')
|
||||||
->whereFolderId(null)
|
->whereParentId(null)
|
||||||
->take(3)
|
->take(3)
|
||||||
->pluck('id');
|
->pluck('id');
|
||||||
|
|
||||||
@@ -812,7 +810,7 @@ class SetupDevEnvironment extends Command
|
|||||||
});
|
});
|
||||||
|
|
||||||
$files = File::whereType('file')
|
$files = File::whereType('file')
|
||||||
->whereFolderId(null)
|
->whereParentId(null)
|
||||||
->take(2)
|
->take(2)
|
||||||
->pluck('id');
|
->pluck('id');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
use App\Users\Models\User;
|
||||||
|
use Domain\Files\Models\File;
|
||||||
|
use Domain\Sharing\Models\Share;
|
||||||
|
use Domain\Folders\Models\Folder;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
@@ -26,5 +32,64 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
// Define admin maintenance gate
|
// Define admin maintenance gate
|
||||||
Gate::define('maintenance', fn ($user) => $user->role === 'admin');
|
Gate::define('maintenance', fn ($user) => $user->role === 'admin');
|
||||||
|
|
||||||
|
// Define user ability
|
||||||
|
collect(['can-edit', 'can-visit'])
|
||||||
|
->each(function ($ability) {
|
||||||
|
Gate::define($ability, function (?User $user, File | Folder $item, ?Share $share) use ($ability) {
|
||||||
|
// If share link exist, then check share access
|
||||||
|
if ($share) {
|
||||||
|
return $this->share_guard($share, $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check user owner status
|
||||||
|
if ($user?->id === $item->user_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check team member ability to access into requested item
|
||||||
|
return $this->team_member_guard($item, $user, $ability);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function share_guard(Share $share, Folder | File $item): bool
|
||||||
|
{
|
||||||
|
$isOwner = $share->user_id === $item->user_id;
|
||||||
|
|
||||||
|
if (! $share->is_protected && $isOwner) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! request()->hasCookie('share_session')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get shared session
|
||||||
|
$share_session = json_decode(
|
||||||
|
request()->cookie('share_session')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if is requested same share record
|
||||||
|
if ($share_session->token !== $share->token) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if share record was previously authenticated
|
||||||
|
if (! $share_session->authenticated) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $isOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function team_member_guard(Folder | File $item, ?User $user, $ability): bool
|
||||||
|
{
|
||||||
|
$membership = DB::table('team_folder_members')
|
||||||
|
->where('parent_id', $item->getLatestParent()->id)
|
||||||
|
->where('user_id', $user->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return $membership?->permission === $ability;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
public function favouriteFolders(): BelongsToMany
|
public function favouriteFolders(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'folder_id', 'id', 'id')
|
return $this->belongsToMany(Folder::class, 'favourite_folder', 'user_id', 'parent_id', 'id', 'id')
|
||||||
->where('team_folder', false);
|
->where('team_folder', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class DeleteUserController extends Controller
|
|||||||
DeleteUserDataAction $deleteUserData,
|
DeleteUserDataAction $deleteUserData,
|
||||||
): Response {
|
): Response {
|
||||||
if (is_demo()) {
|
if (is_demo()) {
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->subscribed('main')) {
|
if ($user->subscribed('main')) {
|
||||||
@@ -39,6 +39,6 @@ class DeleteUserController extends Controller
|
|||||||
// Delete all user data
|
// Delete all user data
|
||||||
($deleteUserData)($user);
|
($deleteUserData)($user);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ResetUserPasswordController extends Controller
|
|||||||
public function __invoke(User $user): Response
|
public function __invoke(User $user): Response
|
||||||
{
|
{
|
||||||
if (is_demo()) {
|
if (is_demo()) {
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get password token
|
// Get password token
|
||||||
@@ -24,6 +24,6 @@ class ResetUserPasswordController extends Controller
|
|||||||
// Send user email
|
// Send user email
|
||||||
$user->sendPasswordResetNotification($token);
|
$user->sendPasswordResetNotification($token);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class BrowseFolderController
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
$files = File::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
$files = File::with(['parent:id,name', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||||
->where('folder_id', $root_id)
|
->where('parent_id', $root_id)
|
||||||
->where('user_id', Auth::id())
|
->where('user_id', Auth::id())
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class BrowseSharedItemsController
|
|||||||
$user_id = Auth::id();
|
$user_id = Auth::id();
|
||||||
|
|
||||||
// Get shared folders and files
|
// Get shared folders and files
|
||||||
$folder_ids = Share::where('user_id', $user_id)
|
$parent_ids = Share::where('user_id', $user_id)
|
||||||
->where('type', 'folder')
|
->where('type', 'folder')
|
||||||
->pluck('item_id');
|
->pluck('item_id');
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ class BrowseSharedItemsController
|
|||||||
// Get folders and files
|
// Get folders and files
|
||||||
$folders = Folder::with(['parent', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
$folders = Folder::with(['parent', 'shared:token,id,item_id,permission,is_protected,expire_in'])
|
||||||
->where('user_id', $user_id)
|
->where('user_id', $user_id)
|
||||||
->whereIn('id', $folder_ids)
|
->whereIn('id', $parent_ids)
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class BrowseTrashContentController
|
|||||||
|
|
||||||
$files = File::onlyTrashed()
|
$files = File::onlyTrashed()
|
||||||
->with('parent')
|
->with('parent')
|
||||||
->where('folder_id', $root_id)
|
->where('parent_id', $root_id)
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ class BrowseTrashContentController
|
|||||||
->with(['parent'])
|
->with(['parent'])
|
||||||
->where('user_id', $user_id)
|
->where('user_id', $user_id)
|
||||||
->where(function ($query) use ($folders_trashed) {
|
->where(function ($query) use ($folders_trashed) {
|
||||||
$query->whereNull('folder_id');
|
$query->whereNull('parent_id');
|
||||||
$query->orWhereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'id'))));
|
$query->orWhereNotIn('parent_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'id'))));
|
||||||
})
|
})
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class VisitorBrowseFolderController
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
$files = File::where('user_id', $shared->user_id)
|
$files = File::where('user_id', $shared->user_id)
|
||||||
->where('folder_id', $id)
|
->where('parent_id', $id)
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -47,21 +47,21 @@ class VisitorSearchFilesAndFoldersController extends Controller
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
// Get accessible folders
|
// Get accessible folders
|
||||||
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
$accessible_parent_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
||||||
|
|
||||||
// Filter files
|
// Filter files
|
||||||
$files = $searched_files->filter(function ($file) use ($accessible_folder_ids, $shared) {
|
$files = $searched_files->filter(function ($file) use ($accessible_parent_ids, $shared) {
|
||||||
// Set public urls
|
// Set public urls
|
||||||
$file->setPublicUrl($shared->token);
|
$file->setPublicUrl($shared->token);
|
||||||
|
|
||||||
// check if item is in accessible folders
|
// check if item is in accessible folders
|
||||||
return in_array($file->folder_id, $accessible_folder_ids);
|
return in_array($file->parent_id, $accessible_parent_ids);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter folders
|
// Filter folders
|
||||||
$folders = $searched_folders->filter(function ($folder) use ($accessible_folder_ids) {
|
$folders = $searched_folders->filter(function ($folder) use ($accessible_parent_ids) {
|
||||||
// check if item is in accessible folders
|
// check if item is in accessible folders
|
||||||
return in_array($folder->id, $accessible_folder_ids);
|
return in_array($folder->id, $accessible_parent_ids);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collect folders and files to single array
|
// Collect folders and files to single array
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class UploadFileAction
|
|||||||
return UserFile::create([
|
return UserFile::create([
|
||||||
'mimetype' => get_file_type_from_mimetype($file_mimetype),
|
'mimetype' => get_file_type_from_mimetype($file_mimetype),
|
||||||
'type' => get_file_type($file_mimetype),
|
'type' => get_file_type($file_mimetype),
|
||||||
'folder_id' => $request->input('folder_id'),
|
'parent_id' => $request->input('parent_id'),
|
||||||
'metadata' => $metadata,
|
'metadata' => $metadata,
|
||||||
'name' => $request->input('filename'),
|
'name' => $request->input('filename'),
|
||||||
'basename' => $disk_file_name,
|
'basename' => $disk_file_name,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class UploadFileController extends Controller
|
|||||||
public function __invoke(
|
public function __invoke(
|
||||||
UploadRequest $request,
|
UploadRequest $request,
|
||||||
): Response | array {
|
): Response | array {
|
||||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
if (is_demo_account()) {
|
||||||
return ($this->fakeUploadFile)($request);
|
return ($this->fakeUploadFile)($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace Domain\Files\Controllers;
|
namespace Domain\Files\Controllers;
|
||||||
|
|
||||||
use Domain\Files\Models\File;
|
use Domain\Files\Models\File;
|
||||||
|
use Gate;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Domain\Sharing\Models\Share;
|
use Domain\Sharing\Models\Share;
|
||||||
use Domain\Files\Resources\FileResource;
|
use Domain\Files\Resources\FileResource;
|
||||||
@@ -12,22 +13,16 @@ use Domain\Sharing\Actions\ProtectShareRecordAction;
|
|||||||
*/
|
*/
|
||||||
class VisitorShowFileController
|
class VisitorShowFileController
|
||||||
{
|
{
|
||||||
public function __construct(
|
|
||||||
private ProtectShareRecordAction $protectShareRecord,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
Share $shared
|
Share $shared
|
||||||
): Response {
|
): Response {
|
||||||
// Check ability to access protected share files
|
|
||||||
($this->protectShareRecord)($shared);
|
|
||||||
|
|
||||||
// Get file
|
|
||||||
$file = File::whereUserId($shared->user_id)
|
$file = File::whereUserId($shared->user_id)
|
||||||
->whereId($shared->item_id)
|
->whereId($shared->item_id)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
|
Gate::authorize('can-visit', [$file, $shared]);
|
||||||
|
|
||||||
// Set access urls
|
// Set access urls
|
||||||
$file->setPublicUrl($shared->token);
|
$file->setPublicUrl($shared->token);
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class VisitorUploadFileController extends Controller
|
|||||||
UploadRequest $request,
|
UploadRequest $request,
|
||||||
Share $shared,
|
Share $shared,
|
||||||
): Response | array {
|
): Response | array {
|
||||||
if (is_demo_account($shared->user->email)) {
|
if (is_demo_account()) {
|
||||||
return ($this->fakeUploadFile)($request);
|
return ($this->fakeUploadFile)($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class VisitorUploadFileController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check access to requested directory
|
// Check access to requested directory
|
||||||
($this->verifyAccessToItem)($request->input('folder_id'), $shared);
|
($this->verifyAccessToItem)($request->input('parent_id'), $shared);
|
||||||
|
|
||||||
// Return new uploaded file
|
// Return new uploaded file
|
||||||
$new_file = ($this->uploadFile)($request, $shared);
|
$new_file = ($this->uploadFile)($request, $shared);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Files\Models;
|
namespace Domain\Files\Models;
|
||||||
|
|
||||||
use ByteUnits\Metric;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Laravel\Scout\Searchable;
|
use Laravel\Scout\Searchable;
|
||||||
use Domain\Sharing\Models\Share;
|
use Domain\Sharing\Models\Share;
|
||||||
@@ -23,7 +22,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
* @method static where(string $string, string $user_id)
|
* @method static where(string $string, string $user_id)
|
||||||
* @property string id
|
* @property string id
|
||||||
* @property string user_id
|
* @property string user_id
|
||||||
* @property string folder_id
|
* @property string parent_id
|
||||||
* @property string thumbnail
|
* @property string thumbnail
|
||||||
* @property string filesize
|
* @property string filesize
|
||||||
* @property string type
|
* @property string type
|
||||||
@@ -148,7 +147,16 @@ class File extends Model
|
|||||||
|
|
||||||
public function parent(): BelongsTo
|
public function parent(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Folder::class, 'folder_id', 'id');
|
return $this->belongsTo(Folder::class, 'parent_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLatestParent()
|
||||||
|
{
|
||||||
|
if ($this->parent) {
|
||||||
|
return $this->parent->getLatestParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shared(): HasOne
|
public function shared(): HasOne
|
||||||
@@ -159,7 +167,8 @@ class File extends Model
|
|||||||
public function toSearchableArray(): array
|
public function toSearchableArray(): array
|
||||||
{
|
{
|
||||||
$name = mb_convert_encoding(
|
$name = mb_convert_encoding(
|
||||||
mb_strtolower($this->name, 'UTF-8'), 'UTF-8'
|
mb_strtolower($this->name, 'UTF-8'),
|
||||||
|
'UTF-8'
|
||||||
);
|
);
|
||||||
|
|
||||||
$trigram = (new TNTIndexer)
|
$trigram = (new TNTIndexer)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class UploadRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'filename' => 'required|string',
|
'filename' => 'required|string',
|
||||||
'folder_id' => 'nullable|uuid',
|
'parent_id' => 'nullable|uuid',
|
||||||
'is_last' => 'sometimes|string',
|
'is_last' => 'sometimes|string',
|
||||||
'file' => ['required', 'file', new DisabledMimetypes],
|
'file' => ['required', 'file', new DisabledMimetypes],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Files\Resources;
|
namespace Domain\Files\Resources;
|
||||||
|
|
||||||
use ByteUnits\Metric;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use ByteUnits\Metric;
|
||||||
use Domain\Sharing\Resources\ShareResource;
|
use Domain\Sharing\Resources\ShareResource;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
@@ -25,17 +25,17 @@ class FileResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'filesize' => $fileSize,
|
'filesize' => $fileSize,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'basename' => $this->basename,
|
'basename' => $this->basename,
|
||||||
'mimetype' => $this->mimetype,
|
'mimetype' => $this->mimetype,
|
||||||
'file_url' => $this->file_url,
|
'file_url' => $this->file_url,
|
||||||
'thumbnail' => $this->thumbnail,
|
'thumbnail' => $this->thumbnail,
|
||||||
'metadata' => $this->metadata,
|
'metadata' => $this->metadata,
|
||||||
'folder_id' => $this->folder_id,
|
'parent_id' => $this->parent_id,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
'created_at' => Carbon::parse($this->created_at)->diffForHumans(),
|
'created_at' => Carbon::parse($this->created_at)->diffForHumans(),
|
||||||
'deleted_at' => $this->deleted_at,
|
'deleted_at' => $this->deleted_at,
|
||||||
/*'updated_at' => format_date(
|
/*'updated_at' => format_date(
|
||||||
set_time_by_user_timezone($this->updated_at), __t('time')
|
set_time_by_user_timezone($this->updated_at), __t('time')
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Folders\Controllers;
|
namespace Domain\Folders\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Domain\Folders\Resources\FolderResource;
|
use Domain\Folders\Resources\FolderResource;
|
||||||
@@ -22,13 +21,13 @@ class CreateFolderController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
CreateFolderRequest $request,
|
CreateFolderRequest $request,
|
||||||
): Response | array {
|
): Response {
|
||||||
// If is demo, return fake folder
|
if (is_demo_account()) {
|
||||||
if (is_demo_account(Auth::user()->email)) {
|
$fakeFolder = ($this->fakeCreateFolder)($request);
|
||||||
return ($this->fakeCreateFolder)($request);
|
|
||||||
|
return response(new FolderResource($fakeFolder), 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateFolder
|
|
||||||
$folder = ($this->createFolder)($request);
|
$folder = ($this->createFolder)($request);
|
||||||
|
|
||||||
return response(new FolderResource($folder), 201);
|
return response(new FolderResource($folder), 201);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Folders\Controllers;
|
namespace Domain\Folders\Controllers;
|
||||||
|
|
||||||
use Domain\Folders\Models\Folder;
|
use Domain\Folders\Models\Folder;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class VisitorCreateFolderController extends Controller
|
|||||||
CreateFolderRequest $request,
|
CreateFolderRequest $request,
|
||||||
Share $shared,
|
Share $shared,
|
||||||
): Response | array {
|
): Response | array {
|
||||||
if (is_demo_account($shared->user->email)) {
|
if (is_demo_account()) {
|
||||||
return ($this->fakeCreateFolderAction)($request);
|
return ($this->fakeCreateFolderAction)($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class Folder extends Model
|
|||||||
*/
|
*/
|
||||||
public function files(): HasMany
|
public function files(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(File::class, 'folder_id', 'id');
|
return $this->hasMany(File::class, 'parent_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +137,7 @@ class Folder extends Model
|
|||||||
*/
|
*/
|
||||||
public function trashedFiles(): HasMany
|
public function trashedFiles(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(File::class, 'folder_id', 'id')
|
return $this->hasMany(File::class, 'parent_id', 'id')
|
||||||
->withTrashed();
|
->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,12 +187,12 @@ class Folder extends Model
|
|||||||
|
|
||||||
public function teamInvitations(): HasMany
|
public function teamInvitations(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(TeamFolderInvitation::class, 'folder_id', 'id');
|
return $this->hasMany(TeamFolderInvitation::class, 'parent_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function teamMembers(): BelongsToMany
|
public function teamMembers(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(User::class, 'team_folder_members', 'folder_id', 'user_id')
|
return $this->belongsToMany(User::class, 'team_folder_members', 'parent_id', 'user_id')
|
||||||
->withPivot('permission');
|
->withPivot('permission');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,10 +206,20 @@ class Folder extends Model
|
|||||||
return $this->parents()->with('teamRoot');
|
return $this->parents()->with('teamRoot');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLatestParent()
|
||||||
|
{
|
||||||
|
if ($this->parent) {
|
||||||
|
return $this->parent->getLatestParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function toSearchableArray(): array
|
public function toSearchableArray(): array
|
||||||
{
|
{
|
||||||
$name = mb_convert_encoding(
|
$name = mb_convert_encoding(
|
||||||
mb_strtolower($this->name, 'UTF-8'), 'UTF-8'
|
mb_strtolower($this->name, 'UTF-8'),
|
||||||
|
'UTF-8'
|
||||||
);
|
);
|
||||||
|
|
||||||
$trigram = (new TNTIndexer)
|
$trigram = (new TNTIndexer)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace Domain\Items\Actions;
|
namespace Domain\Items\Actions;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
|
use Gate;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Domain\Files\Models\File;
|
use Domain\Files\Models\File;
|
||||||
use Domain\Sharing\Models\Share;
|
use Domain\Sharing\Models\Share;
|
||||||
@@ -25,6 +26,8 @@ class DeleteFileOrFolderAction
|
|||||||
->with('folders')
|
->with('folders')
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
|
Gate::authorize('can-edit', [$folder, $shared]);
|
||||||
|
|
||||||
// Get folder shared record
|
// Get folder shared record
|
||||||
$shared = Share::where('type', 'folder')
|
$shared = Share::where('type', 'folder')
|
||||||
->where('item_id', $id)
|
->where('item_id', $id)
|
||||||
@@ -37,7 +40,7 @@ class DeleteFileOrFolderAction
|
|||||||
|
|
||||||
// Remove folder from user favourites
|
// Remove folder from user favourites
|
||||||
DB::table('favourite_folder')
|
DB::table('favourite_folder')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
// Soft delete items
|
// Soft delete items
|
||||||
@@ -53,7 +56,7 @@ class DeleteFileOrFolderAction
|
|||||||
|
|
||||||
// Get children files
|
// Get children files
|
||||||
$files = File::onlyTrashed()
|
$files = File::onlyTrashed()
|
||||||
->whereIn('folder_id', Arr::flatten([$id, $child_folders]))
|
->whereIn('parent_id', Arr::flatten([$id, $child_folders]))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
// Remove all children files
|
// Remove all children files
|
||||||
@@ -83,6 +86,8 @@ class DeleteFileOrFolderAction
|
|||||||
$file = File::withTrashed()
|
$file = File::withTrashed()
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
|
Gate::authorize('can-edit', [$file, $shared]);
|
||||||
|
|
||||||
// Get folder shared record
|
// Get folder shared record
|
||||||
$shared = Share::where('type', 'file')
|
$shared = Share::where('type', 'file')
|
||||||
->where('item_id', $id)
|
->where('item_id', $id)
|
||||||
|
|||||||
@@ -1,28 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Items\Actions;
|
namespace Domain\Items\Actions;
|
||||||
|
|
||||||
use Domain\Files\Models\File;
|
use Domain\Sharing\Models\Share;
|
||||||
use Domain\Folders\Models\Folder;
|
use Gate;
|
||||||
|
|
||||||
class MoveFileOrFolderAction
|
class MoveFileOrFolderAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Move folder or file to new location
|
* Move folder or file to new location
|
||||||
*/
|
*/
|
||||||
public function __invoke($request, ?string $to_id): void
|
public function __invoke($request, ?Share $share = null): void
|
||||||
{
|
{
|
||||||
foreach ($request->items as $item) {
|
foreach ($request->input('items') as $item) {
|
||||||
// Move folder
|
|
||||||
if ($item['type'] === 'folder') {
|
$item = get_item($item['type'], $item['id']);
|
||||||
Folder::find($item['id'])
|
|
||||||
->update(['parent_id' => $to_id]);
|
Gate::authorize('can-edit', [$item, $share]);
|
||||||
}
|
|
||||||
|
|
||||||
// Move file
|
$item->update([
|
||||||
if ($item['type'] !== 'folder') {
|
'parent_id' => $request->input('to_id'),
|
||||||
File::find($item['id'])
|
]);
|
||||||
->update(['folder_id' => $to_id]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Items\Actions;
|
namespace Domain\Items\Actions;
|
||||||
|
|
||||||
|
use Gate;
|
||||||
|
use Domain\Files\Models\File;
|
||||||
|
use Domain\Sharing\Models\Share;
|
||||||
|
use Domain\Folders\Models\Folder;
|
||||||
use Domain\Items\Requests\RenameItemRequest;
|
use Domain\Items\Requests\RenameItemRequest;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
|
||||||
class RenameFileOrFolderAction
|
class RenameFileOrFolderAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Rename item name
|
* Rename item name
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
RenameItemRequest $request,
|
RenameItemRequest $request,
|
||||||
string $id,
|
string $id,
|
||||||
) {
|
?Share $shared = null,
|
||||||
// Get item
|
): File | Folder {
|
||||||
$item = get_item($request->input('type'), $id);
|
$item = get_item($request->input('type'), $id);
|
||||||
|
|
||||||
// Rename item
|
Gate::authorize('can-edit', [$item, $shared]);
|
||||||
|
|
||||||
$item->update([
|
$item->update([
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Items\Controllers;
|
namespace Domain\Items\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Domain\Items\Requests\DeleteItemRequest;
|
use Domain\Items\Requests\DeleteItemRequest;
|
||||||
@@ -20,11 +19,9 @@ class DeleteFileOrFolderController extends Controller
|
|||||||
public function __invoke(
|
public function __invoke(
|
||||||
DeleteItemRequest $request,
|
DeleteItemRequest $request,
|
||||||
): Response {
|
): Response {
|
||||||
abort_if(
|
if (is_demo_account()) {
|
||||||
is_demo_account(Auth::user()?->email),
|
abort(204, 'Done.');
|
||||||
204,
|
}
|
||||||
'Done.'
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($request->input('items') as $item) {
|
foreach ($request->input('items') as $item) {
|
||||||
($this->deleteFileOrFolder)($item, $item['id']);
|
($this->deleteFileOrFolder)($item, $item['id']);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Items\Controllers;
|
namespace Domain\Items\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Domain\Items\Requests\MoveItemRequest;
|
use Domain\Items\Requests\MoveItemRequest;
|
||||||
@@ -20,15 +19,12 @@ class MoveFileOrFolderController extends Controller
|
|||||||
public function __invoke(
|
public function __invoke(
|
||||||
MoveItemRequest $request,
|
MoveItemRequest $request,
|
||||||
): Response {
|
): Response {
|
||||||
abort_if(
|
if (is_demo_account()) {
|
||||||
is_demo_account(Auth::user()?->email),
|
abort(204, 'Done.');
|
||||||
204,
|
}
|
||||||
'Done.'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Move item
|
($this->moveFileOrFolder)($request);
|
||||||
($this->moveFileOrFolder)($request, $request->input('to_id'));
|
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Domain\Items\Controllers;
|
namespace Domain\Items\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Domain\Files\Resources\FileResource;
|
use Domain\Files\Resources\FileResource;
|
||||||
use Domain\Folders\Resources\FolderResource;
|
use Domain\Folders\Resources\FolderResource;
|
||||||
@@ -26,7 +25,7 @@ class RenameFileOrFolderController extends Controller
|
|||||||
RenameItemRequest $request,
|
RenameItemRequest $request,
|
||||||
string $id,
|
string $id,
|
||||||
): FileResource | FolderResource | array {
|
): FileResource | FolderResource | array {
|
||||||
if (is_demo_account(Auth::user()->email)) {
|
if (is_demo_account()) {
|
||||||
return ($this->fakeRenameFileOrFolder)($request, $id);
|
return ($this->fakeRenameFileOrFolder)($request, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ class RenameFileOrFolderController extends Controller
|
|||||||
return new FolderResource($item);
|
return new FolderResource($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return updated item
|
|
||||||
return new FileResource($item);
|
return new FileResource($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ class VisitorDeleteFileOrFolderController extends Controller
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private DeleteFileOrFolderAction $deleteFileOrFolder,
|
private DeleteFileOrFolderAction $deleteFileOrFolder,
|
||||||
private ProtectShareRecordAction $protectShareRecord,
|
|
||||||
private VerifyAccessToItemAction $verifyAccessToItem,
|
private VerifyAccessToItemAction $verifyAccessToItem,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -25,14 +24,9 @@ class VisitorDeleteFileOrFolderController extends Controller
|
|||||||
DeleteItemRequest $request,
|
DeleteItemRequest $request,
|
||||||
Share $shared,
|
Share $shared,
|
||||||
): Response {
|
): Response {
|
||||||
abort_if(
|
if (is_demo_account()) {
|
||||||
is_demo_account($shared->user->email),
|
abort(204, 'Done.');
|
||||||
204,
|
}
|
||||||
'Done.'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check ability to access protected share record
|
|
||||||
($this->protectShareRecord)($shared);
|
|
||||||
|
|
||||||
// Check shared permission
|
// Check shared permission
|
||||||
if (is_visitor($shared)) {
|
if (is_visitor($shared)) {
|
||||||
@@ -47,7 +41,7 @@ class VisitorDeleteFileOrFolderController extends Controller
|
|||||||
if ($file['type'] === 'folder') {
|
if ($file['type'] === 'folder') {
|
||||||
($this->verifyAccessToItem)($item->id, $shared);
|
($this->verifyAccessToItem)($item->id, $shared);
|
||||||
} else {
|
} else {
|
||||||
($this->verifyAccessToItem)($item->folder_id, $shared);
|
($this->verifyAccessToItem)($item->parent_id, $shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete item
|
// Delete item
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class VisitorMoveFileOrFolderController extends Controller
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private MoveFileOrFolderAction $moveFileOrFolder,
|
private MoveFileOrFolderAction $moveFileOrFolder,
|
||||||
private ProtectShareRecordAction $protectShareRecord,
|
|
||||||
private VerifyAccessToItemAction $verifyAccessToItem,
|
private VerifyAccessToItemAction $verifyAccessToItem,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -26,14 +25,9 @@ class VisitorMoveFileOrFolderController extends Controller
|
|||||||
MoveItemRequest $request,
|
MoveItemRequest $request,
|
||||||
Share $shared,
|
Share $shared,
|
||||||
): Response {
|
): Response {
|
||||||
abort_if(
|
if (is_demo_account()) {
|
||||||
is_demo_account($shared->user->email),
|
abort(204, 'Done.');
|
||||||
204,
|
}
|
||||||
'Done.'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check ability to access protected share record
|
|
||||||
($this->protectShareRecord)($shared);
|
|
||||||
|
|
||||||
// Check shared permission
|
// Check shared permission
|
||||||
if (is_visitor($shared)) {
|
if (is_visitor($shared)) {
|
||||||
@@ -53,13 +47,13 @@ class VisitorMoveFileOrFolderController extends Controller
|
|||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
($this->verifyAccessToItem)([
|
($this->verifyAccessToItem)([
|
||||||
$request->input('to_id'), $file->folder_id,
|
$request->input('to_id'), $file->parent_id,
|
||||||
], $shared);
|
], $shared);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
($this->moveFileOrFolder)($request, $request->to_id);
|
($this->moveFileOrFolder)($request, $shared);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use Domain\Files\Resources\FileResource;
|
|||||||
use Domain\Folders\Resources\FolderResource;
|
use Domain\Folders\Resources\FolderResource;
|
||||||
use Domain\Items\Requests\RenameItemRequest;
|
use Domain\Items\Requests\RenameItemRequest;
|
||||||
use Domain\Items\Actions\RenameFileOrFolderAction;
|
use Domain\Items\Actions\RenameFileOrFolderAction;
|
||||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
|
||||||
use Domain\Sharing\Actions\VerifyAccessToItemAction;
|
use Domain\Sharing\Actions\VerifyAccessToItemAction;
|
||||||
use Domain\Folders\Actions\UpdateFolderPropertyAction;
|
use Domain\Folders\Actions\UpdateFolderPropertyAction;
|
||||||
use Support\Demo\Actions\FakeRenameFileOrFolderAction;
|
use Support\Demo\Actions\FakeRenameFileOrFolderAction;
|
||||||
@@ -20,7 +19,6 @@ class VisitorRenameFileOrFolderController extends Controller
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private RenameFileOrFolderAction $renameFileOrFolder,
|
private RenameFileOrFolderAction $renameFileOrFolder,
|
||||||
private ProtectShareRecordAction $protectShareRecord,
|
|
||||||
private VerifyAccessToItemAction $verifyAccessToItem,
|
private VerifyAccessToItemAction $verifyAccessToItem,
|
||||||
private UpdateFolderPropertyAction $updateFolderProperty,
|
private UpdateFolderPropertyAction $updateFolderProperty,
|
||||||
private FakeRenameFileOrFolderAction $fakeRenameFileOrFolder,
|
private FakeRenameFileOrFolderAction $fakeRenameFileOrFolder,
|
||||||
@@ -33,13 +31,10 @@ class VisitorRenameFileOrFolderController extends Controller
|
|||||||
Share $shared,
|
Share $shared,
|
||||||
): Response | array {
|
): Response | array {
|
||||||
// Return fake renamed item in demo
|
// Return fake renamed item in demo
|
||||||
if (is_demo_account($shared->user->email)) {
|
if (is_demo_account()) {
|
||||||
return ($this->fakeRenameFileOrFolder)($request, $id);
|
return ($this->fakeRenameFileOrFolder)($request, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check ability to access protected share record
|
|
||||||
($this->protectShareRecord)($shared);
|
|
||||||
|
|
||||||
// Check shared permission
|
// Check shared permission
|
||||||
if (is_visitor($shared)) {
|
if (is_visitor($shared)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
@@ -52,7 +47,7 @@ class VisitorRenameFileOrFolderController extends Controller
|
|||||||
if ($request->input('type') === 'folder') {
|
if ($request->input('type') === 'folder') {
|
||||||
($this->verifyAccessToItem)($item->id, $shared);
|
($this->verifyAccessToItem)($item->id, $shared);
|
||||||
} else {
|
} else {
|
||||||
($this->verifyAccessToItem)($item->folder_id, $shared);
|
($this->verifyAccessToItem)($item->parent_id, $shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If request have a change folder icon values set the folder icon
|
// If request have a change folder icon values set the folder icon
|
||||||
@@ -61,7 +56,7 @@ class VisitorRenameFileOrFolderController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rename item
|
// Rename item
|
||||||
$item = ($this->renameFileOrFolder)($request, $id);
|
$item = ($this->renameFileOrFolder)($request, $id, $shared);
|
||||||
|
|
||||||
// Set public url
|
// Set public url
|
||||||
if ($request->input('type') !== 'folder') {
|
if ($request->input('type') !== 'folder') {
|
||||||
|
|||||||
@@ -139,6 +139,6 @@ class PaymentMethodsController extends Controller
|
|||||||
"default-payment-methods-user-{$user->id}",
|
"default-payment-methods-user-{$user->id}",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,6 @@ class PlansController extends Controller
|
|||||||
// Clear cached plans
|
// Clear cached plans
|
||||||
cache_forget_many(['plans', 'pricing']);
|
cache_forget_many(['plans', 'pricing']);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ class VerifyAccessToItemAction
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
// Get all authorized parent folders by shared folder as root of tree
|
// Get all authorized parent folders by shared folder as root of tree
|
||||||
$accessible_folder_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
$accessible_parent_ids = Arr::flatten([filter_folders_ids($foldersIds), $shared->item_id]);
|
||||||
|
|
||||||
// Check user access
|
// Check user access
|
||||||
if (is_array($requested_id)) {
|
if (is_array($requested_id)) {
|
||||||
foreach ($requested_id as $id) {
|
foreach ($requested_id as $id) {
|
||||||
if (! in_array($id, $accessible_folder_ids)) {
|
if (! in_array($id, $accessible_parent_ids)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_array($requested_id)) {
|
if (! is_array($requested_id)) {
|
||||||
if (! in_array($requested_id, $accessible_folder_ids)) {
|
if (! in_array($requested_id, $accessible_parent_ids)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class VerifyAccessToItemWithinAction
|
|||||||
): void {
|
): void {
|
||||||
// Check by parent folder permission
|
// Check by parent folder permission
|
||||||
if ($shared->type === 'folder') {
|
if ($shared->type === 'folder') {
|
||||||
($this->verifyAccessToItem)($file->folder_id, $shared);
|
($this->verifyAccessToItem)($file->parent_id, $shared);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check by single file permission
|
// Check by single file permission
|
||||||
|
|||||||
@@ -84,6 +84,6 @@ class ShareController extends Controller
|
|||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ class ShareViaEmailController extends Controller
|
|||||||
token: $token,
|
token: $token,
|
||||||
);
|
);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class SubscriptionCancelController extends Controller
|
|||||||
|
|
||||||
// Check if is demo
|
// Check if is demo
|
||||||
if (is_demo_account($user->email)) {
|
if (is_demo_account($user->email)) {
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel subscription
|
// Cancel subscription
|
||||||
@@ -26,6 +26,6 @@ class SubscriptionCancelController extends Controller
|
|||||||
// Forget user subscription
|
// Forget user subscription
|
||||||
Cache::forget("subscription-user-{$user->id}");
|
Cache::forget("subscription-user-{$user->id}");
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class SubscriptionResumeController extends Controller
|
|||||||
|
|
||||||
// Check if is demo
|
// Check if is demo
|
||||||
if (is_demo_account($user->email)) {
|
if (is_demo_account($user->email)) {
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resume subscription
|
// Resume subscription
|
||||||
@@ -26,6 +26,6 @@ class SubscriptionResumeController extends Controller
|
|||||||
// Forget user subscription
|
// Forget user subscription
|
||||||
Cache::forget("subscription-user-{$user->id}");
|
Cache::forget("subscription-user-{$user->id}");
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SubscriptionUpgradeController extends Controller
|
|||||||
|
|
||||||
// Check if is demo
|
// Check if is demo
|
||||||
if (is_demo_account($user->email)) {
|
if (is_demo_account($user->email)) {
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forget user subscription
|
// Forget user subscription
|
||||||
@@ -53,6 +53,6 @@ class SubscriptionUpgradeController extends Controller
|
|||||||
'storage_capacity' => $plan['product']['metadata']['capacity'],
|
'storage_capacity' => $plan['product']['metadata']['capacity'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
namespace Domain\Teams\Actions;
|
namespace Domain\Teams\Actions;
|
||||||
|
|
||||||
use Domain\Folders\Models\Folder;
|
use Domain\Folders\Models\Folder;
|
||||||
|
use Spatie\QueueableAction\QueueableAction;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Domain\Teams\Models\TeamFolderInvitation;
|
use Domain\Teams\Models\TeamFolderInvitation;
|
||||||
use Domain\Teams\Notifications\InvitationIntoTeamFolder;
|
use Domain\Teams\Notifications\InvitationIntoTeamFolder;
|
||||||
use Spatie\QueueableAction\QueueableAction;
|
|
||||||
|
|
||||||
class InviteMembersIntoTeamFolderAction
|
class InviteMembersIntoTeamFolderAction
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ class InviteMembersIntoTeamFolderAction
|
|||||||
$invitation = TeamFolderInvitation::create([
|
$invitation = TeamFolderInvitation::create([
|
||||||
'permission' => $member['permission'],
|
'permission' => $member['permission'],
|
||||||
'email' => $member['email'],
|
'email' => $member['email'],
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Invite user
|
// Invite user
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class UpdateInvitationsAction
|
|||||||
// Delete invite from team folder
|
// Delete invite from team folder
|
||||||
if ($removed->isNotEmpty()) {
|
if ($removed->isNotEmpty()) {
|
||||||
DB::table('team_folder_invitations')
|
DB::table('team_folder_invitations')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->whereIn('email', $removed)
|
->whereIn('email', $removed)
|
||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ class UpdateInvitationsAction
|
|||||||
->each(
|
->each(
|
||||||
fn ($invitation) =>
|
fn ($invitation) =>
|
||||||
DB::table('team_folder_invitations')
|
DB::table('team_folder_invitations')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->where('email', $invitation['email'])
|
->where('email', $invitation['email'])
|
||||||
->update([
|
->update([
|
||||||
'permission' => $invitation['permission'],
|
'permission' => $invitation['permission'],
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class UpdateMembersAction
|
|||||||
// Remove team members from team folder
|
// Remove team members from team folder
|
||||||
if ($deletedMembers->isNotEmpty()) {
|
if ($deletedMembers->isNotEmpty()) {
|
||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->whereIn('user_id', $deletedMembers->toArray())
|
->whereIn('user_id', $deletedMembers->toArray())
|
||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ class UpdateMembersAction
|
|||||||
->each(
|
->each(
|
||||||
fn ($member) =>
|
fn ($member) =>
|
||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->where('user_id', $member['id'])
|
->where('user_id', $member['id'])
|
||||||
->update([
|
->update([
|
||||||
'permission' => $member['permission'],
|
'permission' => $member['permission'],
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class BrowseSharedWithMeController
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
$files = File::with($relations)
|
$files = File::with($relations)
|
||||||
->where('folder_id', $id)
|
->where('parent_id', $id)
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ class BrowseSharedWithMeController
|
|||||||
if (! $rootId) {
|
if (! $rootId) {
|
||||||
$folderIds = DB::table('team_folder_members')
|
$folderIds = DB::table('team_folder_members')
|
||||||
->where('user_id', Auth::id())
|
->where('user_id', Auth::id())
|
||||||
->pluck('folder_id');
|
->pluck('parent_id');
|
||||||
|
|
||||||
$folders = Folder::with($relations)
|
$folders = Folder::with($relations)
|
||||||
->whereIn('id', $folderIds)
|
->whereIn('id', $folderIds)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class InvitationsController extends Controller
|
|||||||
|
|
||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
'folder_id' => $invitation->folder_id,
|
'parent_id' => $invitation->parent_id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class TeamFoldersController extends Controller
|
|||||||
: $requestedFolder;
|
: $requestedFolder;
|
||||||
|
|
||||||
// Get files
|
// Get files
|
||||||
$files = File::where('folder_id', $rootId)
|
$files = File::where('parent_id', $rootId)
|
||||||
->where('user_id', Auth::id())
|
->where('user_id', Auth::id())
|
||||||
->sortable()
|
->sortable()
|
||||||
->get();
|
->get();
|
||||||
@@ -109,12 +109,12 @@ class TeamFoldersController extends Controller
|
|||||||
{
|
{
|
||||||
// Delete existing invitations
|
// Delete existing invitations
|
||||||
DB::table('team_folder_invitations')
|
DB::table('team_folder_invitations')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
// Delete attached members from folder
|
// Delete attached members from folder
|
||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->where('folder_id', $folder->id)
|
->where('parent_id', $folder->id)
|
||||||
->delete();
|
->delete();
|
||||||
|
|
||||||
$folder->update([
|
$folder->update([
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
/**
|
/**
|
||||||
* @method static create(array $array)
|
* @method static create(array $array)
|
||||||
* @property string id
|
* @property string id
|
||||||
* @property string folder_id
|
* @property string parent_id
|
||||||
* @property string email
|
* @property string email
|
||||||
* @property string status
|
* @property string status
|
||||||
* @property string created_at
|
* @property string created_at
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ class DumpTrashController extends Controller
|
|||||||
public function __invoke(): Response
|
public function __invoke(): Response
|
||||||
{
|
{
|
||||||
abort_if(
|
abort_if(
|
||||||
is_demo_account(Auth::user()->email),
|
is_demo_account(auth()->user()->email),
|
||||||
204,
|
204,
|
||||||
'Done!'
|
'Done.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$user_id = Auth::id();
|
$user_id = Auth::id();
|
||||||
@@ -47,6 +47,6 @@ class DumpTrashController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return response
|
// Return response
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class RestoreTrashContentController extends Controller
|
|||||||
|
|
||||||
// Restore item to home directory
|
// Restore item to home directory
|
||||||
if ($request->has('to_home') && $request->to_home) {
|
if ($request->has('to_home') && $request->to_home) {
|
||||||
$item->folder_id = null;
|
$item->parent_id = null;
|
||||||
$item->save();
|
$item->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,6 @@ class RestoreTrashContentController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return response
|
// Return response
|
||||||
return response('Done!', 204);
|
return response('Done.', 204);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class VisitorZipController extends Controller
|
|||||||
$file_parent_folders = File::whereUserId($shared->user_id)
|
$file_parent_folders = File::whereUserId($shared->user_id)
|
||||||
->whereIn('id', $files->pluck('id'))
|
->whereIn('id', $files->pluck('id'))
|
||||||
->get()
|
->get()
|
||||||
->pluck('folder_id')
|
->pluck('parent_id')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
// Check access to requested directory
|
// Check access to requested directory
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
namespace Domain\Zip\Controllers;
|
namespace Domain\Zip\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use STS\ZipStream\ZipStream;
|
|
||||||
use Domain\Zip\Actions\ZipAction;
|
use Domain\Zip\Actions\ZipAction;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -20,18 +19,16 @@ class ZipController extends Controller
|
|||||||
|
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
Request $request,
|
Request $request,
|
||||||
): ZipStream {
|
): \ZipStream\ZipStream {
|
||||||
$user_id = Auth::id();
|
|
||||||
|
|
||||||
// Get list of folders and files from requested url parameter
|
// Get list of folders and files from requested url parameter
|
||||||
list($folders, $files) = ($this->getItemsListFromUrlParam)($user_id);
|
list($folders, $files) = ($this->getItemsListFromUrlParam)(auth()->id());
|
||||||
|
|
||||||
// Zip items
|
// Zip items
|
||||||
$zip = ($this->zip)($folders, $files);
|
$zip = ($this->zip)($folders, $files);
|
||||||
|
|
||||||
($this->recordDownload)(
|
($this->recordDownload)(
|
||||||
file_size: $zip->predictZipSize(),
|
file_size: $zip->predictZipSize(),
|
||||||
user_id: $user_id,
|
user_id: auth()->id(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $zip;
|
return $zip;
|
||||||
|
|||||||
@@ -1,29 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Support\Demo\Actions;
|
namespace Support\Demo\Actions;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Domain\Folders\Models\Folder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
class FakeCreateFolderAction
|
class FakeCreateFolderAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create new directory
|
* Create new fake folder
|
||||||
*/
|
*/
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
Request $request
|
Request $request
|
||||||
): array {
|
): Collection | Model {
|
||||||
return [
|
return Folder::factory()
|
||||||
'user_id' => 1,
|
->make([
|
||||||
'id' => Str::uuid(),
|
'name' => $request->input('name'),
|
||||||
'parent_id' => random_int(1000, 9999),
|
'author' => $request->user() ? 'user' : 'visitor',
|
||||||
'name' => $request->input('name'),
|
'color' => $request->input('icon.color') ?? null,
|
||||||
'type' => 'folder',
|
'emoji' => $request->input('icon.emoji') ?? null,
|
||||||
'author' => $request->user() ? 'user' : 'visitor',
|
'updated_at' => now()->format(__t('time')),
|
||||||
'items' => '0',
|
'created_at' => now()->format(__t('time')),
|
||||||
'color' => $request->input('icon.color') ?? null,
|
]);
|
||||||
'emoji' => $request->input('icon.emoji') ?? null,
|
|
||||||
'updated_at' => now()->format(__t('time')),
|
|
||||||
'created_at' => now()->format(__t('time')),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class FakeUploadFileAction
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => Str::uuid(),
|
'id' => Str::uuid(),
|
||||||
'folder_id' => $request->input('parent_id'),
|
'parent_id' => $request->input('parent_id'),
|
||||||
'thumbnail' => $thumbnail,
|
'thumbnail' => $thumbnail,
|
||||||
'name' => $file->getClientOriginalName(),
|
'name' => $file->getClientOriginalName(),
|
||||||
'basename' => $filename,
|
'basename' => $filename,
|
||||||
|
|||||||
@@ -251,14 +251,11 @@ if (! function_exists('is_demo')) {
|
|||||||
|
|
||||||
if (! function_exists('is_demo_account')) {
|
if (! function_exists('is_demo_account')) {
|
||||||
/**
|
/**
|
||||||
* Check if is demo
|
* Check if is demo environment
|
||||||
*
|
|
||||||
* @param $email
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
function is_demo_account($email)
|
function is_demo_account(): bool
|
||||||
{
|
{
|
||||||
return config('vuefilemanager.is_demo') && $email === 'howdy@hi5ve.digital';
|
return config('vuefilemanager.is_demo') && auth()->user()->email === 'howdy@hi5ve.digital';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,9 +556,9 @@ if (! function_exists('filter_folders_ids')) {
|
|||||||
*/
|
*/
|
||||||
function filter_folders_ids($folders, $by_column = 'id')
|
function filter_folders_ids($folders, $by_column = 'id')
|
||||||
{
|
{
|
||||||
$folder_ids = recursiveFind($folders->toArray(), $by_column);
|
$parent_ids = recursiveFind($folders->toArray(), $by_column);
|
||||||
|
|
||||||
return appeared_once($folder_ids);
|
return appeared_once($parent_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class PersonalAccessTokenTest extends TestCase
|
|||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$token = $user->createToken('token')->plainTextToken;
|
$token = $user->createToken('token')->plainTextToken;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class UserAccountTest extends TestCase
|
|||||||
->assertExists('files/' . User::first()->id);
|
->assertExists('files/' . User::first()->id);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @test
|
* todo: finish test
|
||||||
*/
|
*/
|
||||||
public function it_test_user_timezone()
|
public function it_test_user_timezone()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class AdminTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ class BrowseTest extends TestCase
|
|||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertExactJson([
|
->assertExactJson([
|
||||||
[
|
[
|
||||||
'name' => 'Files',
|
'location' => 'files',
|
||||||
'folders' => [
|
'name' => 'Files',
|
||||||
|
'folders' => [
|
||||||
[
|
[
|
||||||
'id' => $folder_level_1->id,
|
'id' => $folder_level_1->id,
|
||||||
'parent_id' => null,
|
'parent_id' => null,
|
||||||
@@ -108,10 +109,13 @@ class BrowseTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'isMovable' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Team Folders',
|
'location' => 'team-folders',
|
||||||
'folders' => [],
|
'name' => 'Team Folders',
|
||||||
|
'folders' => [],
|
||||||
|
'isMovable' => false,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -140,7 +144,7 @@ class BrowseTest extends TestCase
|
|||||||
|
|
||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $root->id,
|
'parent_id' => $root->id,
|
||||||
'name' => 'Document',
|
'name' => 'Document',
|
||||||
'basename' => 'document.pdf',
|
'basename' => 'document.pdf',
|
||||||
'mimetype' => 'application/pdf',
|
'mimetype' => 'application/pdf',
|
||||||
@@ -180,7 +184,7 @@ class BrowseTest extends TestCase
|
|||||||
|
|
||||||
$file_1 = File::factory(File::class)
|
$file_1 = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $root->id,
|
'parent_id' => $root->id,
|
||||||
'name' => 'Document 1',
|
'name' => 'Document 1',
|
||||||
'basename' => 'document-1.pdf',
|
'basename' => 'document-1.pdf',
|
||||||
'mimetype' => 'application/pdf',
|
'mimetype' => 'application/pdf',
|
||||||
@@ -194,7 +198,7 @@ class BrowseTest extends TestCase
|
|||||||
|
|
||||||
$file_2 = File::factory(File::class)
|
$file_2 = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $root->id,
|
'parent_id' => $root->id,
|
||||||
'name' => 'Document 2',
|
'name' => 'Document 2',
|
||||||
'basename' => 'document-2.pdf',
|
'basename' => 'document-2.pdf',
|
||||||
'mimetype' => 'application/pdf',
|
'mimetype' => 'application/pdf',
|
||||||
@@ -235,7 +239,7 @@ class BrowseTest extends TestCase
|
|||||||
|
|
||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'name' => 'Document',
|
'name' => 'Document',
|
||||||
'basename' => 'document.pdf',
|
'basename' => 'document.pdf',
|
||||||
'mimetype' => 'application/pdf',
|
'mimetype' => 'application/pdf',
|
||||||
@@ -247,7 +251,7 @@ class BrowseTest extends TestCase
|
|||||||
|
|
||||||
File::factory(File::class)
|
File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'deleted_at' => now(),
|
'deleted_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class FileTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class FileTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class FileTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(423);
|
])->assertStatus(423);
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ class FileTest extends TestCase
|
|||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(422);
|
])->assertStatus(422);
|
||||||
|
|
||||||
@@ -164,12 +164,14 @@ class FileTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_rename_file()
|
public function it_rename_file()
|
||||||
{
|
{
|
||||||
$file = File::factory(File::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$file = File::factory(File::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->patchJson("/api/rename/{$file->id}", [
|
->patchJson("/api/rename/{$file->id}", [
|
||||||
@@ -191,15 +193,19 @@ class FileTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_move_file_to_another_folder()
|
public function it_move_file_to_another_folder()
|
||||||
{
|
{
|
||||||
$folder = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$file = File::factory(File::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$folder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$file = File::factory(File::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->postJson('/api/move', [
|
->postJson('/api/move', [
|
||||||
@@ -214,7 +220,7 @@ class FileTest extends TestCase
|
|||||||
|
|
||||||
$this->assertDatabaseHas('files', [
|
$this->assertDatabaseHas('files', [
|
||||||
'id' => $file->id,
|
'id' => $file->id,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +234,9 @@ class FileTest extends TestCase
|
|||||||
|
|
||||||
$files = File::factory(File::class)
|
$files = File::factory(File::class)
|
||||||
->count(2)
|
->count(2)
|
||||||
->create();
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
@@ -273,7 +281,7 @@ class FileTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class FavouriteFolderTest extends TestCase
|
|||||||
|
|
||||||
$this->assertDatabaseHas('favourite_folder', [
|
$this->assertDatabaseHas('favourite_folder', [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ class FavouriteFolderTest extends TestCase
|
|||||||
|
|
||||||
$this->assertDatabaseMissing('favourite_folder', [
|
$this->assertDatabaseMissing('favourite_folder', [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,14 @@ class FolderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_rename_folder()
|
public function it_rename_folder()
|
||||||
{
|
{
|
||||||
$folder = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$folder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->patchJson("/api/rename/{$folder->id}", [
|
->patchJson("/api/rename/{$folder->id}", [
|
||||||
@@ -80,12 +82,14 @@ class FolderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_set_folder_emoji()
|
public function it_set_folder_emoji()
|
||||||
{
|
{
|
||||||
$folder = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$folder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$emoji_fragment = [
|
$emoji_fragment = [
|
||||||
'category' => 'Smileys & Emotion (face-smiling)',
|
'category' => 'Smileys & Emotion (face-smiling)',
|
||||||
'char' => '😁',
|
'char' => '😁',
|
||||||
@@ -116,12 +120,14 @@ class FolderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_set_folder_color()
|
public function it_set_folder_color()
|
||||||
{
|
{
|
||||||
$folder = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$folder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->patchJson("/api/rename/{$folder->id}", [
|
->patchJson("/api/rename/{$folder->id}", [
|
||||||
@@ -147,15 +153,19 @@ class FolderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_move_folder_to_another_folder()
|
public function it_move_folder_to_another_folder()
|
||||||
{
|
{
|
||||||
$root = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$children = Folder::factory(Folder::class)
|
|
||||||
->create();
|
|
||||||
|
|
||||||
$user = User::factory(User::class)
|
$user = User::factory(User::class)
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
|
$root = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$children = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
->postJson('/api/move', [
|
->postJson('/api/move', [
|
||||||
@@ -183,10 +193,14 @@ class FolderTest extends TestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$folder_1 = Folder::factory(Folder::class)
|
$folder_1 = Folder::factory(Folder::class)
|
||||||
->create();
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$folder_2 = Folder::factory(Folder::class)
|
$folder_2 = Folder::factory(Folder::class)
|
||||||
->create();
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$user->favouriteFolders()->attach($folder_1->id);
|
$user->favouriteFolders()->attach($folder_1->id);
|
||||||
$user->favouriteFolders()->attach($folder_2->id);
|
$user->favouriteFolders()->attach($folder_2->id);
|
||||||
@@ -215,7 +229,7 @@ class FolderTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertDatabaseMissing('favourite_folder', [
|
$this->assertDatabaseMissing('favourite_folder', [
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -229,10 +243,14 @@ class FolderTest extends TestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$folder_1 = Folder::factory(Folder::class)
|
$folder_1 = Folder::factory(Folder::class)
|
||||||
->create();
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$folder_2 = Folder::factory(Folder::class)
|
$folder_2 = Folder::factory(Folder::class)
|
||||||
->create();
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->actingAs($user)
|
->actingAs($user)
|
||||||
@@ -281,13 +299,13 @@ class FolderTest extends TestCase
|
|||||||
|
|
||||||
$file_1 = File::factory(File::class)
|
$file_1 = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder_root->id,
|
'parent_id' => $folder_root->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$file_2 = File::factory(File::class)
|
$file_2 = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder_children->id,
|
'parent_id' => $folder_children->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -347,7 +365,7 @@ class FolderTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Domain\Sharing;
|
namespace Tests\Domain\Sharing;
|
||||||
|
|
||||||
use Storage;
|
use Storage;
|
||||||
@@ -53,7 +54,7 @@ class VisitorAccessToItemsTest extends TestCase
|
|||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $is_protected) {
|
if (!$is_protected) {
|
||||||
// Get shared file
|
// Get shared file
|
||||||
$this->get("/file/$document->name/$share->token")
|
$this->get("/file/$document->name/$share->token")
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
@@ -66,10 +67,21 @@ class VisitorAccessToItemsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_try_to_get_protected_file_record()
|
public function it_try_to_get_protected_file_record()
|
||||||
{
|
{
|
||||||
|
$user = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$file = File::factory(File::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'name' => 'fake-thumbnail.jpg',
|
||||||
|
]);
|
||||||
|
|
||||||
$share = Share::factory(Share::class)
|
$share = Share::factory(Share::class)
|
||||||
->create([
|
->create([
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'is_protected' => true,
|
'is_protected' => true,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'item_id' => $file->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get share record
|
// Get share record
|
||||||
@@ -123,7 +135,7 @@ class VisitorAccessToItemsTest extends TestCase
|
|||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $is_protected) {
|
if (!$is_protected) {
|
||||||
$this->get("/share/$share->token")
|
$this->get("/share/$share->token")
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
@@ -174,7 +186,7 @@ class VisitorAccessToItemsTest extends TestCase
|
|||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $is_protected) {
|
if (!$is_protected) {
|
||||||
$this->get("/thumbnail/$thumbnail->name/$share->token")
|
$this->get("/thumbnail/$thumbnail->name/$share->token")
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Domain\Sharing;
|
namespace Tests\Domain\Sharing;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -160,7 +159,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
|
|
||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $root->id,
|
'parent_id' => $root->id,
|
||||||
'name' => 'Document',
|
'name' => 'Document',
|
||||||
'basename' => 'document.pdf',
|
'basename' => 'document.pdf',
|
||||||
'mimetype' => 'application/pdf',
|
'mimetype' => 'application/pdf',
|
||||||
@@ -189,7 +188,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check public shared item
|
// Check public shared item
|
||||||
if (!$is_protected) {
|
if (! $is_protected) {
|
||||||
$this->getJson("/api/browse/folders/$root->id/$share->token")
|
$this->getJson("/api/browse/folders/$root->id/$share->token")
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
@@ -304,7 +303,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check public shared item
|
// Check public shared item
|
||||||
if (!$is_protected) {
|
if (! $is_protected) {
|
||||||
$this->getJson("/api/browse/navigation/$share->token")
|
$this->getJson("/api/browse/navigation/$share->token")
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertExactJson($tree);
|
->assertExactJson($tree);
|
||||||
@@ -336,7 +335,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'name' => 'Document',
|
'name' => 'Document',
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $folder->user_id,
|
'user_id' => $folder->user_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -356,7 +355,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check public shared item
|
// Check public shared item
|
||||||
if (!$is_protected) {
|
if (! $is_protected) {
|
||||||
$this->getJson("/api/browse/search/$share->token?query=doc")
|
$this->getJson("/api/browse/search/$share->token?query=doc")
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
@@ -407,7 +406,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check public shared item
|
// Check public shared item
|
||||||
if (!$is_protected) {
|
if (! $is_protected) {
|
||||||
$this->getJson("/api/browse/search/$share->token?query=doc")
|
$this->getJson("/api/browse/search/$share->token?query=doc")
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJsonFragment([]);
|
->assertJsonFragment([]);
|
||||||
@@ -454,7 +453,7 @@ class VisitorBrowseTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check public shared item
|
// Check public shared item
|
||||||
if (!$is_protected) {
|
if (! $is_protected) {
|
||||||
$this->getJson("/api/browse/file/$share->token")
|
$this->getJson("/api/browse/file/$share->token")
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
|
|
||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$share = Share::factory(Share::class)
|
$share = Share::factory(Share::class)
|
||||||
@@ -240,7 +241,8 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
$files = File::factory(File::class)
|
$files = File::factory(File::class)
|
||||||
->count(2)
|
->count(2)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'user_id' => $user->id,
|
||||||
|
'parent_id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
@@ -327,7 +329,7 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
->post("/api/editor/upload/$share->token", [
|
->post("/api/editor/upload/$share->token", [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
}
|
}
|
||||||
@@ -337,7 +339,7 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
$this->postJson("/api/editor/upload/$share->token", [
|
$this->postJson("/api/editor/upload/$share->token", [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
}
|
}
|
||||||
@@ -378,7 +380,7 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
$file = File::factory(File::class)
|
$file = File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'folder_id' => $root->id,
|
'parent_id' => $root->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$share = Share::factory(Share::class)
|
$share = Share::factory(Share::class)
|
||||||
@@ -421,7 +423,7 @@ class VisitorManipulatingTest extends TestCase
|
|||||||
|
|
||||||
$this->assertDatabaseHas('files', [
|
$this->assertDatabaseHas('files', [
|
||||||
'id' => $file->id,
|
'id' => $file->id,
|
||||||
'folder_id' => $children->id,
|
'parent_id' => $children->id,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests\Domain\Spotlight;
|
namespace Tests\Domain\Spotlight;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use Domain\Files\Models\File;
|
use Domain\Files\Models\File;
|
||||||
use Domain\Folders\Models\Folder;
|
use Domain\Folders\Models\Folder;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class SearchTest extends TestCase
|
class SearchTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -36,14 +35,15 @@ class SearchTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
collect([$english, $russian, $turkish])
|
collect([$english, $russian, $turkish])
|
||||||
->each(fn($file) => $this
|
->each(
|
||||||
->actingAs($user)
|
fn ($file) => $this
|
||||||
->getJson('/api/browse/search?query=' . mb_strtolower(mb_substr($file->name, 0, 3)))
|
->actingAs($user)
|
||||||
->assertStatus(200)
|
->getJson('/api/browse/search?query=' . mb_strtolower(mb_substr($file->name, 0, 3)))
|
||||||
->assertJsonFragment([
|
->assertStatus(200)
|
||||||
'id' => $file->id,
|
->assertJsonFragment([
|
||||||
'name' => $file->name,
|
'id' => $file->id,
|
||||||
])
|
'name' => $file->name,
|
||||||
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,4 +69,4 @@ class SearchTest extends TestCase
|
|||||||
'id' => $folder->id,
|
'id' => $folder->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class TeamsTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_find_team_folder_id_from_children()
|
public function it_find_team_parent_id_from_children()
|
||||||
{
|
{
|
||||||
$teamFolder = Folder::factory()
|
$teamFolder = Folder::factory()
|
||||||
->create([
|
->create([
|
||||||
@@ -140,7 +140,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
$invitation = TeamFolderInvitation::factory()
|
$invitation = TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'email' => $member->email,
|
'email' => $member->email,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
@@ -153,11 +153,11 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
$this
|
$this
|
||||||
->assertDatabaseHas('team_folder_invitations', [
|
->assertDatabaseHas('team_folder_invitations', [
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'accepted',
|
'status' => 'accepted',
|
||||||
])
|
])
|
||||||
->assertDatabaseHas('team_folder_members', [
|
->assertDatabaseHas('team_folder_members', [
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $member->id,
|
'user_id' => $member->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
]);
|
]);
|
||||||
@@ -178,7 +178,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
$invitation = TeamFolderInvitation::factory()
|
$invitation = TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'email' => $member->email,
|
'email' => $member->email,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
@@ -191,11 +191,11 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
$this
|
$this
|
||||||
->assertDatabaseHas('team_folder_invitations', [
|
->assertDatabaseHas('team_folder_invitations', [
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'rejected',
|
'status' => 'rejected',
|
||||||
])
|
])
|
||||||
->assertDatabaseMissing('team_folder_members', [
|
->assertDatabaseMissing('team_folder_members', [
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $member->id,
|
'user_id' => $member->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
TeamFolderInvitation::factory()
|
TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
'email' => 'existing@member.com',
|
'email' => 'existing@member.com',
|
||||||
@@ -229,12 +229,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[0]->id,
|
'user_id' => $members[0]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[1]->id,
|
'user_id' => $members[1]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
@@ -299,7 +299,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
TeamFolderInvitation::factory()
|
TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
'email' => 'deleted@member.com',
|
'email' => 'deleted@member.com',
|
||||||
@@ -307,7 +307,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
TeamFolderInvitation::factory()
|
TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
'email' => 'existing@member.com',
|
'email' => 'existing@member.com',
|
||||||
@@ -316,12 +316,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[0]->id,
|
'user_id' => $members[0]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[1]->id,
|
'user_id' => $members[1]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
@@ -379,12 +379,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[0]->id,
|
'user_id' => $members[0]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[1]->id,
|
'user_id' => $members[1]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
@@ -426,7 +426,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
TeamFolderInvitation::factory()
|
TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-view',
|
'permission' => 'can-view',
|
||||||
'email' => 'existing@member.com',
|
'email' => 'existing@member.com',
|
||||||
@@ -478,12 +478,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[0]->id,
|
'user_id' => $members[0]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[1]->id,
|
'user_id' => $members[1]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
@@ -532,7 +532,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
TeamFolderInvitation::factory()
|
TeamFolderInvitation::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'status' => 'pending',
|
'status' => 'pending',
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
]);
|
]);
|
||||||
@@ -540,12 +540,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[0]->id,
|
'user_id' => $members[0]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $members[1]->id,
|
'user_id' => $members[1]->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
@@ -600,7 +600,7 @@ class TeamsTest extends TestCase
|
|||||||
|
|
||||||
$file = File::factory()
|
$file = File::factory()
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -634,12 +634,12 @@ class TeamsTest extends TestCase
|
|||||||
DB::table('team_folder_members')
|
DB::table('team_folder_members')
|
||||||
->insert([
|
->insert([
|
||||||
[
|
[
|
||||||
'folder_id' => $folders[0]->id,
|
'parent_id' => $folders[0]->id,
|
||||||
'user_id' => $member->id,
|
'user_id' => $member->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'folder_id' => $folders[1]->id,
|
'parent_id' => $folders[1]->id,
|
||||||
'user_id' => $member->id,
|
'user_id' => $member->id,
|
||||||
'permission' => 'can-edit',
|
'permission' => 'can-edit',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class TrafficTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $this->file->name,
|
'filename' => $this->file->name,
|
||||||
'file' => $this->file,
|
'file' => $this->file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class TrafficTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $this->file->name,
|
'filename' => $this->file->name,
|
||||||
'file' => $this->file,
|
'file' => $this->file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class TrafficTest extends TestCase
|
|||||||
->postJson('/api/upload', [
|
->postJson('/api/upload', [
|
||||||
'filename' => $secondFile->name,
|
'filename' => $secondFile->name,
|
||||||
'file' => $secondFile,
|
'file' => $secondFile,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ class TrafficTest extends TestCase
|
|||||||
$this->postJson("/api/editor/upload/$share->token", [
|
$this->postJson("/api/editor/upload/$share->token", [
|
||||||
'filename' => $this->file->name,
|
'filename' => $this->file->name,
|
||||||
'file' => $this->file,
|
'file' => $this->file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class TrashTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $image->name,
|
'filename' => $image->name,
|
||||||
'file' => $image,
|
'file' => $image,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class SharedZippingTest extends TestCase
|
|||||||
File::factory(File::class)
|
File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'filesize' => $file->getSize(),
|
'filesize' => $file->getSize(),
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'basename' => $file->name,
|
'basename' => $file->name,
|
||||||
'name' => "fake-file-$index.pdf",
|
'name' => "fake-file-$index.pdf",
|
||||||
@@ -61,7 +61,7 @@ class SharedZippingTest extends TestCase
|
|||||||
File::factory(File::class)
|
File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'filesize' => $file->getSize(),
|
'filesize' => $file->getSize(),
|
||||||
'folder_id' => $sharedFolder->id,
|
'parent_id' => $sharedFolder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'basename' => $file->name,
|
'basename' => $file->name,
|
||||||
'name' => "fake-file-$index.pdf",
|
'name' => "fake-file-$index.pdf",
|
||||||
@@ -122,7 +122,7 @@ class SharedZippingTest extends TestCase
|
|||||||
|
|
||||||
File::factory(File::class)
|
File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class SharedZippingTest extends TestCase
|
|||||||
File::factory(File::class)
|
File::factory(File::class)
|
||||||
->create([
|
->create([
|
||||||
'filesize' => $file->getSize(),
|
'filesize' => $file->getSize(),
|
||||||
'folder_id' => $children->id,
|
'parent_id' => $children->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'basename' => $file->name,
|
'basename' => $file->name,
|
||||||
'name' => "fake-file-$index.pdf",
|
'name' => "fake-file-$index.pdf",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class UserZippingTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
@@ -46,13 +46,13 @@ class UserZippingTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => null,
|
'parent_id' => null,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
|
|
||||||
$files = File::all()
|
$files = File::all()
|
||||||
->where('folder_id', null)
|
->where('parent_id', null)
|
||||||
->pluck('id')
|
->pluck('id')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class UserZippingTest extends TestCase
|
|||||||
$this->postJson('/api/upload', [
|
$this->postJson('/api/upload', [
|
||||||
'filename' => $file->name,
|
'filename' => $file->name,
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'folder_id' => $folder->id,
|
'parent_id' => $folder->id,
|
||||||
'is_last' => 'true',
|
'is_last' => 'true',
|
||||||
])->assertStatus(201);
|
])->assertStatus(201);
|
||||||
});
|
});
|
||||||
|
|||||||
259
tests/Support/Gate/GateTest.php
Normal file
259
tests/Support/Gate/GateTest.php
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Support\Gate;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Users\Models\User;
|
||||||
|
use Domain\Files\Models\File;
|
||||||
|
use Domain\Sharing\Models\Share;
|
||||||
|
use Domain\Folders\Models\Folder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class GateTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function owner_rename_folder()
|
||||||
|
{
|
||||||
|
$user = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$folder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this
|
||||||
|
->actingAs($user)
|
||||||
|
->patchJson("/api/rename/{$folder->id}", [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'type' => 'folder',
|
||||||
|
])
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('folders', [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function guest_rename_folder()
|
||||||
|
{
|
||||||
|
// check private or public share record
|
||||||
|
collect([true, false])
|
||||||
|
->each(function ($is_protected) {
|
||||||
|
$user = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$root = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$children = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'parent_id' => $root->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$share = Share::factory(Share::class)
|
||||||
|
->create([
|
||||||
|
'item_id' => $root->id,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'type' => 'folder',
|
||||||
|
'is_protected' => $is_protected,
|
||||||
|
'permission' => 'editor',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Check shared item protected by password
|
||||||
|
if ($is_protected) {
|
||||||
|
$cookie = ['share_session' => json_encode([
|
||||||
|
'token' => $share->token,
|
||||||
|
'authenticated' => true,
|
||||||
|
])];
|
||||||
|
|
||||||
|
$this
|
||||||
|
->withUnencryptedCookies($cookie)
|
||||||
|
->patch("/api/editor/rename/{$children->id}/$share->token", [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'type' => 'folder',
|
||||||
|
])
|
||||||
|
->assertStatus(201)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check public shared item
|
||||||
|
if (! $is_protected) {
|
||||||
|
$this->patchJson("/api/editor/rename/{$children->id}/$share->token", [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'type' => 'folder',
|
||||||
|
])
|
||||||
|
->assertStatus(201)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('folders', [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'id' => $children->id,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function team_member_with_can_edit_privilege_rename_folder()
|
||||||
|
{
|
||||||
|
$owner = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$member = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$teamFolder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'team_folder' => 1,
|
||||||
|
'name' => 'Team Folder',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$parent = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$children = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'parent_id' => $parent->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::table('team_folder_members')
|
||||||
|
->insert([
|
||||||
|
[
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
'user_id' => $member->id,
|
||||||
|
'permission' => 'can-edit',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this
|
||||||
|
->actingAs($member)
|
||||||
|
->patchJson("/api/rename/{$children->id}", [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'type' => 'folder',
|
||||||
|
])
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function team_member_with_can_visit_privilege_try_rename_folder()
|
||||||
|
{
|
||||||
|
$owner = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$member = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$teamFolder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'team_folder' => 1,
|
||||||
|
'name' => 'Team Folder',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$parent = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$children = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'parent_id' => $parent->id,
|
||||||
|
'name' => 'Captivating',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::table('team_folder_members')
|
||||||
|
->insert([
|
||||||
|
[
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
'user_id' => $member->id,
|
||||||
|
'permission' => 'can-view',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this
|
||||||
|
->actingAs($member)
|
||||||
|
->patchJson("/api/rename/{$children->id}", [
|
||||||
|
'name' => 'Renamed Folder',
|
||||||
|
'type' => 'folder',
|
||||||
|
])
|
||||||
|
->assertStatus(403);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('folders', [
|
||||||
|
'name' => 'Captivating',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function team_member_rename_file()
|
||||||
|
{
|
||||||
|
$owner = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$member = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$teamFolder = Folder::factory(Folder::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'team_folder' => 1,
|
||||||
|
'name' => 'Team Folder',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$file = File::factory(File::class)
|
||||||
|
->create([
|
||||||
|
'user_id' => $owner->id,
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::table('team_folder_members')
|
||||||
|
->insert([
|
||||||
|
[
|
||||||
|
'parent_id' => $teamFolder->id,
|
||||||
|
'user_id' => $member->id,
|
||||||
|
'permission' => 'can-edit',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this
|
||||||
|
->actingAs($member)
|
||||||
|
->patchJson("/api/rename/{$file->id}", [
|
||||||
|
'name' => 'Renamed File',
|
||||||
|
'type' => 'file',
|
||||||
|
])
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'name' => 'Renamed File',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user