Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ const TermInfo = ({ open, setOpen }) => {
const queryComponentOpened = useSelector(
(state) => state.globalInfo.queryComponentOpened
);
const currentTemplate = useSelector(
(state) => state.instances.launchTemplate
);

const [termInfoData, setTermInfoData] = useState(data);
const [toggleReadMore, setToggleReadMore] = useState(false);
Expand Down Expand Up @@ -534,40 +531,6 @@ const TermInfo = ({ open, setOpen }) => {
];
};

const handleLinkClick = (href, event) => {
event.preventDefault();

const idsArray = href.split(',');
const templateId = idsArray[idsArray.length - 1];
const currentTemplateId = currentTemplate?.metadata?.Id;

let isAlignedTemplate = false;
if (data?.metadata?.Examples && typeof data?.metadata?.Examples === 'object' && Object.keys(data?.metadata?.Examples).length > 0) {
isAlignedTemplate = !!(data.metadata.Examples[currentTemplateId] && data.metadata.Examples[currentTemplateId].find(e => e.id === templateId));
} else if (data?.metadata?.Images && Array.isArray(data?.metadata?.Images) && data?.metadata?.Images.length > 0) {
isAlignedTemplate = !!(data.metadata.Images[currentTemplateId] && data.metadata.Images[currentTemplateId].find(e => e.id === templateId));
}

if (href.startsWith("http")) {
window.open(href, "_blank", "noopener,noreferrer");
} else {
if (isAlignedTemplate) {
getInstanceByID(
templateId,
true,
true,
true
);
} else {
setConfirmationModal({
open: true,
id: templateId,
message: "The image you requested is aligned to another template. Click Load Template to open it in a new tab or Cancel to just view the image metadata."
});
}
}
};

const queryGroups = useMemo(() => [
{ label: "Types of neurons with...", keys: ["Find neurons", "Find all", "Neurons with"] },
{ label: "Individual neurons with ", keys: ["Images of neurons with"] },
Expand Down Expand Up @@ -630,15 +593,16 @@ const TermInfo = ({ open, setOpen }) => {
return (
<ReactMarkdown
components={{
// eslint-disable-next-line no-unused-vars
a: ({ href, children, ...props }) => (
<span
style={{
fontSize: '0.875rem',
":hover": {
color: tabActiveColor,
cursor: 'pointer',
cursor: 'default',
}}}
onClick={e => handleLinkClick(href, e)}
// onClick={e => handleLinkClick(href, e)}
{...props}
>
{children}
Expand All @@ -648,7 +612,7 @@ const TermInfo = ({ open, setOpen }) => {
img: ({node, ...props}) => (
<img
{...props}
style={{ maxWidth: 180, maxHeight: 90, width: 'auto', height: 'auto' }}
style={{ maxWidth: 180, maxHeight: 90, width: 'auto', height: 'auto', cursor: 'default' }}
alt={props.alt}
/>
),
Expand Down Expand Up @@ -1195,7 +1159,7 @@ const TermInfo = ({ open, setOpen }) => {
return ( <TableRow key={row.id + '-' + rowIdx}>
{headers.slice(0, -1).map((h) =>
(
<TableCell key={h.key}>
<TableCell key={h.key} style={{ cursor: 'default' }}>
{renderCellContent(h.type, row[h.key])}
</TableCell>
)
Expand Down Expand Up @@ -1425,7 +1389,7 @@ const TermInfo = ({ open, setOpen }) => {
return ( <TableRow key={row.id + '-' + rowIdx}>
{headers.slice(0, -1).map((h) =>
(
<TableCell key={h.key}>
<TableCell key={h.key} style={{ cursor: 'default' }}>
{renderCellContent(h.type, row[h.key])}
</TableCell>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getInstancesTypes } from '../actions/types/getInstancesTypes';
import { setFirstIDLoaded, setAlignTemplates, setTemplateID } from '../actions/globals';
import { getInstanceByID, get3DMesh, triggerInstanceFailure, setBulkLoadingCount, clearUrlLoadingState, focusInstance, selectInstance } from '../actions/instances';
import * as GeppettoActions from '@metacell/geppetto-meta-client/common/actions';
import { DEFAULT_TEMPLATE_ID } from '../../utils/constants';

function updateUrlParameterWithCurrentUrl(param, value, reset) {
const urlObj = new URL(window.location.href);
Expand Down Expand Up @@ -54,7 +55,7 @@ function updateUrlWithInstancesAndSelectedId(selectedId, store) {
}
}

const DEFAULT_ID = "VFB_00101567";
const DEFAULT_ID = DEFAULT_TEMPLATE_ID;
const APP_LOADED_FLAG_KEY = "CURRENT_LOADED_URL";

// Track the initial focus ID from URL to prevent templates from overwriting it
Expand Down Expand Up @@ -95,8 +96,8 @@ const isFirstTimeLoad = (allLoadedInstances, store) => {
}

// id= parameter should always take priority for focus
const focusTarget = idSelected ||
(queuedInstances.length > 0
const focusTarget = idSelected ||
(queuedInstances.length > 0
? queuedInstances[queuedInstances.length - 1]
: uniqueLoadOrder[uniqueLoadOrder.length - 1]);

Expand Down Expand Up @@ -150,9 +151,14 @@ export const urlUpdaterMiddleware = store => next => (action) => {
const state = store.getState().instances;
const newFinishedCount = state.finishedLoadedInstances + 1;
const isAllBulkInstancesLoaded = state.isBulkLoading && newFinishedCount >= state.bulkLoadingCount;

// If bulk loading completed from URL, apply focus/select and clear the flag
if (isAllBulkInstancesLoaded && isLoadingFromUrl) {
if (!launchTemplate?.metadata?.Id && !action.payload?.IsTemplate) {
getInstanceByID(DEFAULT_TEMPLATE_ID, true, false, false);
updateUrlParameterWithCurrentUrl('i', DEFAULT_TEMPLATE_ID, false);
}

const urlParams = new URLSearchParams(window.location.search);
const pendingFocusId = urlParams.get('id');

Expand All @@ -166,7 +172,7 @@ export const urlUpdaterMiddleware = store => next => (action) => {
await focusInstance(pendingFocusId);
await selectInstance(pendingFocusId);
// Clear URL loading state after async operations complete
store.dispatch(clearUrlLoadingState());
store.dispatch(clearUrlLoadingState());
// Clear the initial focus ID after a longer delay to allow all pending template operations to complete
setTimeout(() => {
initialUrlFocusId = null;
Expand All @@ -176,13 +182,11 @@ export const urlUpdaterMiddleware = store => next => (action) => {
store.dispatch(clearUrlLoadingState());
}
}

const IsTemplate = action.payload?.IsTemplate || false;
const isClass = action.payload?.IsClass || false;
const isIndividual = action.payload?.IsIndividual || false;



if (!IsTemplate && !isClass && !isIndividual) {
// If the instance is not a template, class, or individual, dispatch the getInstanceFailure with an error message
if (action.payload?.Id === undefined) {
Expand All @@ -202,7 +206,7 @@ export const urlUpdaterMiddleware = store => next => (action) => {
}
get3DMesh(action.payload);
store.dispatch(setTemplateID(action.payload.Id));

if (!(initialUrlFocusId && initialUrlFocusId !== action.payload.Id)) {
updateUrlWithInstancesAndSelectedId(action.payload.Id, store);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const SELECTED_COLOR = { r: 0.8, g: 0.8, b: 0, a: 1 }
export const DESELECTED_COLOR = { r: .2, g: .8, b: 1, a: .3 }
export const TEMPLATE_COLOR = { r: .8, g: .8, b: .8, a: .4 }
export const DEFAULT_TEMPLATE_ID = "VFB_00101567";
export const SKELETON = "skeleton";
export const CYLINDERS = "sphere";
export const NEURON = "Neuron"
Expand Down
Loading