From 0c359a0b7e71ce92576a53fc9430f2c5cc027530 Mon Sep 17 00:00:00 2001
From: sverhoeven
Date: Thu, 27 Nov 2025 13:29:13 +0100
Subject: [PATCH] Always show save state as file
Even if a link with embedded state can be made
---
.../src/components/ShareButton.tsx | 115 ++++++++++--------
1 file changed, 62 insertions(+), 53 deletions(-)
diff --git a/apps/class-solid/src/components/ShareButton.tsx b/apps/class-solid/src/components/ShareButton.tsx
index 8816f0c..c5295fc 100644
--- a/apps/class-solid/src/components/ShareButton.tsx
+++ b/apps/class-solid/src/components/ShareButton.tsx
@@ -19,6 +19,66 @@ import { showToast } from "./ui/toast";
const MAX_SHAREABLE_LINK_LENGTH = 32_000;
+function ShareStateAsFile({ state }: { state: string }) {
+ const downloadUrl = createMemo(() => {
+ return URL.createObjectURL(
+ new Blob([decodeURI(state)], {
+ type: "application/json",
+ }),
+ );
+ });
+ onCleanup(() => {
+ URL.revokeObjectURL(downloadUrl());
+ });
+
+ const filename = createMemo(() => {
+ const names = experiments.map((e) => e.config.reference.name).join("-");
+ return `class-${names.slice(0, 120)}.json`;
+ });
+
+ return (
+ <>
+
+ Alternatively you can create your own shareable link by hosting the
+ state remotely:
+
+
+ -
+
+ Download state
+ {" "}
+ as file
+
+ -
+ Upload the state file to some static hosting service like your own web
+ server or an AWS S3 bucket.
+
+ -
+ Open the CLASS web application with
+ "https://classmodel.github.io/class-web?s=<your remote url>".
+
+
+
+ Make sure the CLASS web application is{" "}
+
+ allowed to download from remote location
+
+ .
+
+ >
+ );
+}
+
export function ShareButton() {
const [open, setOpen] = createSignal(false);
const [isCopied, setIsCopied] = createSignal(false);
@@ -36,21 +96,6 @@ export function ShareButton() {
const url = `${window.location.origin}${basePath}#${encodedAppState()}`;
return url;
});
- const downloadUrl = createMemo(() => {
- return URL.createObjectURL(
- new Blob([decodeURI(encodedAppState())], {
- type: "application/json",
- }),
- );
- });
- onCleanup(() => {
- URL.revokeObjectURL(downloadUrl());
- });
-
- const filename = createMemo(() => {
- const names = experiments.map((e) => e.config.reference.name).join("-");
- return `class-${names.slice(0, 120)}.json`;
- });
async function copyToClipboard() {
try {
@@ -93,44 +138,7 @@ export function ShareButton() {
Cannot embed application state in shareable link, it is too
large.
-
- Alternatively you can create your own shareable link by hosting
- the state remotely:
-
-
- -
-
- Download state
- {" "}
- as file
-
- -
- Upload the state file to some static hosting service like your
- own web server or an AWS S3 bucket.
-
- -
- Open the CLASS web application with
- "https://classmodel.github.io/class-web?s=<your remote
- url>".
-
-
-
- Make sure the CLASS web application is{" "}
-
- allowed to download from remote location
-
- .
-
+
>
}
>
@@ -177,6 +185,7 @@ export function ShareButton() {
+