Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

chore: replace getAssetUrl with inline images (#74960)

Uladzimir Havenchyk4cccd299adbd
diff --git a/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts b/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts
index 33a85f89948..5def64a54f4 100644
--- a/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts
+++ b/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts
@@ -1532,15 +1532,13 @@ describe("admin > custom visualizations", () => {
cy.findByTestId("viz-type-button").click();
cy.log(
- "Threshold defaults to 0 and Count(Orders) is > 0, so the thumbs-up image should render.",
+ "Threshold defaults to 0 and Count(Orders) is > 0, so the thumbs-up should render.",
);
H.main()
- .findByAltText("Above threshold")
- .should("be.visible")
- .and("have.attr", "src")
- .and("match", /thumbs-up\.png/);
+ .findByRole("img", { name: "Above threshold" })
+ .should("be.visible");
- cy.log("Modifying plugin source to change the alt text via getAssetUrl");
+ cy.log("Modifying plugin source to change the rendered label");
cy.readFile(pluginSrcPath).then((src) => {
const updated = src.replace('"Above threshold"', '"Way above!"');
if (updated === src) {
@@ -1552,7 +1550,7 @@ describe("admin > custom visualizations", () => {
});
cy.log("Checking if hot reload works");
- H.main().findByAltText("Way above!").should("be.visible");
+ H.main().findByRole("img", { name: "Way above!" }).should("be.visible");
cy.log("Verify plugin settings affect rendering.");
cy.log(
@@ -1567,9 +1565,8 @@ describe("admin > custom visualizations", () => {
name: /Done/,
}).click();
H.main()
- .findByAltText("Below threshold")
- .should("have.attr", "src")
- .and("match", /thumbs-down\.png/);
+ .findByRole("img", { name: "Below threshold" })
+ .should("be.visible");
cy.log(
"Saving the question and reloading to verify persistence of settings and dev URL",
@@ -1580,9 +1577,8 @@ describe("admin > custom visualizations", () => {
cy.findByRole("dialog", { name: /Save question/ }).should("not.exist");
cy.reload();
H.main()
- .findByAltText("Below threshold")
- .should("have.attr", "src")
- .and("match", /thumbs-down\.png/);
+ .findByRole("img", { name: "Below threshold" })
+ .should("be.visible");
cy.log(
"When the dev server is stopped, the visualization should revert to the default",
diff --git a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/api.clj b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/api.clj
index 2b75ff29706..3c3d0416d85 100644
--- a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/api.clj
@@ -111,9 +111,9 @@
"Register a new custom visualization plugin from an uploaded tar.gz bundle.
The archive must contain `metabase-plugin.json` at the root and
- `dist/index.js` for the JS bundle, plus any whitelisted assets under
- `dist/assets/`. The plugin's `identifier` is taken from the manifest's `name`
- field."
+ `dist/index.js` for the JS bundle. The only static asset served from the bundle
+ is the manifest `icon` (under `dist/assets/`); plugins do not ship arbitrary
+ assets. The plugin's `identifier` is taken from the manifest's `name` field."
{:multipart {:max-file-size cache/max-bundle-bytes
:max-file-count 1}}
[_route-params
@@ -321,10 +321,10 @@
(raise e))))
(api.macros/defendpoint :get "/:id/asset" :- :any
- "Serve a static image asset from the plugin's bundle.
+ "Serve the plugin's icon image from its bundle.
The asset path is passed as a `path` query parameter (e.g. `?path=icon.svg`)
- and must match an entry in the manifest's `assets` whitelist.
- Only image files are served.
+ and must match the manifest `icon`. Only the icon is served — plugins do not
+ ship arbitrary assets.
In dev mode, proxies from the dev base URL if set."
[{:keys [id]} :- [:map [:id ms/PositiveInt]]
{:keys [path]} :- [:map [:path ms/NonBlankString]]
diff --git a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/cache.clj b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/cache.clj
index faecc42dd54..ae38c1cbda7 100644
--- a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/cache.clj
+++ b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/cache.clj
@@ -43,7 +43,7 @@
;; The uploaded archive has the same layout as the previous git-sourced plugins:
;; metabase-plugin.json (manifest, at the archive root)
;; dist/index.js (the JS bundle)
-;; dist/assets/* (static assets)
+;; dist/assets/<icon> (the manifest icon — the only servable asset)
(def ^:private ^:const bundle-rel-path "index.js")
@@ -71,10 +71,10 @@
(* 5 max-bundle-bytes))
(def ^:const ^:private max-entries
- "Cap on entry count in a bundle archive. A real plugin has a manifest, the JS
- bundle, and a handful of image assets; 256 leaves plenty of slack without
- inviting denial-of-service via metadata-only entries."
- 256)
+ "Cap on entry count in a bundle archive. A real plugin is just the manifest, the
+ JS bundle, and the icon (plus a couple of directory entries); 16 leaves slack
+ without inviting denial-of-service via metadata-only entries."
+ 16)
(def ^:private untgz-opts
{:max-uncompressed-bytes max-uncompressed-bytes
@@ -277,7 +277,8 @@
:hash (or (:bundle_hash plugin) (bytes-hash bytes))}))
(defn- asset-whitelisted?
- "Check whether an asset path is explicitly listed in the plugin's manifest."
+ "Check whether an asset path is servable for the plugin. Only the manifest `icon`
+ is servable — see [[metabase-enterprise.custom-viz-plugin.manifest/asset-paths]]."
[{:keys [manifest]} ^String asset-path]
(when manifest
(let [allowed (set (manifest/asset-paths manifest))]
diff --git a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/manifest.clj b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/manifest.clj
index 0d76557135d..12a409096fc 100644
--- a/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/manifest.clj
+++ b/enterprise/backend/src/metabase_enterprise/custom_viz_plugin/manifest.clj
@@ -59,16 +59,6 @@
(let [lower (u/lower-case-en path)]
(some #(str/ends-with? lower %) image-extensions)))
-(def ^:private allowed-asset-extensions
- "File extensions allowed for static asset serving (images + JSON)."
- (into image-extensions #{".json"}))
-
-(defn- allowed-asset-file?
- "Returns true if the file path has a recognized allowed extension."
- [^String path]
- (let [lower (u/lower-case-en path)]
- (some #(str/ends-with? lower %) allowed-asset-extensions)))
-
(defn safe-relative-path?
"Returns true if path normalizes to a relative path with no directory traversal."
[^String path]
@@ -77,25 +67,19 @@
(not (.startsWith normalized "..")))))
(defn asset-paths
- "List the static asset paths whitelisted by the manifest.
- Includes paths from the `assets` array (filtered to allowed extensions and
- safe relative paths) and the `icon` (if it's an image filename).
- Only explicitly listed paths are supported — no glob patterns."
+ "List the static asset paths the backend will serve for a plugin.
+ Custom viz plugins do not ship arbitrary assets — the only servable asset is the
+ plugin `icon` (when it's an image with a safe relative path). Authors who need
+ images inline them (e.g. base64) into their single JS bundle."
[manifest]
- (let [declared (filter (every-pred allowed-asset-file? safe-relative-path?) (get manifest :assets []))
- icon-name (when-let [icon (:icon manifest)]
- (when (and (image-file? icon) (safe-relative-path? icon)) icon))]
- (distinct (concat declared (when icon-name [icon-name])))))
+ (when-let [icon (:icon manifest)]
+ (when (and (image-file? icon) (safe-relative-path? icon))
+ [icon])))
(defn asset-content-type
- "Return the MIME content type for an allowed asset file, or nil if not recognized.
- Allows image files and JSON files (for locale translations)."
+ "Return the MIME content type for an image asset file, or nil if not recognized.
+ Only the plugin icon is served, so only image types are allowed."
[^String path]
- (cond
- (str/ends-with? path ".json")
- "application/json"
-
- :else
- (let [ct (java.net.URLConnection/guessContentTypeFromName path)]
- (when (and ct (str/starts-with? ct "image/"))
- ct))))
+ (let [ct (java.net.URLConnection/guessContentTypeFromName path)]
+ (when (and ct (str/starts-with? ct "image/"))
+ ct)))
diff --git a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/api_test.clj b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/api_test.clj
index 2ab96de2a23..212984475f8 100644
--- a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/api_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/api_test.clj
@@ -226,9 +226,8 @@
(deftest asset-endpoint-security-test
(mt/with-premium-features #{:custom-viz}
- (let [manifest {:name "sec-test"
- :icon "icon.svg"
- :assets ["icon.svg"]}]
+ (let [manifest {:name "sec-test"
+ :icon "icon.svg"}]
(mt/with-temp [:model/CustomVizPlugin {id :id} {:identifier "sec-test"
:display_name "sec-test"
:status :active
diff --git a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/cache_test.clj b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/cache_test.clj
index 8eae07e1179..c230c4c1f47 100644
--- a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/cache_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/cache_test.clj
@@ -143,22 +143,26 @@
;;; ------------------------------------------------ Asset Whitelist ------------------------------------------------
(deftest resolve-asset-whitelist-test
- (testing "SECURITY: resolve-asset enforces manifest whitelist"
+ (testing "SECURITY: resolve-asset only serves the manifest icon"
(mt/with-premium-features #{:custom-viz}
- (let [manifest {:name "test-viz"
- :icon "icon.svg"
- :assets ["icon.svg" "thumb.png"]}]
+ (let [manifest {:name "test-viz"
+ :icon "icon.svg"}]
(mt/with-temp [:model/CustomVizPlugin plugin {:identifier "test-viz"
:display_name "test-viz"
:status :active
:bundle_hash "abc123"
:manifest manifest}]
- (testing "returns nil for assets not in manifest whitelist"
- (is (nil? (cache/resolve-asset plugin "not-listed.png"))))
- (testing "returns nil for path traversal attempts"
- (is (nil? (cache/resolve-asset plugin "../../../etc/passwd"))))
- (testing "returns nil for absolute path attempts"
- (is (nil? (cache/resolve-asset plugin "/etc/passwd")))))))))
+ (with-redefs [cache/get-asset (fn [_ asset-name] (.getBytes (str "bytes:" asset-name) "UTF-8"))]
+ (testing "serves the manifest icon"
+ (is (= "bytes:icon.svg"
+ (some-> (cache/resolve-asset plugin "icon.svg") (String. "UTF-8")))))
+ (testing "returns nil for any asset other than the icon"
+ (is (nil? (cache/resolve-asset plugin "thumb.png")))
+ (is (nil? (cache/resolve-asset plugin "not-listed.png"))))
+ (testing "returns nil for path traversal attempts"
+ (is (nil? (cache/resolve-asset plugin "../../../etc/passwd"))))
+ (testing "returns nil for absolute path attempts"
+ (is (nil? (cache/resolve-asset plugin "/etc/passwd"))))))))))
;;; ------------------------------------------------ insert-bundle!/save-bundle! state consistency ------------------------------------------------
diff --git a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/manifest_test.clj b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/manifest_test.clj
index 3ed4e8452b0..6cfe558c150 100644
--- a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/manifest_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/manifest_test.clj
@@ -73,29 +73,22 @@
;;; ------------------------------------------------ Asset Paths ------------------------------------------------
(deftest asset-paths-test
- (testing "filters to allowed extensions"
- (is (= ["icon.svg" "thumb.png"]
- (manifest/asset-paths {:assets ["icon.svg" "thumb.png" "malware.exe"]}))))
- (testing "includes icon from manifest"
- (is (some #{"icon.svg"} (manifest/asset-paths {:icon "icon.svg"}))))
- (testing "allows JSON assets (for locale translations)"
- (is (some #{"en.json"} (manifest/asset-paths {:assets ["en.json"]}))))
- (testing "rejects non-image non-JSON assets"
- (is (not (some #{"script.js"} (manifest/asset-paths {:assets ["script.js"]}))))
- (is (not (some #{"data.csv"} (manifest/asset-paths {:assets ["data.csv"]})))))
- (testing "rejects assets with path traversal"
- (is (empty? (manifest/asset-paths {:assets ["../../../etc/passwd"]}))))
- (testing "rejects absolute asset paths"
- (is (empty? (manifest/asset-paths {:assets ["/etc/passwd"]}))))
- (testing "rejects icon with traversal"
- (is (not (some #{"../secret.svg"} (manifest/asset-paths {:icon "../secret.svg"})))))
- (testing "deduplicates"
+ (testing "returns the icon when it's a safe image"
+ (is (= ["icon.svg"] (manifest/asset-paths {:icon "icon.svg"})))
+ (is (= ["icon.png"] (manifest/asset-paths {:icon "icon.png"}))))
+ (testing "returns nil when there is no icon"
+ (is (nil? (manifest/asset-paths {})))
+ (is (nil? (manifest/asset-paths {:icon nil}))))
+ (testing "rejects a non-image icon"
+ (is (nil? (manifest/asset-paths {:icon "icon.js"}))))
+ (testing "rejects an icon with path traversal"
+ (is (nil? (manifest/asset-paths {:icon "../secret.svg"})))
+ (is (nil? (manifest/asset-paths {:icon "/etc/passwd.svg"}))))
+ (testing "ignores a stray assets array — only the icon is ever served"
(is (= ["icon.svg"]
- (manifest/asset-paths {:icon "icon.svg" :assets ["icon.svg"]}))))
- (testing "icon is auto-included without being listed in assets"
- (is (= #{"icon.svg" "thumbs-up.png" "thumbs-down.png"}
- (set (manifest/asset-paths {:icon "icon.svg"
- :assets ["thumbs-up.png" "thumbs-down.png"]}))))))
+ (manifest/asset-paths {:icon "icon.svg"
+ :assets ["thumbs-up.png" "thumbs-down.png" "en.json"]})))
+ (is (nil? (manifest/asset-paths {:assets ["thumbs-up.png"]})))))
;;; ------------------------------------------------ Content Type ------------------------------------------------
@@ -104,12 +97,10 @@
(is (= "image/svg+xml" (manifest/asset-content-type "icon.svg")))
(is (= "image/png" (manifest/asset-content-type "thumb.png")))
(is (= "image/jpeg" (manifest/asset-content-type "photo.jpg"))))
- (testing "recognizes JSON"
- (is (= "application/json" (manifest/asset-content-type "en.json"))))
- (testing "returns nil for disallowed types"
+ (testing "returns nil for non-image types — assets (incl. JSON) are no longer served"
+ (is (nil? (manifest/asset-content-type "en.json")))
(is (nil? (manifest/asset-content-type "script.js")))
(is (nil? (manifest/asset-content-type "style.css")))
- (is (nil? (manifest/asset-content-type "data.csv"))))
- (testing "returns nil for non-image MIME types"
+ (is (nil? (manifest/asset-content-type "data.csv")))
;; .html has MIME text/html — should be rejected
(is (nil? (manifest/asset-content-type "page.html")))))
diff --git a/enterprise/frontend/src/custom-viz/package.json b/enterprise/frontend/src/custom-viz/package.json
index e452df55e94..3d006c576ec 100644
--- a/enterprise/frontend/src/custom-viz/package.json
+++ b/enterprise/frontend/src/custom-viz/package.json
@@ -1,6 +1,6 @@
{
"name": "@metabase/custom-viz",
- "version": "1.0.1",
+ "version": "1.0.2",
"description": "Creating custom visualizations for Metabase",
"type": "module",
"bin": {
diff --git a/enterprise/frontend/src/custom-viz/src/cli.integration.spec.ts b/enterprise/frontend/src/custom-viz/src/cli.integration.spec.ts
index e966f77d25a..db5603584c2 100644
--- a/enterprise/frontend/src/custom-viz/src/cli.integration.spec.ts
+++ b/enterprise/frontend/src/custom-viz/src/cli.integration.spec.ts
@@ -53,7 +53,8 @@ describe("build output validation", () => {
const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
expect(manifest.name).toBe("test-viz-build");
expect(manifest).toHaveProperty("icon");
- expect(manifest).toHaveProperty("assets");
+ // Custom viz no longer ship arbitrary assets — only the icon is served.
+ expect(manifest).not.toHaveProperty("assets");
});
it("build produces an upload-ready .tgz", () => {
diff --git a/enterprise/frontend/src/custom-viz/src/cli.ts b/enterprise/frontend/src/custom-viz/src/cli.ts
index 7372e17274c..4a66abe3921 100644
--- a/enterprise/frontend/src/custom-viz/src/cli.ts
+++ b/enterprise/frontend/src/custom-viz/src/cli.ts
@@ -20,7 +20,6 @@ import {
generateReadme,
generateTsConfig,
generateViteConfig,
- readBinaryTemplate,
} from "./templates";
const program = new Command();
@@ -68,14 +67,6 @@ program
),
writeFile(join(name, "metabase-plugin.json"), generateManifest(name)),
writeFile(join(name, "public", "assets", "icon.svg"), generateIconSvg()),
- writeFile(
- join(name, "public", "assets", "thumbs-up.png"),
- readBinaryTemplate("thumbs-up.png"),
- ),
- writeFile(
- join(name, "public", "assets", "thumbs-down.png"),
- readBinaryTemplate("thumbs-down.png"),
- ),
writeFile(join(name, ".gitignore"), generateGitignore()),
writeFile(join(name, "README.md"), generateReadme(name, displayName)),
]);
@@ -88,8 +79,6 @@ program
console.log(` ${name}/src/index.tsx`);
console.log(` ${name}/metabase-plugin.json`);
console.log(` ${name}/public/assets/icon.svg`);
- console.log(` ${name}/public/assets/thumbs-up.png`);
- console.log(` ${name}/public/assets/thumbs-down.png`);
console.log(` ${name}/.gitignore`);
console.log(` ${name}/README.md`);
console.log();
diff --git a/enterprise/frontend/src/custom-viz/src/cli.unit.spec.ts b/enterprise/frontend/src/custom-viz/src/cli.unit.spec.ts
index c99d200a935..50730d7eb13 100644
--- a/enterprise/frontend/src/custom-viz/src/cli.unit.spec.ts
+++ b/enterprise/frontend/src/custom-viz/src/cli.unit.spec.ts
@@ -74,8 +74,6 @@ describe("cli init", () => {
"src/index.tsx",
"metabase-plugin.json",
"public/assets/icon.svg",
- "public/assets/thumbs-up.png",
- "public/assets/thumbs-down.png",
".gitignore",
];
diff --git a/enterprise/frontend/src/custom-viz/src/templates.ts b/enterprise/frontend/src/custom-viz/src/templates.ts
index 36ad8af1c29..d704f64b408 100644
--- a/enterprise/frontend/src/custom-viz/src/templates.ts
+++ b/enterprise/frontend/src/custom-viz/src/templates.ts
@@ -1,7 +1,3 @@
-import { readFileSync } from "node:fs";
-import { dirname, join } from "node:path";
-import { fileURLToPath } from "node:url";
-
import { version } from "../package.json";
import gitignoreTemplate from "./templates/.gitignore?raw";
@@ -64,17 +60,6 @@ export function generateIconSvg(): string {
return iconSvgTemplate;
}
-// Binary templates can't use ?raw imports, so we read them from disk.
-// The build step copies src/templates/ to dist/templates/.
-const TEMPLATES_DIR = join(
- dirname(fileURLToPath(import.meta.url)),
- "templates",
-);
-
-export function readBinaryTemplate(filename: string): Buffer {
- return readFileSync(join(TEMPLATES_DIR, filename));
-}
-
export function generateGitignore(): string {
return gitignoreTemplate;
}
diff --git a/enterprise/frontend/src/custom-viz/src/templates/README.md b/enterprise/frontend/src/custom-viz/src/templates/README.md
index 940550a510c..204ae5ae062 100644
--- a/enterprise/frontend/src/custom-viz/src/templates/README.md
+++ b/enterprise/frontend/src/custom-viz/src/templates/README.md
@@ -27,11 +27,10 @@ npm run build # Compiles src/ → dist/, then packages it into a .tgz
```
src/
index.tsx # Your visualization code — start here
-metabase-plugin.json # Plugin manifest (name, icon, assets, version)
+metabase-plugin.json # Plugin manifest (name, icon, version)
public/
assets/
icon.svg # Visualization icon (shown in chart type picker)
- ... # Any other static assets
vite.config.ts # Build configuration (do not edit)
tsconfig.json
```
@@ -62,19 +61,17 @@ To develop against a live Metabase instance with hot-reload:
{
"name": "__CUSTOM_VIZ_NAME__",
"icon": "icon.svg",
- "assets": ["image.png"],
"metabase": {
"version": ">=1.60.0"
}
}
```
-| Field | Description |
-| ------------------ | ------------------------------------------------------------------------------------------------ |
-| `name` | Unique identifier for the plugin. Must match the `id` returned by your visualization factory. |
-| `icon` | Path to the visualization icon (SVG recommended). Automatically served — do not add to `assets`. |
-| `assets` | Additional static files to bundle (images and JSON only). Reference them via `getAssetUrl()`. |
-| `metabase.version` | Semver range of compatible Metabase versions (e.g. `">=1.60.0"`, `"^1.60"`). |
+| Field | Description |
+| ------------------ | -------------------------------------------------------------------------------------------- |
+| `name` | Unique identifier for the plugin. Must match the `id` returned by your visualization factory. |
+| `icon` | Path to the visualization icon (SVG recommended). Served automatically. |
+| `metabase.version` | Semver range of compatible Metabase versions (e.g. `">=1.60.0"`, `"^1.60"`). |
---
@@ -91,7 +88,6 @@ type Settings = {
const createVisualization: CreateCustomVisualization<Settings> = ({
defineSetting,
- getAssetUrl,
locale,
}) => {
const VisualizationComponent = ({ series, settings, width, height }) => {
@@ -207,24 +203,26 @@ settings: {
---
-## Using Assets
+## Using Images
-1. Declare assets in `metabase-plugin.json` under `"assets"` (images and JSON files only).
-2. Place files in `public/assets/` during development — they're copied to `dist/assets/` on build.
-3. Reference them in code using `getAssetUrl("filename.png")`.
+A custom visualization is a single JS bundle — it cannot load separate image files
+from the Metabase instance. To use an image, **inline it into your bundle**:
+
+- Embed a raster image as a base64 `data:` URL (this is what the generated
+ `src/index.tsx` does), or
+- Draw it as inline `<svg>` (best for icons and simple graphics):
```tsx
-const createVisualization: CreateCustomVisualization<Settings> = ({
- getAssetUrl,
-}) => {
- // ...
- return <img src={getAssetUrl("my-image.png")} />;
-};
+const myImage = "data:image/png;base64,iVBORw0KGgo...";
+
+// ...
+return <img src={myImage} alt="My image" />;
```
-`getAssetUrl()` returns the correct URL in both interactive rendering and development mode.
+You can also reference images hosted on your own domain (`<img src="https://example.com/1.png" />`).
-> **Note:** The plugin icon is declared separately as `"icon"` in the manifest and is served automatically — do not add it to `"assets"`.
+> **Note:** The only file served from the instance is the plugin `icon`, declared via
+> `"icon"` in the manifest.
---
diff --git a/enterprise/frontend/src/custom-viz/src/templates/index.tsx b/enterprise/frontend/src/custom-viz/src/templates/index.tsx
index 73dfecfdbb4..17961cf014c 100644
--- a/enterprise/frontend/src/custom-viz/src/templates/index.tsx
+++ b/enterprise/frontend/src/custom-viz/src/templates/index.tsx
@@ -10,7 +10,6 @@ type Settings = {
const createVisualization: CreateCustomVisualization<Settings> = ({
defineSetting,
- getAssetUrl,
}) => {
const VisualizationComponent = ({
height,
@@ -41,18 +40,13 @@ const createVisualization: CreateCustomVisualization<Settings> = ({
height: "100%",
}}
>
- <img
- alt={meetsThreshold ? "Above threshold" : "Below threshold"}
- src={
- meetsThreshold
- ? getAssetUrl("thumbs-up.png")
- : getAssetUrl("thumbs-down.png")
- }
- style={{
- height: finalHeight,
- width: "auto",
- }}
- />
+ <div
+ role="img"
+ aria-label={meetsThreshold ? "Above threshold" : "Below threshold"}
+ style={{ fontSize: finalHeight, lineHeight: 1 }}
+ >
+ {meetsThreshold ? "👍" : "👎"}
+ </div>
</div>
);
};
diff --git a/enterprise/frontend/src/custom-viz/src/templates/metabase-plugin.json b/enterprise/frontend/src/custom-viz/src/templates/metabase-plugin.json
index 2cc8059a22b..4d217dee5fc 100644
--- a/enterprise/frontend/src/custom-viz/src/templates/metabase-plugin.json
+++ b/enterprise/frontend/src/custom-viz/src/templates/metabase-plugin.json
@@ -1,7 +1,6 @@
{
"name": "__CUSTOM_VIZ_NAME__",
"icon": "icon.svg",
- "assets": ["thumbs-up.png", "thumbs-down.png"],
"metabase": {
"version": ">=1.60.0"
}
diff --git a/enterprise/frontend/src/custom-viz/src/templates/thumbs-down.png b/enterprise/frontend/src/custom-viz/src/templates/thumbs-down.png
deleted file mode 100644
index 2ca42c70ee7..00000000000
Binary files a/enterprise/frontend/src/custom-viz/src/templates/thumbs-down.png and /dev/null differ
diff --git a/enterprise/frontend/src/custom-viz/src/templates/thumbs-up.png b/enterprise/frontend/src/custom-viz/src/templates/thumbs-up.png
deleted file mode 100644
index ec27c0ca206..00000000000
Binary files a/enterprise/frontend/src/custom-viz/src/templates/thumbs-up.png and /dev/null differ
diff --git a/enterprise/frontend/src/custom-viz/src/types/viz.ts b/enterprise/frontend/src/custom-viz/src/types/viz.ts
index f66daa137a3..f6bcd8fdf00 100644
--- a/enterprise/frontend/src/custom-viz/src/types/viz.ts
+++ b/enterprise/frontend/src/custom-viz/src/types/viz.ts
@@ -21,13 +21,6 @@ export type CreateCustomVisualizationProps<
> = {
defineSetting: ReturnType<CreateDefineSetting<TSettings>>;
- /**
- * Returns a URL for a static asset declared in the plugin manifest.
- * Use this to reference images and other static files from your plugin.
- * @example getAssetUrl("icon.svg")
- */
- getAssetUrl: (assetPath: string) => string;
-
/**
* Locale to render visualization with (e.g. "de", "ja", "en").
*/
diff --git a/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx b/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx
index a899f73b9d3..14fc7f9ca77 100644
--- a/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx
@@ -310,17 +310,12 @@ export async function loadCustomVizPlugin(
);
}
- const cacheBust = cacheBustSuffix ? `&t=${Date.now()}` : "";
-
const props: CreateCustomVisualizationProps<Record<string, unknown>> = {
defineSetting(definition) {
return definition as unknown as CustomVisualizationSettingDefinition<
Record<string, unknown>
>;
},
- getAssetUrl(path: string) {
- return `${getPluginAssetUrl(plugin.id, path) ?? ""}${cacheBust}`;
- },
locale:
window.MetabaseUserLocalization?.headers?.language ??
window.MetabaseSiteLocalization?.headers?.language ??
diff --git a/frontend/src/metabase-types/api/custom-viz-plugin.ts b/frontend/src/metabase-types/api/custom-viz-plugin.ts
index d6b9ac33c01..c88a622a435 100644
--- a/frontend/src/metabase-types/api/custom-viz-plugin.ts
+++ b/frontend/src/metabase-types/api/custom-viz-plugin.ts
@@ -4,7 +4,6 @@ export interface CustomVizPluginManifest {
metabase?: {
version?: string;
};
- assets?: string[];
}
export type CustomVizPluginId = number;