Skip to content

Commit

Permalink
fix: Authored state lookup in authoring mode [PT-187809702]
Browse files Browse the repository at this point in the history
This fixes a couple of issues found when testing out authoring:

In authoring mode the authoredState comes in as a string which was causing the authoring preview to show an error that the experiment was not selected.

There was still a reference to the "Save Authored State" button, which I believe came from the S3 authoring version.
  • Loading branch information
dougmartin committed Jun 20, 2024
1 parent cacc372 commit 24602d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/lara-app/components/authoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const AuthoringComponent = (props : IProps) => {
})}
</>
</select>
<div className={css.note}>Once you select an experiment please click the "Save authored state" button above to save your choice.</div>
</div>
);
};
16 changes: 13 additions & 3 deletions src/lara-app/hooks/interactive-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,19 @@ export const useInteractiveApi = (options: {setError: (error: any) => void}) =>
setConnectedToLara(true);

let _experiment;
if (data.authoredState && (data.authoredState.version === "1.0")) {
experimentId.current = data.authoredState.experimentId;
_experiment = findExperiment(data.authoredState.experimentId);
let authoredState = data.authoredState;
// In authoring mode the authored state comes in as a string
// which causes the authoring preview to show an error
if (typeof authoredState === "string") {
try {
authoredState = JSON.parse(authoredState);
} catch (e) {
// noop
}
}
if (authoredState?.version === "1.0") {
experimentId.current = authoredState.experimentId;
_experiment = findExperiment(authoredState.experimentId);
setExperiment(_experiment);
}

Expand Down

0 comments on commit 24602d1

Please sign in to comment.