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

new folder button

Bruno Pagno2ddc60491d71
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 5a7d9e9bcb4..b621427704e 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
@@ -79,6 +79,10 @@ export class StorageFilesResourceService {
return this.httpClient.request<IUploadLink>(link.method, link.href, { body: link.payload });
}
+ createFolder(href:string, body:{ name:string, parent_id:ID }):Observable<IStorageFile> {
+ return this.httpClient.post<IStorageFile>(href, body);
+ }
+
reset():void {
this.store.reset();
}
diff --git a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.html b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.html
index 893be4759a4..f6e263e38af 100644
--- a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.html
+++ b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.html
@@ -72,6 +72,16 @@
</div>
<div class="spot-action-bar">
+ <div class="spot-action-bar--left">
+ <button
+ type="button"
+ class="button spot-action-bar--action"
+ (click)="createAndNavigateToFolder()"
+ >
+ <span class="spot-icon spot-icon_folder-add op-files-tab--icon op-files-tab--icon_forums"></span>
+ <span [textContent]="text.buttons.newFolder"></span>
+ </button>
+ </div>
<div class="spot-action-bar--right">
<button
type="button"
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 6ecfecf518c..2e9ca084c8c 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
@@ -74,6 +74,7 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
submitEmptySelection: this.i18n.t('js.storages.file_links.selection_none'),
cancel: this.i18n.t('js.button_cancel'),
selectAll: this.i18n.t('js.storages.file_links.select_all'),
+ newFolder: this.i18n.t('js.storages.new_folder'),
},
tooltip: {
directory_not_writeable: this.i18n.t('js.storages.files.directory_not_writeable'),
@@ -170,4 +171,20 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
return this.text.tooltip.file_not_selectable;
}
+
+ public createAndNavigateToFolder() {
+ // eslint-disable-next-line
+ const value = window.prompt(this.text.buttons.newFolder);
+ if (!value) { return; }
+
+ this.storageFilesResourceService.createFolder(
+ `${this.storage._links.self.href}/folders`,
+ {
+ name: value,
+ parent_id: this.currentDirectory.id,
+ },
+ ).subscribe((newlyCreatedDirectory) => {
+ this.changeLevel(newlyCreatedDirectory);
+ });
+ }
}
diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.ts
index 9877227ab47..1f133e75b40 100644
--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts
+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts
@@ -357,6 +357,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD
const locals = {
projectFolderHref: this.projectStorage._links.projectFolder?.href,
projectFolderMode: this.projectStorage.projectFolderMode,
+ createFolderHref: `${this.projectStorage._links.storage.href}/folders`,
storage,
};
diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.yml
index ac9733c3f2d..ff5c94d3fc6 100644
--- a/modules/storages/config/locales/js-en.yml
+++ b/modules/storages/config/locales/js-en.yml
@@ -13,6 +13,7 @@ en:
open_storage: "Open %{storageType}"
select_location: "Select location"
choose_location: "Choose location"
+ new_folder: "New folder"
types:
nextcloud: "Nextcloud"