mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
- ability leave team folder
- refactoring
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
"/chunks/admin-account~chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/datab~39825672.js": "/chunks/admin-account~chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/datab~39825672.js?id=66fa2c4863d93c8af4a8",
|
||||
"/chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/~3e4fdd8b.js": "/chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~chunks/~3e4fdd8b.js?id=1d731f1c4a9daecb2a99",
|
||||
"/chunks/admin~chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-item~9b68162c.js": "/chunks/admin~chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-item~9b68162c.js?id=5841d65172536a8a9bdc",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.js?id=a99755060794dbdfba72",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.js?id=0babe59e69f432ce0d03",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.js?id=6085eaa6037408097b4a",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.js?id=314e422e80bd946227c6",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~1bec6fe4.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~1bec6fe4.js?id=575db2908a16fbd98d57",
|
||||
"/chunks/admin~chunks/platform.js": "/chunks/admin~chunks/platform.js?id=90270d0c5aeb5c50dacf",
|
||||
"/chunks/admin~chunks/platform~chunks/settings.js": "/chunks/admin~chunks/platform~chunks/settings.js?id=2ceec639f8de0a9a9966",
|
||||
@@ -59,8 +59,8 @@
|
||||
"/chunks/plan-settings.js": "/chunks/plan-settings.js?id=4b3d3d91faa908b876ac",
|
||||
"/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=b5017d712135057283c9",
|
||||
"/chunks/plans.js": "/chunks/plans.js?id=7c1b78c2301824c517ed",
|
||||
"/chunks/platform.js": "/chunks/platform.js?id=984941e8fbad48c84c31",
|
||||
"/chunks/platform~chunks/shared.js": "/chunks/platform~chunks/shared.js?id=6eab13949e690d85a716",
|
||||
"/chunks/platform.js": "/chunks/platform.js?id=1b7f64fc2bc8a29a5252",
|
||||
"/chunks/platform~chunks/shared.js": "/chunks/platform~chunks/shared.js?id=8848a34b4da18ab940a2",
|
||||
"/chunks/profile.js": "/chunks/profile.js?id=0638997b77c6f1246062",
|
||||
"/chunks/profile~chunks/settings-password.js": "/chunks/profile~chunks/settings-password.js?id=58edfb3a35062e1ba4e0",
|
||||
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=3f4199493a8b878c7ece",
|
||||
@@ -75,11 +75,11 @@
|
||||
"/chunks/settings~chunks/settings-password.js": "/chunks/settings~chunks/settings-password.js?id=e67e12955133c57194d1",
|
||||
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=651d5accf401908724c5",
|
||||
"/chunks/shared.js": "/chunks/shared.js?id=4efec0aaa7842ff85c36",
|
||||
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=53c87f0ad28672f3f2ad",
|
||||
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=d83f0d713c1936ada2b0",
|
||||
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=ec0ed66a1216eb60bc6a",
|
||||
"/chunks/shared/files.js": "/chunks/shared/files.js?id=f7d29daa21fc7df5fb8d",
|
||||
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=1f5ef0d9638037a6e659",
|
||||
"/chunks/sign-in.js": "/chunks/sign-in.js?id=6ecc2ce22a17468f5976",
|
||||
"/chunks/sign-in.js": "/chunks/sign-in.js?id=a26cf4decf44433d7f18",
|
||||
"/chunks/sign-up.js": "/chunks/sign-up.js?id=a5d30a11ec0114bcde59",
|
||||
"/chunks/status-check.js": "/chunks/status-check.js?id=b6805d5f5f5035b64fc8",
|
||||
"/chunks/stripe-credentials.js": "/chunks/stripe-credentials.js?id=c3a3069f686efe261a66",
|
||||
@@ -755,5 +755,34 @@
|
||||
"/chunks/platform.40ca1af0128c29ddba55.hot-update.js": "/chunks/platform.40ca1af0128c29ddba55.hot-update.js",
|
||||
"/js/main.78489affcd9a63dcff1b.hot-update.js": "/js/main.78489affcd9a63dcff1b.hot-update.js",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.1ee38cce08f672b31e42.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.1ee38cce08f672b31e42.hot-update.js",
|
||||
"/chunks/invitation.1ee38cce08f672b31e42.hot-update.js": "/chunks/invitation.1ee38cce08f672b31e42.hot-update.js"
|
||||
"/chunks/invitation.1ee38cce08f672b31e42.hot-update.js": "/chunks/invitation.1ee38cce08f672b31e42.hot-update.js",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.bbd458abdd5efc3a56e8.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~673d1ac3.bbd458abdd5efc3a56e8.hot-update.js",
|
||||
"/chunks/platform~chunks/shared.43129c61052cb57ec184.hot-update.js": "/chunks/platform~chunks/shared.43129c61052cb57ec184.hot-update.js",
|
||||
"/chunks/platform~chunks/shared.8beb4072a64988bc6530.hot-update.js": "/chunks/platform~chunks/shared.8beb4072a64988bc6530.hot-update.js",
|
||||
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.b3e8713a2cf4c8b7974d.hot-update.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/settin~97130d1f.b3e8713a2cf4c8b7974d.hot-update.js",
|
||||
"/js/main.c1c1d1b94d7e90fa32c8.hot-update.js": "/js/main.c1c1d1b94d7e90fa32c8.hot-update.js",
|
||||
"/chunks/platform~chunks/shared.3de7bf70620ab893da94.hot-update.js": "/chunks/platform~chunks/shared.3de7bf70620ab893da94.hot-update.js",
|
||||
"/js/main.5acd2019c6af2556e808.hot-update.js": "/js/main.5acd2019c6af2556e808.hot-update.js",
|
||||
"/js/main.23e68d28bb4f265d39ad.hot-update.js": "/js/main.23e68d28bb4f265d39ad.hot-update.js",
|
||||
"/chunks/shared-with-me.23e68d28bb4f265d39ad.hot-update.js": "/chunks/shared-with-me.23e68d28bb4f265d39ad.hot-update.js",
|
||||
"/js/main.1f91d6de692fb7faf623.hot-update.js": "/js/main.1f91d6de692fb7faf623.hot-update.js",
|
||||
"/chunks/platform.1f91d6de692fb7faf623.hot-update.js": "/chunks/platform.1f91d6de692fb7faf623.hot-update.js",
|
||||
"/chunks/shared-with-me.247c86fdc1f3906ed64a.hot-update.js": "/chunks/shared-with-me.247c86fdc1f3906ed64a.hot-update.js",
|
||||
"/chunks/shared-with-me.66566c9328191989f4de.hot-update.js": "/chunks/shared-with-me.66566c9328191989f4de.hot-update.js",
|
||||
"/chunks/shared-with-me.cff971b7817fa2fd0819.hot-update.js": "/chunks/shared-with-me.cff971b7817fa2fd0819.hot-update.js",
|
||||
"/chunks/shared-with-me.d64deac303a2b994950c.hot-update.js": "/chunks/shared-with-me.d64deac303a2b994950c.hot-update.js",
|
||||
"/chunks/shared-with-me.70c2ef513ff17452f2f6.hot-update.js": "/chunks/shared-with-me.70c2ef513ff17452f2f6.hot-update.js",
|
||||
"/chunks/platform~chunks/shared.6d9d004e095a93cb71c7.hot-update.js": "/chunks/platform~chunks/shared.6d9d004e095a93cb71c7.hot-update.js",
|
||||
"/chunks/shared-with-me.b2fab8244cd334de1259.hot-update.js": "/chunks/shared-with-me.b2fab8244cd334de1259.hot-update.js",
|
||||
"/js/main.99290ad8c825c32311f3.hot-update.js": "/js/main.99290ad8c825c32311f3.hot-update.js",
|
||||
"/chunks/shared-with-me.ad44a5ef58d84c6cf522.hot-update.js": "/chunks/shared-with-me.ad44a5ef58d84c6cf522.hot-update.js",
|
||||
"/chunks/shared-with-me.6973baa7013598a61155.hot-update.js": "/chunks/shared-with-me.6973baa7013598a61155.hot-update.js",
|
||||
"/chunks/shared-with-me.2558a81e50a5fa0eadcd.hot-update.js": "/chunks/shared-with-me.2558a81e50a5fa0eadcd.hot-update.js",
|
||||
"/chunks/shared-with-me.77d5a2f61c95dc901b02.hot-update.js": "/chunks/shared-with-me.77d5a2f61c95dc901b02.hot-update.js",
|
||||
"/chunks/shared-with-me.40d3ead66da6931beb9b.hot-update.js": "/chunks/shared-with-me.40d3ead66da6931beb9b.hot-update.js",
|
||||
"/chunks/sign-in.56b746c1fdb0a0688a72.hot-update.js": "/chunks/sign-in.56b746c1fdb0a0688a72.hot-update.js",
|
||||
"/chunks/sign-in.fbddb013e9e1e82ab1cf.hot-update.js": "/chunks/sign-in.fbddb013e9e1e82ab1cf.hot-update.js",
|
||||
"/chunks/sign-in.e4e7a0db85a46a67fff5.hot-update.js": "/chunks/sign-in.e4e7a0db85a46a67fff5.hot-update.js",
|
||||
"/chunks/sign-in.2b90fded6e62db75027b.hot-update.js": "/chunks/sign-in.2b90fded6e62db75027b.hot-update.js",
|
||||
"/chunks/sign-in.1c6cafebef4f2cadf32b.hot-update.js": "/chunks/sign-in.1c6cafebef4f2cadf32b.hot-update.js"
|
||||
}
|
||||
|
||||
@@ -61,10 +61,15 @@
|
||||
<TeamMembersButton @click.stop.native="showTeamFolderMenu" class="team-preview" />
|
||||
<PopoverItem name="team-folder" side="left">
|
||||
<TeamFolderPreview />
|
||||
|
||||
<OptionGroup v-if="$isThisRoute($route, ['TeamFolders'])">
|
||||
<Option @click.native="$updateTeamFolder(teamFolder)" :title="$t('Edit Members')" icon="rename" />
|
||||
<Option @click.native="$dissolveTeamFolder(teamFolder)" :title="$t('Dissolve Team')" icon="trash" />
|
||||
</OptionGroup>
|
||||
|
||||
<OptionGroup v-if="$isThisRoute($route, ['SharedWithMe'])">
|
||||
<Option @click.native="$detachMeFromTeamFolder(teamFolder)" :title="$t('Leave the Team Folder')" icon="user-minus" />
|
||||
</OptionGroup>
|
||||
</PopoverItem>
|
||||
</PopoverWrapper>
|
||||
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
:style="{fill: color}"
|
||||
style="width: 53px; height: 52px"
|
||||
/>
|
||||
<!-- <FontAwesomeIcon
|
||||
v-if="!emoji"
|
||||
:class="[{'is-deleted':isDeleted},{'is-team':item.data.attributes.isTeamFolder},{'default-color': ! color && ! isDeleted}, 'folder-icon' ]"
|
||||
:style="{fill: color}"
|
||||
icon="folder"
|
||||
/>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<users-icon v-if="icon === 'users'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<user-icon v-if="icon === 'user'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<user-plus-icon v-if="icon === 'user-plus'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<user-minus-icon v-if="icon === 'user-minus'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<user-check-icon v-if="icon === 'user-check'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<settings-icon v-if="icon === 'settings'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
<power-icon v-if="icon === 'power'" size="17" class="group-hover-text-theme" :class="{'text-theme': isActive}"/>
|
||||
@@ -50,6 +51,7 @@
|
||||
<script>
|
||||
import AlphabetIcon from '/resources/js/components/FilesView/Icons/AlphabetIcon'
|
||||
import {
|
||||
UserMinusIcon,
|
||||
UserCheckIcon,
|
||||
UserPlusIcon,
|
||||
ArrowUpIcon,
|
||||
@@ -96,6 +98,7 @@ import {
|
||||
'icon'
|
||||
],
|
||||
components: {
|
||||
UserMinusIcon,
|
||||
UserCheckIcon,
|
||||
UserPlusIcon,
|
||||
ArrowUpIcon,
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
&.success {
|
||||
background: $theme_light;
|
||||
|
||||
line {
|
||||
line, polyline {
|
||||
stroke: $theme;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
&.danger {
|
||||
background: rgba($danger, 0.1);
|
||||
|
||||
line {
|
||||
line, polyline {
|
||||
stroke: $danger;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
let route = this.name
|
||||
? `/api/teams/folders`
|
||||
: `/api/teams/convert/${this.item.data.id}`
|
||||
: `/api/teams/folders/${this.item.data.id}/convert`
|
||||
|
||||
let payload = this.name
|
||||
? {
|
||||
|
||||
11
resources/js/helpers/itemHelpers.js
vendored
11
resources/js/helpers/itemHelpers.js
vendored
@@ -45,6 +45,17 @@ const itemHelpers = {
|
||||
})
|
||||
},
|
||||
|
||||
Vue.prototype.$detachMeFromTeamFolder = function (folder) {
|
||||
events.$emit('confirm:open', {
|
||||
title: this.$t('Are you sure you want to leave this team?'),
|
||||
message: this.$t('You will not have access to the files in this team folder.'),
|
||||
action: {
|
||||
id: folder.data.id,
|
||||
operation: 'leave-team-folder',
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Vue.prototype.$createTeamFolder = function () {
|
||||
events.$emit('popup:open', {name: 'create-team-folder'})
|
||||
}
|
||||
|
||||
2
resources/js/store/modules/teams.js
vendored
2
resources/js/store/modules/teams.js
vendored
@@ -92,7 +92,7 @@ const actions = {
|
||||
getTeamFolderTree: ({commit, getters}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(`/api/teams/tree/${getters.currentTeamFolder.data.id}${getters.sorting.URI}`)
|
||||
.get(`/api/teams/folders/${getters.currentTeamFolder.data.id}/tree${getters.sorting.URI}`)
|
||||
.then(response => {
|
||||
resolve(response)
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@
|
||||
this.$store.commit('SET_AUTHORIZED', true)
|
||||
|
||||
// Go to files page
|
||||
this.$router.push({name: 'Files'})
|
||||
this.proceedToAccount()
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -336,7 +336,7 @@
|
||||
this.$store.commit('SET_AUTHORIZED', true)
|
||||
|
||||
// Go to files page
|
||||
this.$router.push({name: 'Files'})
|
||||
this.proceedToAccount()
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -368,6 +368,13 @@
|
||||
}
|
||||
|
||||
},
|
||||
proceedToAccount() {
|
||||
if (this.$route.query.redirect) {
|
||||
this.$router.push(this.$route.query.redirect)
|
||||
} else {
|
||||
this.$router.push({name: 'Files'})
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$scrollTop()
|
||||
@@ -377,6 +384,10 @@
|
||||
this.loginEmail = 'howdy@hi5ve.digital'
|
||||
this.loginPassword = 'vuefilemanager'
|
||||
//}
|
||||
|
||||
console.log(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -191,6 +191,22 @@
|
||||
events.$on('context-menu:show', (event, item) => this.item = item)
|
||||
events.$on('mobile-context-menu:show', item => this.item = item)
|
||||
events.$on('context-menu:current-folder', folder => this.item = folder)
|
||||
|
||||
events.$on('action:confirmed', data => {
|
||||
|
||||
// Leave team folder after popup confirmation
|
||||
if (data.operation === 'leave-team-folder')
|
||||
axios.delete(`/api/teams/folders/${data.id}/leave`)
|
||||
.then(() => {
|
||||
this.$router.push({name: 'SharedWithMe'})
|
||||
|
||||
events.$emit('toaster', {
|
||||
type: 'success',
|
||||
message: this.$t('You have successfully left the team folder'),
|
||||
})
|
||||
})
|
||||
.catch(() => this.$isSomethingWrong())
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Domain\Teams\Controllers\InvitationsController;
|
||||
use Domain\Teams\Controllers\LeaveTeamFolderController;
|
||||
use Domain\Teams\Controllers\NavigationTreeController;
|
||||
use Domain\Teams\Controllers\TeamFoldersController;
|
||||
use Domain\Teams\Controllers\BrowseSharedWithMeController;
|
||||
@@ -12,8 +13,9 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
|
||||
Route::apiResource('/folders', TeamFoldersController::class);
|
||||
|
||||
Route::post('/convert/{folder}', ConvertFolderIntoTeamFolderController::class);
|
||||
Route::get('/shared-with-me/{id}', BrowseSharedWithMeController::class);
|
||||
Route::post('/folders/{folder}/convert', ConvertFolderIntoTeamFolderController::class);
|
||||
Route::delete('/folders/{folder}/leave', LeaveTeamFolderController::class);
|
||||
Route::get('/folders/{folder}/tree', NavigationTreeController::class);
|
||||
|
||||
Route::get('/tree/{id}', NavigationTreeController::class);
|
||||
Route::get('/shared-with-me/{id}', BrowseSharedWithMeController::class);
|
||||
});
|
||||
|
||||
@@ -132,7 +132,7 @@ class SetupDevEnvironment extends Command
|
||||
],
|
||||
[
|
||||
'avatar' => 'avatar-03.png',
|
||||
'email' => $this->faker->email,
|
||||
'email' => 'johan@hi5ve.digital',
|
||||
],
|
||||
[
|
||||
'avatar' => 'avatar-04.png',
|
||||
@@ -805,6 +805,9 @@ class SetupDevEnvironment extends Command
|
||||
$owner = User::whereEmail('alice@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$johan = User::whereEmail('johan@hi5ve.digital')
|
||||
->first();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
@@ -828,25 +831,29 @@ class SetupDevEnvironment extends Command
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'permission' => 'owner',
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'permission' => 'owner',
|
||||
],
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $johan->id,
|
||||
'permission' => 'owner',
|
||||
]
|
||||
]);
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'Sofishticated.jpg',
|
||||
'whaaaaat.jpg',
|
||||
'You Are My Sunshine.jpg',
|
||||
])
|
||||
->each(function ($file) use ($owner, $memes) {
|
||||
->each(function ($file) use ($owner, $folder) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
@@ -855,7 +862,7 @@ class SetupDevEnvironment extends Command
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $memes->id,
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
@@ -867,6 +874,34 @@ class SetupDevEnvironment extends Command
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
// Get meme gallery
|
||||
collect([
|
||||
'You Are My Sunshine.jpg',
|
||||
])
|
||||
->each(function ($file) use ($johan, $folder) {
|
||||
$basename = Str::random(12) . '-' . $file;
|
||||
|
||||
// Copy file into app storage
|
||||
Storage::putFileAs("files/$johan->id", storage_path("demo/images/memes/$file"), $basename, 'private');
|
||||
Storage::putFileAs("files/$johan->id", storage_path("demo/images/memes/thumbnail-$file"), "thumbnail-$basename", 'private');
|
||||
|
||||
// Create file record
|
||||
File::create([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $johan->id,
|
||||
'name' => $file,
|
||||
'basename' => $basename,
|
||||
'type' => 'image',
|
||||
'author' => 'user',
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => "thumbnail-$basename",
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
collect([
|
||||
'Eggcited bro.jpg',
|
||||
'Get a Rest.jpg',
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Domain\Teams\Controllers;
|
||||
use Domain\Files\Resources\FilesCollection;
|
||||
use Domain\Folders\Resources\FolderCollection;
|
||||
use Domain\Folders\Resources\FolderResource;
|
||||
use Gate;
|
||||
use Str;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
@@ -18,6 +19,12 @@ class BrowseSharedWithMeController
|
||||
$id = Str::isUuid($id) ? $id : null;
|
||||
|
||||
if ($id) {
|
||||
$teamFolder = Folder::findOrFail($id)->getLatestParent();
|
||||
|
||||
if (! Gate::any(['can-edit', 'can-view'], [$teamFolder, null])) {
|
||||
abort(403, 'Access Denied');
|
||||
}
|
||||
|
||||
$folders = Folder::with(['parent:id,name'])
|
||||
->where('parent_id', $id)
|
||||
->sortable()
|
||||
@@ -44,7 +51,7 @@ class BrowseSharedWithMeController
|
||||
'root' => $id ? new FolderResource(Folder::findOrFail($id)) : null,
|
||||
'folders' => new FolderCollection($folders),
|
||||
'files' => isset($files) ? new FilesCollection($files) : new FilesCollection([]),
|
||||
'teamFolder' => $id ? new FolderResource(Folder::findOrFail($id)->getLatestParent()) : null,
|
||||
'teamFolder' => $id ? new FolderResource($teamFolder) : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
25
src/Domain/Teams/Controllers/LeaveTeamFolderController.php
Normal file
25
src/Domain/Teams/Controllers/LeaveTeamFolderController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Teams\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Auth;
|
||||
|
||||
class LeaveTeamFolderController extends Controller
|
||||
{
|
||||
public function __invoke(Folder $folder): Response|Application|ResponseFactory
|
||||
{
|
||||
// Find and delete attached member from team folder
|
||||
DB::table('team_folder_members')
|
||||
->where('parent_id', $folder->id)
|
||||
->where('user_id', Auth::id())
|
||||
->delete();
|
||||
|
||||
return response('Done.', 204);
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ use Gate;
|
||||
|
||||
class NavigationTreeController
|
||||
{
|
||||
public function __invoke(string $id): array
|
||||
public function __invoke(Folder $folder): array
|
||||
{
|
||||
$teamFolder = Folder::findOrFail($id)->getLatestParent();
|
||||
$teamFolder = $folder->getLatestParent();
|
||||
|
||||
if (! Gate::any(['can-edit', 'can-view'], [$teamFolder, null])) {
|
||||
abort(403, 'Access Denied');
|
||||
|
||||
@@ -45,7 +45,7 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_accept_team_folder_invite()
|
||||
{
|
||||
$member = User::factory(User::class)
|
||||
$member = User::factory()
|
||||
->create([
|
||||
'email' => 'john@internal.com',
|
||||
]);
|
||||
@@ -96,7 +96,7 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_reject_team_folder_invite()
|
||||
{
|
||||
$member = User::factory(User::class)
|
||||
$member = User::factory()
|
||||
->create([
|
||||
'email' => 'john@internal.com',
|
||||
]);
|
||||
@@ -133,10 +133,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_invite_member_into_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -212,10 +212,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_delete_invited_member_from_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -291,10 +291,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_remove_member_from_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -343,7 +343,7 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_update_invited_member_permission_in_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
@@ -390,10 +390,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_update_member_permission_in_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -445,10 +445,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function member_try_update_permission_in_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -502,10 +502,10 @@ class TeamManagementTest extends TestCase
|
||||
*/
|
||||
public function it_dissolve_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
@@ -549,12 +549,51 @@ class TeamManagementTest extends TestCase
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function member_try_dissolve_team_folder()
|
||||
public function it_leave_team_folder()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory(User::class)
|
||||
$member = User::factory()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => 1,
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
[
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->deleteJson("/api/teams/folders/{$folder->id}/leave")
|
||||
->assertNoContent();
|
||||
|
||||
$this
|
||||
->assertDatabaseMissing('team_folder_members', [
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function member_try_dissolve_team_folder()
|
||||
{
|
||||
$user = User::factory()
|
||||
->create();
|
||||
|
||||
$members = User::factory()
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class TeamsTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->post("/api/teams/convert/{$folder->id}", [
|
||||
->post("/api/teams/folders/{$folder->id}/convert", [
|
||||
'invitations' => [
|
||||
[
|
||||
'email' => 'john@internal.com',
|
||||
|
||||
Reference in New Issue
Block a user