Skip to content

Commit

Permalink
Compute2: TreeWizard initial routing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-sharapov-sc committed Feb 3, 2025
1 parent 137b006 commit d21ca83
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export abstract class CustomFunctionView extends DG.ViewBase {

requestFeature: (() => Promise<void>) | null = null;

// TODO: initial URL id handling
public async init() {
const func = DG.Func.byName(this.funcNqName);
this.linkFunccall(func.prepare({}));
Expand All @@ -53,6 +54,10 @@ export abstract class CustomFunctionView extends DG.ViewBase {

public linkFunccall(funcCall: DG.FuncCall) {
this.funcCall = funcCall;
if (funcCall.id)
this.path = `?id=${funcCall.id}`;
else
this.path = ``;
}

public async onFuncCallReady() {
Expand Down
1 change: 0 additions & 1 deletion packages/Compute2/src/components/RFV/RichFunctionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import './RichFunctionView.css';
import * as Utils from '@datagrok-libraries/compute-utils/shared-utils/utils';
import {History} from '../History/History';
import {computedAsync, useUrlSearchParams} from '@vueuse/core';
import {ConsistencyInfo, FuncCallStateInfo} from '@datagrok-libraries/compute-utils/reactive-tree-driver/src/runtime/StateTreeNodes';
import {FittingView} from '@datagrok-libraries/compute-utils/function-views/src/fitting-view';
import {SensitivityAnalysisView} from '@datagrok-libraries/compute-utils';
Expand Down
19 changes: 15 additions & 4 deletions packages/Compute2/src/components/TreeWizard/TreeWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ export const TreeWizard = Vue.defineComponent({

const searchParams = useUrlSearchParams<{id?: string, currentStep?: string}>('history');

Vue.watch(searchParams, (params) => {
console.log(params);
let paramsRaw = [];
if (params.currentStep)
paramsRaw.push(`currentStep=${params.currentStep.replace(' ', '+')}`);
if (params.id)
paramsRaw.push(`id=${params.id}`);
if (paramsRaw.length)
grok.shell.v.path = `?${paramsRaw.join('&')}`;
else
grok.shell.v.path = ''
});

const isLoading = Vue.ref(false);

const handleActivePanelChanged = async (newPanel: string | null, prevPanel: string | null) => {
Expand All @@ -123,7 +136,6 @@ export const TreeWizard = Vue.defineComponent({
if (prevPanel === 'Step review')
rfvRef.value?.savePersonalState();


if (newPanel === 'Step review') {
isLoading.value = true;
await Vue.nextTick();
Expand Down Expand Up @@ -235,16 +247,15 @@ export const TreeWizard = Vue.defineComponent({
else grok.shell.v.name = providerFuncName.value;
});

let alreadyLoaded = false;
Vue.watch(treeState, () => {
if (!treeState.value || alreadyLoaded) return;
if (!treeState.value || globalThis.initialURLHandled) return;

// Getting inital URL user entered with
const startUrl = new URL(grok.shell.startUri);
const loadingId = startUrl.searchParams.get('id');
if (loadingId) {
loadPipeline(loadingId);
alreadyLoaded = true;
globalThis.initialURLHandled = true;
}
});

Expand Down
6 changes: 4 additions & 2 deletions packages/Compute2/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {CustomFunctionView} from '@datagrok-libraries/compute-utils/function-vie
import {HistoryApp} from './apps/HistoryApp';
import {Subject} from 'rxjs';

declare global {
var initialURLHandled: boolean;
}

export const _package = new DG.Package();

//tags: init
Expand All @@ -32,8 +36,6 @@ function setViewHierarchyData(call: DG.FuncCall, view: DG.ViewBase) {

if (call?.func?.name)
view.basePath = `/${call.func.name}`;

console.log(view);
}

//name: CustomFunctionViewEditor
Expand Down

0 comments on commit d21ca83

Please sign in to comment.