Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#62047] fix creating folders from location picker

Eric Schubertf2171165ee3d
diff --git a/frontend/src/app/core/state/storage-files/storage-files.service.ts b/frontend/src/app/core/state/storage-files/storage-files.service.ts
index b621427704e..2cf49e90e28 100644
--- a/frontend/src/app/core/state/storage-files/storage-files.service.ts
+++ b/frontend/src/app/core/state/storage-files/storage-files.service.ts
@@ -87,6 +87,10 @@ export class StorageFilesResourceService {
this.store.reset();
}
+ removeCollection(link:IHalResourceLink):void {
+ delete this.store.getValue().files[link.href];
+ }
+
private lookup(id:ID):Observable<IStorageFile> {
return this
.query
diff --git a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
index d81aa497703..285d670b92f 100644
--- a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
+++ b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
@@ -40,7 +40,11 @@ import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.mod
import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
import { SortFilesPipe } from 'core-app/shared/components/storages/pipes/sort-files.pipe';
-import { isDirectory, storageLocaleString } from 'core-app/shared/components/storages/functions/storages.functions';
+import {
+ isDirectory,
+ makeFilesCollectionLink,
+ storageLocaleString,
+} from 'core-app/shared/components/storages/functions/storages.functions';
import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';
import {
StorageFileListItem,
@@ -195,7 +199,12 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
parent_id: this.currentDirectory.id,
},
).subscribe({
- next: (newlyCreatedDirectory) => this.changeLevel(newlyCreatedDirectory),
+ next: (newlyCreatedDirectory) => {
+ // clear cache for the current directory
+ const cacheKey = makeFilesCollectionLink(this.storage._links.self, this.currentDirectory.location);
+ this.storageFilesResourceService.removeCollection(cacheKey);
+ this.changeLevel(newlyCreatedDirectory);
+ },
error: (_) => this.showAlert.next('cannotCreateFolder'),
});
}
diff --git a/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts
index f37f1b021d5..6316f1238c1 100644
--- a/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts
@@ -98,6 +98,7 @@ export default class ProjectStorageFormController extends Controller {
selectProjectFolder(_evt:Event):void {
const locals = {
projectFolderHref: this.projectFolderHref,
+ createFolderHref: `${this.storage._links.self.href}/folders`,
storage: this.storage,
};