Skip to content

Commit 0658e77

Browse files
Hari KiranHari Kiran
authored andcommitted
Fix: Github action and Handle Preview
1 parent 9ef1ad5 commit 0658e77

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed

.github/workflows/build-deploy-zodiac.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
- name: Install dependencies
2222
run: yarn install --frozen-lockfile
2323

24-
- name: Build React App with Dynamic PUBLIC_URL
25-
run: |
26-
echo "Building for /dev/dev_hari/"
27-
PUBLIC_URL="/dev/dev_hari/" yarn build
28-
2924
- name: Determine Branch Name
3025
id: get_branch
3126
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
3227

28+
- name: Build React App with Dynamic PUBLIC_URL
29+
run: |
30+
echo "Building for /dev/${{ env.BRANCH_NAME }}/"
31+
PUBLIC_URL="/dev/${{ env.BRANCH_NAME }}/" yarn build
32+
3333
- name: Copy package to server
3434
uses: NeuroJSON/[email protected]
3535
with:

src/pages/DatasetDetailPage.tsx

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface ExternalDataLink {
2828
size: string;
2929
path: string;
3030
url: string;
31+
index: number;
3132
}
3233

3334
const DatasetDetailPage: React.FC = () => {
@@ -74,6 +75,7 @@ const DatasetDetailPage: React.FC = () => {
7475
size,
7576
path: subPath,
7677
url: correctedUrl,
78+
index: links.length,
7779
});
7880
} else if (typeof obj[key] === "object") {
7981
links.push(...extractDataLinks(obj[key], `${path}/${key}`));
@@ -95,14 +97,28 @@ const DatasetDetailPage: React.FC = () => {
9597
fetchData();
9698
}, [dbName, docId, dispatch]);
9799

100+
// useEffect(() => {
101+
// if (datasetDocument) {
102+
// // Extract external links
103+
// const links = extractDataLinks(datasetDocument, "");
104+
// setExternalLinks(links);
105+
// }
106+
// }, [datasetDocument]);
107+
98108
useEffect(() => {
99109
if (datasetDocument) {
100-
// Extract external links
101-
const links = extractDataLinks(datasetDocument, "");
110+
// ✅ Extract links and ensure each link gets a proper `index`
111+
const links = extractDataLinks(datasetDocument, "").map((link, index) => ({
112+
...link,
113+
index, // ✅ Assign index correctly
114+
}));
115+
116+
console.log("🟢 Extracted external links with index:", links); // Debugging
102117
setExternalLinks(links);
103118
}
104119
}, [datasetDocument]);
105120

121+
106122

107123
// Function to handle the "Preview" functionality
108124
// const handlePreview = (url: string) => {
@@ -127,22 +143,42 @@ const DatasetDetailPage: React.FC = () => {
127143
// setPreviewOpen(true);
128144
// };
129145

130-
const handlePreview = (url: string) => {
146+
// const handlePreview = (url: string) => {
147+
148+
// // Check if the file is NIfTI (.nii, .nii.gz), JData (.jdt, .jdb), or Mesh (.bmsh, .jmsh)
149+
// if (/\.(nii|nii\.gz|jdt|jdb|bmsh|jmsh|bnii)$/i.test(url)) {
150+
// if (typeof (window as any).previewdataurl === "function") {
151+
// (window as any).previewdataurl(url, 0); // Calls preview immediately
152+
// } else {
153+
// console.error("❌ previewdataurl() is not defined!");
154+
// }
155+
// } else {
156+
// console.warn("⚠️ Unsupported file format for preview:", url);
157+
// }
158+
159+
// setPreviewDataKey(url); // Store the preview key
160+
// setPreviewOpen(true); // Open the preview modal
161+
// };
162+
163+
const handlePreview = (url: string, idx: number) => {
164+
console.log("🟢 Preview button clicked for:", url, "Index:", idx);
131165

132-
// Check if the file is NIfTI (.nii, .nii.gz), JData (.jdt, .jdb), or Mesh (.bmsh, .jmsh)
166+
// Check if the file type is supported
133167
if (/\.(nii|nii\.gz|jdt|jdb|bmsh|jmsh|bnii)$/i.test(url)) {
134168
if (typeof (window as any).previewdataurl === "function") {
135-
(window as any).previewdataurl(url, 0); // Calls preview immediately
169+
console.log("✅ Calling previewdataurl() for:", url, "Index:", idx);
170+
(window as any).previewdataurl(url, idx); // ✅ Correctly passing `idx`
136171
} else {
137172
console.error("❌ previewdataurl() is not defined!");
138173
}
139174
} else {
140175
console.warn("⚠️ Unsupported file format for preview:", url);
141176
}
142177

143-
setPreviewDataKey(url); // Store the preview key
144-
setPreviewOpen(true); // Open the preview modal
178+
setPreviewDataKey(url); // Store the preview key
179+
setPreviewOpen(true); // ✅ Open the preview modal
145180
};
181+
146182

147183
// const handleClosePreview = () => {
148184
// setPreviewOpen(false);
@@ -535,7 +571,8 @@ const DatasetDetailPage: React.FC = () => {
535571
color: Colors.primary.dark,
536572
},
537573
}}
538-
onClick={() => handlePreview(link.url)}
574+
onClick={() => handlePreview(link.url, link.index)} // ✅ Ensure `idx` is dynamically set
575+
539576
>
540577
Preview
541578
</Button>

0 commit comments

Comments
 (0)