Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions resources/js/Shared/Children.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,10 @@ export default {
* @param {String|Number} selectedId - ID of the selected file/folder
*/
updateURLWithSelection(selectedId) {
if (selectedId == null || selectedId === "") {
return;
}

// Parse current URL parameters
const urlParams = new URLSearchParams(window.location.search);

Expand Down
40 changes: 32 additions & 8 deletions resources/js/Shared/FileSystemBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@
:show="showDownloadTerms"
:download-url="pendingDownloadUrl"
:download-identifier="pendingDownloadIdentifier"
:license-title="project?.license?.title || study?.license?.title"
:license-title="licenseTitle"
@close="closeDownloadTerms"
/>
</template>
Expand Down Expand Up @@ -1703,13 +1703,15 @@ export default {
* @prop {Boolean} readonly - Whether the browser is in read-only mode
* @prop {String} height - Tailwind height classes for the root #fs-dropzone (e.g. h-full min-h-0 when the parent establishes height via flex).
* @prop {Object} project - Project object for public file access (optional)
* @prop {Object} study - Study object for public file access (optional)
* @prop {Boolean} treeOnly - Show only the folder tree (hide details panel)
*/
props: [
"draft",
"readonly",
"height",
"project",
"study",
"treeOnly",
"studies",
"submittedStudyIds",
Expand Down Expand Up @@ -1912,15 +1914,32 @@ export default {
}
},

resolvedStudy() {
if (this.study) {
return this.study;
}

return (
this.$page.props.study?.data ?? this.$page.props.study ?? null
);
},

licenseTitle() {
return (
this.project?.license?.title ||
this.resolvedStudy?.license?.title ||
null
);
},

downloadTrackingIdentifier() {
if (this.project) {
return this.trackingIdentifier(this.project);
}

const study =
this.$page.props.study?.data ?? this.$page.props.study;

return study ? this.trackingIdentifier(study) : null;
return this.resolvedStudy
? this.trackingIdentifier(this.resolvedStudy)
: null;
},

/**
Expand Down Expand Up @@ -4094,9 +4113,14 @@ export default {
let targetId = null;

// First try to use the selected parameter from URL
if (selectedParam) {
targetId = parseInt(selectedParam);
} else {
if (selectedParam && selectedParam !== "undefined") {
const parsed = parseInt(selectedParam, 10);
if (!Number.isNaN(parsed)) {
targetId = parsed;
}
}

if (targetId == null) {
// Fall back to last expanded folder
const expandedIds = Array.from(this.expandedFolders);
if (expandedIds.length === 0) return;
Expand Down
29 changes: 29 additions & 0 deletions tests/Unit/FileSystemBrowserLicenseTitleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Tests\Unit;

use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class FileSystemBrowserLicenseTitleTest extends TestCase
{
#[Test]
public function download_terms_modal_does_not_read_undeclared_study_during_render(): void
{
$path = resource_path('js/Shared/FileSystemBrowser.vue');

$this->assertFileExists($path);

$contents = file_get_contents($path);

$this->assertNotFalse($contents);

[$template] = explode('<script>', $contents, 2);

$this->assertStringContainsString(':license-title="licenseTitle"', $template);
$this->assertStringNotContainsString('study?.license', $template);
$this->assertStringContainsString('"study"', $contents);
$this->assertStringContainsString('licenseTitle()', $contents);
$this->assertStringContainsString('resolvedStudy()', $contents);
}
}
Loading