Skip to content

Commit

Permalink
refactor(settings): Return entire folder on creation
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin authored and backportbot[bot] committed Sep 3, 2024
1 parent 2e79039 commit 156fe95
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 7 additions & 1 deletion lib/Controller/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCA\GroupFolders\Service\FoldersFilter;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\Files\IRootFolder;
use OCP\IGroupManager;
Expand Down Expand Up @@ -145,10 +146,15 @@ private function getRootFolderStorageId(): ?int {
/**
* @RequireGroupFolderAdmin
* @NoAdminRequired
* @throws OCSNotFoundException
*/
public function addFolder(string $mountpoint): DataResponse {
$id = $this->manager->createFolder(trim($mountpoint));
return new DataResponse(['id' => $id]);
$folder = $this->manager->getFolder($id, $this->rootFolder->getMountPoint()->getNumericStorageId());
if ($folder === false) {
throw new OCSNotFoundException();
}
return new DataResponse($folder);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/settings/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export class Api {
}).then((data) => data.data)
}

createFolder(mountPoint: string): Thenable<number> {
createFolder(mountPoint: string): Thenable<Folder> {
return $.post(this.getUrl('folders'), {
mountpoint: mountPoint
}, null, 'json').then((data: OCSResult<{ id: number; }>) => data.ocs.data.id)
}, null, 'json').then((data: OCSResult<Folder>) => data.ocs.data)
}

deleteFolder(id: number): Thenable<void> {
Expand Down
12 changes: 2 additions & 10 deletions src/settings/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,9 @@ export class App extends Component<{}, AppState> implements OC.Plugin<OC.Search.
return
}
this.setState({ newMountPoint: '' })
this.api.createFolder(mountPoint).then((id) => {
this.api.createFolder(mountPoint).then((folder) => {
const folders = this.state.folders
folders.push({
mount_point: mountPoint,
groups: {},
quota: -3,
size: 0,
id,
acl: false,
manage: [],
})
folders.push(folder)
this.setState({ folders })
})
}
Expand Down

0 comments on commit 156fe95

Please sign in to comment.