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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#48044] Use Location picker modal to insert project folder name and ID into HTML form
Eric Schubert42f63c2e750e
diff --git a/app/helpers/api_v3_helper.rb b/app/helpers/api_v3_helper.rbnew file mode 100644index 00000000000..50be2f4d6eb--- /dev/null+++ b/app/helpers/api_v3_helper.rb@@ -0,0 +1,33 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module APIV3Helper+ def api_v3_paths+ ::API::V3::Utilities::PathHelper::ApiV3Path+ end+enddiff --git a/frontend/src/app/core/state/project-storages/project-storage.model.ts b/frontend/src/app/core/state/project-storages/project-storage.model.tsindex 1a486ceb89f..d65eac7af58 100644--- a/frontend/src/app/core/state/project-storages/project-storage.model.ts+++ b/frontend/src/app/core/state/project-storages/project-storage.model.ts@@ -27,12 +27,13 @@//++import { ID } from '@datorama/akita';-import { IHalResourceLink, IHalResourceLinks } from 'core-app/core/state/hal-resource';+import { IHalOptionalTitledLink, IHalResourceLink, IHalResourceLinks } from 'core-app/core/state/hal-resource';export interface IProjectStorageHalResourceLinks extends IHalResourceLinks {storage:IHalResourceLink;project:IHalResourceLink;creator:IHalResourceLink;+ projectFolder?:IHalOptionalTitledLink;}export interface IProjectStorage {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.tsindex 8b1cd1de205..646279ba9b5 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@@ -71,9 +71,8 @@ export class StorageFilesResourceService {.pipe(tap((storageFiles) => this.insert(storageFiles, link.href)));}- file(storageId:ID, id:ID):Observable<IStorageFile> {- return this.httpClient- .get<IStorageFile>(`${this.apiV3Service.storages.id(storageId).path}/files/${id}`);+ file(href:string):Observable<IStorageFile> {+ return this.httpClient.get<IStorageFile>(href);}uploadLink(link:IPrepareUploadLink):Observable<IUploadLink> {diff --git a/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts b/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.tsindex a7145c437cf..c271a3cc102 100644--- a/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts+++ b/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts@@ -88,7 +88,7 @@ export abstract class FilePickerBaseModalComponent extends OpModalComponent impl.map((file, index) => this.storageFileToListItem(file, index))),);- public readonly loading$ = new BehaviorSubject<boolean>(true);+ public readonly loading$ = new BehaviorSubject<'loading'|'success'|'error'>('loading');protected constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,@@ -107,12 +107,16 @@ export abstract class FilePickerBaseModalComponent extends OpModalComponent impl.pipe(this.untilDestroyed(),switchMap((location:string) => this.storageFilesResourceService.files(makeFilesCollectionLink(this.storage._links.self, location))),+ catchError((error) => {+ this.loading$.next('error');+ throw error;+ }),).subscribe((storageFiles) => {this.currentDirectory = storageFiles.parent;this.breadcrumbs = this.makeBreadcrumbs(storageFiles.ancestors, storageFiles.parent);this.storageFiles$.next(storageFiles.files);- this.loading$.next(false);+ this.loading$.next('success');});}@@ -138,25 +142,29 @@ export abstract class FilePickerBaseModalComponent extends OpModalComponent implprotected changeLevel(ancestor:IStorageFile):void {this.cancelCurrentLoading();- this.loading$.next(true);+ this.loading$.next('loading');this.loadingSubscription = this.storageFilesResourceService.files(makeFilesCollectionLink(this.storage._links.self, ancestor.location))+ .pipe(catchError((error) => {+ this.loading$.next('error');+ throw error;+ })).subscribe((storageFiles) => {this.currentDirectory = storageFiles.parent;this.breadcrumbs = this.makeBreadcrumbs(storageFiles.ancestors, storageFiles.parent);this.storageFiles$.next(storageFiles.files);- this.loading$.next(false);+ this.loading$.next('success');});}private entryLocation():Observable<string> {- if (this.locals.projectFolderId === null) {+ if (this.locals.projectFolderHref === null) {return of('/');}return this.storageFilesResourceService- .file(this.storage.id, this.locals.projectFolderId as string)+ .file(this.locals.projectFolderHref as string).pipe(map((file) => file.location),catchError((error:HttpErrorResponse) => {diff --git a/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.html b/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.htmlindex 56af7ae1519..e14c9fb3bff 100644--- a/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.html+++ b/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.html@@ -26,7 +26,11 @@<spot-breadcrumbs [content]="breadcrumbs"></spot-breadcrumbs>- <ng-container *ngIf="(loading$ | async) === false; else loadingTemplate">+ <ng-container *ngIf="(loading$ | async) === 'success'; then listTemplate"></ng-container>+ <ng-container *ngIf="(loading$ | async) === 'error'; then notFoundTemplate"></ng-container>+ <ng-container *ngIf="(loading$ | async) === 'loading'; then loadingTemplate"></ng-container>++ <ng-template #listTemplate><ul*ngIf="(listItems$ | async).length > 0; else emptyTemplate"class="spot-list spot-list_compact op-file-list op-file-picker--scrollable-content"@@ -40,16 +44,26 @@[content]="file"></li></ul>- </ng-container>+ </ng-template><ng-template #loadingTemplate><op-loading-file-list class="spot-body-big"></op-loading-file-list></ng-template><ng-template #emptyTemplate>- <div class="spot-body-big spot-body-big_bold op-file-picker--empty">- <span class="spot-icon spot-icon_folder-open op-file-picker--empty-icon"></span>+ <div class="spot-body-big spot-body-big_bold op-file-picker--info">+ <span class="spot-icon spot-icon_folder-open op-file-picker--info-icon"></span><span [textContent]="text.content.empty"></span>+ <span class="spot-body-small op-file-picker--info-sub-text" [textContent]="text.content.emptyHint"></span>+ </div>+ </ng-template>++ <ng-template #notFoundTemplate>+ <div class="spot-body-big spot-body-big_bold op-file-picker--info">+ <span class="spot-icon spot-icon_remove-link op-file-picker--info-icon"></span>+ <span [textContent]="text.content.noConnection(storageType)"></span>+ <span class="spot-body-small op-file-picker--info-sub-text"+ [textContent]="text.content.noConnectionHint(storageType)"></span></div></ng-template></div>diff --git a/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.ts b/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.tsindex 8353efe2afc..6693cf83b30 100644--- a/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.ts+++ b/frontend/src/app/shared/components/storages/file-picker-modal/file-picker-modal.component.ts@@ -41,7 +41,7 @@ import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.modimport { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';import { SortFilesPipe } from 'core-app/shared/components/storages/pipes/sort-files.pipe';import { FileLinksResourceService } from 'core-app/core/state/file-links/file-links.service';-import { isDirectory } from 'core-app/shared/components/storages/functions/storages.functions';+import { isDirectory, storageLocaleString } from 'core-app/shared/components/storages/functions/storages.functions';import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';import {StorageFileListItem,@@ -61,6 +61,9 @@ export class FilePickerModalComponent extends FilePickerBaseModalComponent {warningNoAccess: this.i18n.t('js.storages.files.project_folder_no_access'),content: {empty: this.i18n.t('js.storages.files.empty_folder'),+ emptyHint: this.i18n.t('js.storages.files.empty_folder_location_hint'),+ noConnection: (storageType:string) => this.i18n.t('js.storages.no_connection', { storageType }),+ noConnectionHint: (storageType:string) => this.i18n.t('js.storages.information.connection_error', { storageType }),},buttons: {submit: (count:number):string => this.i18n.t('js.storages.file_links.selection', { count }),@@ -80,6 +83,10 @@ export class FilePickerModalComponent extends FilePickerBaseModalComponent {return this.selection.size;}+ public get storageType():string {+ return this.i18n.t(storageLocaleString(this.storage._links.type.href));+ }+public showSelectAll = false;private readonly selection = new Set<string>();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.htmlindex 586289c87ff..2960428b594 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@@ -26,7 +26,11 @@<spot-breadcrumbs [content]="breadcrumbs"></spot-breadcrumbs>- <ng-container *ngIf="(loading$ | async) === false; else loadingTemplate">+ <ng-container *ngIf="(loading$ | async) === 'success'; then listTemplate"></ng-container>+ <ng-container *ngIf="(loading$ | async) === 'error'; then notFoundTemplate"></ng-container>+ <ng-container *ngIf="(loading$ | async) === 'loading'; then loadingTemplate"></ng-container>++ <ng-template #listTemplate><ul*ngIf="(listItems$ | async).length > 0; else emptyTemplate"class="spot-list spot-list_compact op-file-list op-file-picker--scrollable-content"@@ -40,17 +44,26 @@[content]="file"></li></ul>- </ng-container>+ </ng-template><ng-template #loadingTemplate><op-loading-file-list class="spot-body-big"></op-loading-file-list></ng-template><ng-template #emptyTemplate>- <div class="spot-body-big spot-body-big_bold op-file-picker--empty">- <span class="spot-icon spot-icon_folder-open op-file-picker--empty-icon"></span>+ <div class="spot-body-big spot-body-big_bold op-file-picker--info">+ <span class="spot-icon spot-icon_folder-open op-file-picker--info-icon"></span><span [textContent]="text.content.empty"></span>- <span class="spot-body-small op-file-picker--empty-sub-text" [textContent]="text.content.emptyHint"></span>+ <span class="spot-body-small op-file-picker--info-sub-text" [textContent]="text.content.emptyHint"></span>+ </div>+ </ng-template>++ <ng-template #notFoundTemplate>+ <div class="spot-body-big spot-body-big_bold op-file-picker--info">+ <span class="spot-icon spot-icon_remove-link op-file-picker--info-icon"></span>+ <span [textContent]="text.content.noConnection(storageType)"></span>+ <span class="spot-body-small op-file-picker--info-sub-text"+ [textContent]="text.content.noConnectionHint(storageType)"></span></div></ng-template></div>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.tsindex fe153419c7a..d70d5de2509 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,7 @@ import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.modimport { 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 } from 'core-app/shared/components/storages/functions/storages.functions';+import { isDirectory, storageLocaleString } from 'core-app/shared/components/storages/functions/storages.functions';import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';import {StorageFileListItem,@@ -62,6 +62,8 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {content: {empty: this.i18n.t('js.storages.files.empty_folder'),emptyHint: this.i18n.t('js.storages.files.empty_folder_location_hint'),+ noConnection: (storageType:string) => this.i18n.t('js.storages.no_connection', { storageType }),+ noConnectionHint: (storageType:string) => this.i18n.t('js.storages.information.connection_error', { storageType }),},buttons: {submit: this.i18n.t('js.storages.choose_location'),@@ -75,8 +77,12 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {},};- public get location():string {- return this.currentDirectory.id as string;+ public get location():IStorageFile {+ return this.currentDirectory;+ }++ public get storageType():string {+ return this.i18n.t(storageLocaleString(this.storage._links.type.href));}public get filesAtLocation():IStorageFile[] {diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.tsindex 586aa7521a1..6b9243ae51f 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@ -177,16 +177,16 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDreturn (this.resource.$links as unknown&{ addFileLink:IHalResourceLink }).addFileLink.href;}- private get projectFolderId():string|null {+ private get projectFolderHref():string|null {if (this.projectStorage.projectFolderMode === 'inactive') {return null;}- if (this.projectStorage.projectFolderId === null) {+ if (!this.projectStorage._links.projectFolder) {throw new Error(`Project folder id 'null' not allowed for project folder mode '${this.projectStorage.projectFolderMode}'.`);}- return this.projectStorage.projectFolderId;+ return this.projectStorage._links.projectFolder.href;}private onGlobalDragLeave:(_event:DragEvent) => void = (_event) => {@@ -293,7 +293,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD.subscribe(([storage, fileLinks, collectionKey]) => {const locals = {addFileLinksHref: this.addFileLinksHref,- projectFolderId: this.projectFolderId,+ projectFolderHref: this.projectFolderHref,storage,collectionKey,fileLinks,@@ -328,7 +328,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDprivate selectUploadLocation(storage:IStorage):Observable<LocationData> {const locals = {- projectFolderId: this.projectFolderId,+ projectFolderHref: this.projectFolderHref,storage,};@@ -337,7 +337,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDswitchMap((modal) => modal.closingEvent),filter((modal) => modal.submitted),first(),- map((modal) => ({ location: modal.location, files: modal.filesAtLocation })),+ map((modal) => ({ location: modal.location.id as string, files: modal.filesAtLocation })),);}diff --git a/frontend/src/global_styles/content/_buttons.sass b/frontend/src/global_styles/content/_buttons.sassindex 2e9bf2d7bba..36b313a528b 100644--- a/frontend/src/global_styles/content/_buttons.sass+++ b/frontend/src/global_styles/content/_buttons.sass@@ -130,6 +130,9 @@ a.button&_no-marginmargin: 0+ &_no-bottom-margin+ margin-bottom: 0+.button--icon@include icon-commondiff --git a/frontend/src/global_styles/content/_forms.sass b/frontend/src/global_styles/content/_forms.sassindex 99cc85ec45f..37e1927786e 100644--- a/frontend/src/global_styles/content/_forms.sass+++ b/frontend/src/global_styles/content/_forms.sass@@ -428,6 +428,10 @@ fieldset.form--fieldsetdisplay: flexflex-wrap: wrap+ &.-with-children-spacing+ > *:not(:last-child)+ margin-right: 0.5rem+&.-verticaldisplay: block@@ -511,6 +515,9 @@ fieldset.form--fieldset&.-labeled-checkboxmargin-left: 25px+ &.-with-bottom-spacing+ margin-bottom: 1rem+.form--inline-instructionsfont-style: italicdisplay: inline@@ -573,7 +580,7 @@ fieldset.form--fieldset#{$text-input-selectors},selectline-height: 100%- margin-bottom: 0rem+ margin-bottom: 0font-size: 0.9rem&:hover, &:focus, &:activediff --git a/frontend/src/global_styles/content/work_packages/shared/_file_picker.sass b/frontend/src/global_styles/content/work_packages/shared/_file_picker.sassindex 29cccf4851e..db3f5e058e0 100644--- a/frontend/src/global_styles/content/work_packages/shared/_file_picker.sass+++ b/frontend/src/global_styles/content/work_packages/shared/_file_picker.sass@@ -42,7 +42,7 @@height: calc(#{var(--app-height)} / 2)max-height: 32rem- &--empty+ &--infodisplay: flexflex-direction: columnalign-items: center@@ -50,7 +50,7 @@height: 100%text-align: center- &-icon+ & &-iconwidth: 9.5remheight: 9.5remfont-size: 5.5remdiff --git a/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.tsindex e06c0e68f7c..5163ddafec4 100644--- a/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/project-storage-form.controller.ts@@ -29,27 +29,84 @@*/import { Controller } from '@hotwired/stimulus';+import { from, Observable } from 'rxjs';+import { filter, map, switchMap } from 'rxjs/operators';++import { OpModalService } from 'core-app/shared/components/modal/modal.service';+import {+ LocationPickerModalComponent,+} from 'core-app/shared/components/storages/location-picker-modal/location-picker-modal.component';+import { IStorage } from 'core-app/core/state/storages/storage.model';+import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.model';export default class ProjectStorageFormController extends Controller {static targets = ['projectFolderSection',+ 'projectFolderIdInput',+ 'selectedFolderText',+ 'storage',+ 'storageSelector',];static values = {folderMode: String,+ placeholderFolderName: String,+ emptyFolderNameValidation: String,};declare folderModeValue:string;+ declare placeholderFolderNameValue:string;++ declare emptyFolderNameValidationValue:string;++ declare readonly storageTargets:HTMLElement[];++ declare readonly storageSelectorTarget:HTMLSelectElement;++ declare readonly hasStorageSelectorTarget:boolean;+declare readonly projectFolderSectionTarget:HTMLElement;+ declare readonly projectFolderIdInputTarget:HTMLInputElement;++ declare readonly selectedFolderTextTarget:HTMLSpanElement;+declare readonly hasProjectFolderSectionTarget:boolean;- connect() {+ connect():void {this.toggleFolderDisplay(this.folderModeValue);+ this.selectedFolderTextTarget.innerText = this.placeholderFolderNameValue;++ const href = this.projectFolderHref;+ if (href !== null) {+ void fetch(href)+ .then((data) => data.json())+ .then((file:IStorageFile) => {+ this.selectedFolderTextTarget.innerText = file.name;+ });+ }}- updateDisplay(evt:InputEvent) {+ selectProjectFolder(_evt:Event):void {+ const locals = {+ projectFolderHref: this.projectFolderHref,+ storage: this.storage,+ };++ this.modalService+ .pipe(+ switchMap((service) => service.show(LocationPickerModalComponent, 'global', locals)),+ switchMap((modal) => modal.closingEvent),+ filter((modal) => modal.submitted),+ )+ .subscribe((modal) => {+ this.selectedFolderTextTarget.innerText = modal.location.name;+ this.projectFolderIdInputTarget.value = modal.location.id as string;+ });+ }++ updateDisplay(evt:InputEvent):void {if (!this.hasProjectFolderSectionTarget) {return;}@@ -57,7 +114,30 @@ export default class ProjectStorageFormController extends Controller {this.toggleFolderDisplay((evt.target as HTMLInputElement).value);}- private toggleFolderDisplay(value:string) {+ private get modalService():Observable<OpModalService> {+ return from(window.OpenProject.getPluginContext())+ .pipe(map((pluginContext) => pluginContext.services.opModalService));+ }++ private get storage():IStorage {+ const storageElement = this.hasStorageSelectorTarget+ ? this.storageSelectorTarget.options[this.storageSelectorTarget.selectedIndex]+ : this.storageTargets[0];++ return JSON.parse(storageElement.dataset.storage as string) as IStorage;+ }++ private get projectFolderHref():string|null {+ const projectFolderId = this.projectFolderIdInputTarget.value;++ if (projectFolderId.length === 0) {+ return null;+ }++ return `${this.storage._links.self.href}/files/${projectFolderId}`;+ }++ private toggleFolderDisplay(value:string):void {// If the manual radio button is selected, show the manual folder selection sectionif (value === 'manual') {this.projectFolderSectionTarget.style.display = 'flex';diff --git a/modules/storages/app/views/storages/project_settings/_form.html.erb b/modules/storages/app/views/storages/project_settings/_form.html.erbindex 172a9807482..679f3bbd132 100644--- a/modules/storages/app/views/storages/project_settings/_form.html.erb+++ b/modules/storages/app/views/storages/project_settings/_form.html.erb@@ -29,16 +29,39 @@ See COPYRIGHT and LICENSE files for more details.<% content_controller 'project-storage-form',dynamic: true,- 'project-storage-form-folder-mode-value': @project_storage.project_folder_mode %>+ 'project-storage-form-folder-mode-value': @project_storage.project_folder_mode,+ 'project-storage-form-placeholder-folder-name-value': t(:"storages.label_no_selected_folder"),+ 'project-storage-form-empty-folder-name-validation-value': t(:"storages.label_empty_project_folder_validation")+%><div class="form--field -required"><% case action_name %><% when 'new' %><%= f.select :storage_id,- available_storages.map { |storage| ["#{storage.name} (#{storage.short_provider_type})", storage.id] },- selected: available_storages.first.id.to_s,- class: '-bold',- container_class: '-slim' %>+ (@available_storages.map do |storage|+ [+ "#{storage.name} (#{storage.short_provider_type})",+ storage.id,+ data: {+ 'project-storage-form-target': 'storage',+ storage: {+ name: storage.name,+ id: storage.id,+ _links: {+ self: { href: api_v3_paths.storage(storage.id) },+ type: { href: API::V3::Storages::URN_STORAGE_TYPE_NEXTCLOUD }+ }+ },+ }+ ]+ end),+ {+ selected: @available_storages.first.id.to_s,+ container_class: '-slim'+ },+ data: {+ 'project-storage-form-target': 'storageSelector',+ } %><% if User.current.admin? %><span class="form--field-instructions"><%= t(:"storages.instructions.setting_up_additional_storages") %>@@ -50,8 +73,21 @@ See COPYRIGHT and LICENSE files for more details.<%= f.label :storage_id, class: "form--label -bold" do %><%= t(:"storages.label_storage") %><% end %>- <div class="form--field-container -horizontal">- <span><%= @project_storage.storage.name %></span>+ <div class="form--field-container">+ <%= content_tag(:span,+ @project_storage.storage.name,+ id: 'active_storage',+ data: {+ 'project-storage-form-target': 'storage',+ storage: {+ name: @project_storage.storage.name,+ id: @project_storage.storage.id,+ _links: {+ self: { href: api_v3_paths.storage(@project_storage.storage.id) },+ type: { href: API::V3::Storages::URN_STORAGE_TYPE_NEXTCLOUD }+ }+ },+ }) %></div><% end %></div>@@ -68,7 +104,7 @@ See COPYRIGHT and LICENSE files for more details.}%><% end %>- <div class="form--field-container -horizontal">+ <div class="form--field-container"><%= f.label :project_folder_mode, class: "form--label-with-radio-button" do %><%= f.radio_button :project_folder_mode,'inactive',@@ -77,11 +113,11 @@ See COPYRIGHT and LICENSE files for more details.<%= t(:"storages.label_no_specific_folder") %><% end %></div>- <p class="form--field-instructions">+ <span class="form--field-instructions -with-bottom-spacing"><%= t(:"storages.instructions.no_specific_folder") %>- </p>+ </span>- <div class="form--field-container -horizontal">+ <div class="form--field-container"><%= f.label :project_folder_mode, class: "form--label-with-radio-button" do %><%= f.radio_button :project_folder_mode,'manual',@@ -90,19 +126,32 @@ See COPYRIGHT and LICENSE files for more details.<%= t(:"storages.label_existing_manual_folder") %><% end %></div>- <p class="form--field-instructions -xwide">+ <span class="form--field-instructions -xwide -with-bottom-spacing"><%= t(:"storages.instructions.existing_manual_folder") %>- </p>- </div>+ </span>- <div style="display:none;" class="form--field -required" data-project-storage-form-target="projectFolderSection">- <label class="form--label -bold"> <%= t(:"storages.label_existing_manual_folder_selection") %> </label>- <div class="form--field-container -horizontal">- <%= f.text_field :project_folder_id,- placeholder: t(:"storages.placeholder_existing_folder_selection"),- container_class: "-middle",- no_label: true- %>+ <div+ style="display: none;"+ class="form--field-container -with-children-spacing"+ data-project-storage-form-target="projectFolderSection"+ >+ <%= f.hidden_field :project_folder_id,+ required: true,+ data: {+ 'project-storage-form-target': "projectFolderIdInput"+ } %>+ <%= styled_button_tag id: 'open_location_picker_button',+ class: 'button_no-margin',+ data: {+ 'action': "project-storage-form#selectProjectFolder"+ },+ type: 'button' do %>+ <%= spot_icon('folder-open') %>+ <%= content_tag :span, t(:"storages.buttons.select_folder") %>+ <% end %>+ <span+ data-project-storage-form-target="selectedFolderText"+ ></span></div></div><% end %>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 79596a035fe..e501e16648b 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -54,6 +54,7 @@ en:replace_provider_type_oauth: "Replace %{provider_type} OAuth"save_and_continue_setup: "Save and continue setup"save_and_complete_setup: "Save and complete setup"+ select_folder: "Select folder"page_titles:project_settings:index: "File storages available in this project"@@ -88,7 +89,6 @@ en:project_storage: >Are you sure you want to remove this file storage from this project? This will alsoremove all links to files stored in this storage for this project.- placeholder_existing_folder_selection: "Select a folder"label_creator: "Creator"label_file_link: "File link"label_file_links: "File links"@@ -103,8 +103,9 @@ en:label_project_folder: "Project folder"label_new_storage: "New storage"label_existing_manual_folder: "Existing folder with manually managed permissions"- label_existing_manual_folder_selection: "Existing folder selection"label_no_specific_folder: "No specific folder"+ label_no_selected_folder: "No selected folder"+ label_empty_project_folder_validation: "Selecting a folder is mandatory to proceed"label_storage: "Storage"label_storages: "Storages"no_results: "No storages set up yet."diff --git a/modules/storages/lib/api/v3/project_storages/project_storage_representer.rb b/modules/storages/lib/api/v3/project_storages/project_storage_representer.rbindex 09861c9409c..7f32da802d6 100644--- a/modules/storages/lib/api/v3/project_storages/project_storage_representer.rb+++ b/modules/storages/lib/api/v3/project_storages/project_storage_representer.rb@@ -41,6 +41,12 @@ module API::V3::ProjectStoragesproperty :project_folder_idproperty :project_folder_mode+ link :projectFolder do+ next if represented.project_folder_id.blank?++ { href: api_v3_paths.storage_file(represented.storage.id, represented.project_folder_id) }+ end+associated_resource :storage, skip_render: ->(*) { true }, skip_link: ->(*) { false }associated_resource :project, skip_render: ->(*) { true }, skip_link: ->(*) { false }associated_resource :creator,