Skip to content

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

Use Iframe for changelog (#62943)

Ryan Laurie63f9d193a901
diff --git a/e2e/test/scenarios/admin-2/settings.cy.spec.js b/e2e/test/scenarios/admin-2/settings.cy.spec.js
index 7fb62b356d8..fb09247b938 100644
--- a/e2e/test/scenarios/admin-2/settings.cy.spec.js
+++ b/e2e/test/scenarios/admin-2/settings.cy.spec.js
@@ -1343,26 +1343,26 @@ describe("admin > settings > updates", () => {
// we're mocking this so it can be stable for tests
const versionInfo = {
latest: {
- version: "v1.86.76",
+ version: "v1.56.4",
released: "2022-10-14",
rollout: 60,
highlights: ["New latest feature", "Another new feature"],
},
beta: {
- version: "v1.86.75.309",
+ version: "v1.56.75.3",
released: "2022-10-15",
rollout: 70,
highlights: ["New beta feature", "Another new feature"],
},
nightly: {
- version: "v1.86.75.311",
+ version: "v1.56.75.2",
released: "2022-10-16",
rollout: 80,
highlights: ["New nightly feature", "Another new feature"],
},
older: [
{
- version: "v1.86.75",
+ version: "v1.56.1",
released: "2022-10-10",
rollout: 100,
highlights: ["Some old feature", "Another old feature"],
@@ -1370,12 +1370,11 @@ describe("admin > settings > updates", () => {
],
};
- const currentVersion = "v1.86.70";
+ const currentVersion = "v1.55.2";
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
- cy.visit("/admin/settings/updates");
cy.intercept("GET", "/api/session/properties", (req) => {
req.continue((res) => {
@@ -1387,26 +1386,33 @@ describe("admin > settings > updates", () => {
cy.intercept("GET", "/api/setting/version-info", (req) => {
req.reply(versionInfo);
});
+
+ cy.visit("/admin/settings/updates");
});
+ const assertIframeLoaded = (testId) => {
+ cy.findByTestId(testId).should("be.visible");
+ cy.findByTestId(testId).should(($iframe) => {
+ const body = $iframe.contents().find("body");
+ expect(body).to.exist;
+ });
+ };
+
it("should show the updates page", () => {
cy.findByTestId("check-for-updates-setting")
.findByText("Check for updates")
.should("be.visible");
cy.findByTestId("settings-updates").within(() => {
- cy.findByText("Metabase 1.86.76 is available. You're running 1.86.70.");
- cy.findByText("Some old feature").should("be.visible");
- });
-
- cy.log("hide most things if updates are turned off");
+ cy.findByText(
+ "Metabase 1.56.4 is available. You're running 1.55.2.",
+ ).should("be.visible");
- cy.findByTestId("check-for-updates-setting")
- .findByText("Check for updates")
- .click();
+ cy.findByText("Changelog").should("be.visible").click();
+ assertIframeLoaded("changelog-iframe");
- cy.findByTestId("settings-updates").within(() => {
- cy.findByText("Some old feature").should("not.exist");
+ cy.findByText("What's new").should("be.visible").click();
+ assertIframeLoaded("releases-iframe");
});
});
});
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.tsx
index 4b6616fa240..fb5a1bb8189 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.tsx
@@ -12,6 +12,7 @@ import CS from "metabase/css/core/index.css";
import { AdminSettingInput } from "../widgets/AdminSettingInput";
import { VersionUpdateNotice } from "../widgets/VersionUpdateNotice";
+import { NewVersionInfo } from "../widgets/VersionUpdateNotice/VersionUpdateNotice";
export function UpdatesSettingsPage() {
const isHosted = useSetting("is-hosted?");
@@ -38,6 +39,7 @@ export function UpdatesSettingsPage() {
<VersionUpdateNotice />
</div>
)}
+ <NewVersionInfo />
</SettingsSection>
<UpsellHostingBanner location="settings-updates-migrate_to_cloud" />
</SettingsPageWrapper>
diff --git a/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.module.css b/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.module.css
index 7c98e69e8c1..3a1496631e8 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.module.css
+++ b/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.module.css
@@ -10,3 +10,11 @@
border-radius: 0.5rem;
background-color: var(--mb-color-brand);
}
+
+.iframe {
+ width: 100%;
+ height: 600px;
+ border: 1px solid var(--mb-color-border);
+ border-radius: 0.5rem;
+ margin-top: 1rem;
+}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.tsx b/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.tsx
index 2a4b46682aa..9fd9a07c85f 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/VersionUpdateNotice/VersionUpdateNotice.tsx
@@ -8,10 +8,12 @@ import ButtonsS from "metabase/css/components/buttons.module.css";
import CS from "metabase/css/core/index.css";
import { useSelector } from "metabase/lib/redux";
import { newVersionAvailable, versionIsLatest } from "metabase/lib/utils";
-import type { VersionInfo, VersionInfoRecord } from "metabase-types/api";
+import { Tabs } from "metabase/ui";
import S from "./VersionUpdateNotice.module.css";
+const embedQueryParams = "?hide_nav=true&no_gdpr=true";
+
export function VersionUpdateNotice() {
const { data: versionInfo } = useGetVersionInfoQuery();
const currentVersion = useSelector(getCurrentVersion);
@@ -27,7 +29,6 @@ export function VersionUpdateNotice() {
<NewVersionAvailable
currentVersion={displayVersion}
latestVersion={latestVersion}
- versionInfo={versionInfo}
/>
);
}
@@ -59,14 +60,10 @@ function DefaultUpdateMessage({ currentVersion }: { currentVersion: string }) {
function NewVersionAvailable({
currentVersion,
latestVersion,
- versionInfo,
}: {
currentVersion: string;
latestVersion: string;
- versionInfo?: VersionInfo | null;
}) {
- const lastestVersionInfo = versionInfo?.latest;
-
return (
<div>
<div
@@ -101,53 +98,44 @@ function NewVersionAvailable({
{t`Update`}
</ExternalLink>
</div>
-
- {versionInfo && (
- <div
- className={cx(
- CS.textMedium,
- CS.bordered,
- CS.rounded,
- CS.p2,
- CS.mt2,
- CS.overflowYScroll,
- )}
- style={{ height: 330 }}
- >
- <h3 className={cx(CS.pb3, CS.textUppercase)}>{t`What's Changed:`}</h3>
-
- {lastestVersionInfo && <Version version={lastestVersionInfo} />}
-
- {versionInfo.older &&
- versionInfo.older.map((version, index) => (
- <Version key={index} version={version} />
- ))}
- </div>
- )}
</div>
);
}
-function Version({ version }: { version: VersionInfoRecord }) {
- if (!version) {
- return null;
- }
+export function NewVersionInfo() {
+ const { data: versionInfo } = useGetVersionInfoQuery();
+ const latestMajorVersion = getLatestMajorVersion(
+ versionInfo?.latest?.version,
+ );
return (
- <div className={CS.pb3}>
- <h3 className={CS.textMedium}>{formatVersion(version.version)}</h3>
- <ul style={{ listStyleType: "disc", listStylePosition: "inside" }}>
- {version.highlights &&
- version.highlights.map((highlight, index) => (
- <li key={index} style={{ lineHeight: "1.5" }} className={CS.pl1}>
- {highlight}
- </li>
- ))}
- </ul>
- </div>
+ <Tabs mt="md" defaultValue="whats-new">
+ <Tabs.List>
+ <Tabs.Tab value="whats-new">{t`What's new`}</Tabs.Tab>
+ <Tabs.Tab value="changelog">{t`Changelog`}</Tabs.Tab>
+ </Tabs.List>
+ <Tabs.Panel value="whats-new">
+ <iframe
+ data-testid="releases-iframe"
+ src={`https://www.metabase.com/releases${embedQueryParams}`}
+ className={S.iframe}
+ />
+ </Tabs.Panel>
+ <Tabs.Panel value="changelog">
+ <iframe
+ data-testid="changelog-iframe"
+ src={`https://www.metabase.com/changelog/${latestMajorVersion}${embedQueryParams}`}
+ className={S.iframe}
+ />
+ </Tabs.Panel>
+ </Tabs>
);
}
+function getLatestMajorVersion(version: string | null | undefined) {
+ return version?.split(".")[1] ?? "";
+}
+
function formatVersion(versionLabel = "") {
return versionLabel.replace(/^v/, "");
}
diff --git a/src/metabase/server/middleware/security.clj b/src/metabase/server/middleware/security.clj
index 05466a4534a..6d6bb4a5a13 100644
--- a/src/metabase/server/middleware/security.clj
+++ b/src/metabase/server/middleware/security.clj
@@ -102,12 +102,17 @@
new-domain
(when (and port (not= domain "*")) (format ":%s" port))))))))
+(def ^:private always-allowed-iframe-hosts
+ ["'self'"
+ "https://www.metabase.com/"
+ "https://metabase.com/"])
+
(defn- parse-allowed-iframe-hosts*
[hosts-string]
(->> (str/split hosts-string #"[ ,\s\r\n]+")
(remove str/blank?)
(mapcat add-wildcard-entries)
- (into ["'self'"])))
+ (into always-allowed-iframe-hosts)))
(def ^{:doc "Parse the string of allowed iframe hosts, adding wildcard prefixes as needed."}
parse-allowed-iframe-hosts
diff --git a/test/metabase/server/middleware/security_test.clj b/test/metabase/server/middleware/security_test.clj
index b807e341aae..f49ef802a2e 100644
--- a/test/metabase/server/middleware/security_test.clj
+++ b/test/metabase/server/middleware/security_test.clj
@@ -55,9 +55,10 @@
(deftest csp-header-iframe-hosts-tests
(testing "Allowed iframe hosts setting is used in the CSP frame-src directive."
- (mt/with-temporary-setting-values [allowed-iframe-hosts "https://www.wikipedia.org, https://www.metabase.com https://clojure.org"]
- (is (= (str "frame-src 'self' https://wikipedia.org https://*.wikipedia.org https://www.wikipedia.org "
- "https://metabase.com https://*.metabase.com https://www.metabase.com "
+ (mt/with-temporary-setting-values [allowed-iframe-hosts "https://www.wikipedia.org, https://www.typescriptlang.org/ https://clojure.org"]
+ (is (= (str "frame-src 'self' https://www.metabase.com/ https://metabase.com/ "
+ "https://wikipedia.org https://*.wikipedia.org https://www.wikipedia.org "
+ "https://typescriptlang.org https://*.typescriptlang.org https://www.typescriptlang.org "
"https://clojure.org https://*.clojure.org")
(csp-directive "frame-src")))))
(testing "Includes 'self' so embed previews work (#49142)"
@@ -306,62 +307,63 @@
(testing "The allowed iframe hosts parse in the expected way."
(let [default-hosts @#'server.settings/default-allowed-iframe-hosts]
(testing "The defaults hosts parse correctly"
- (is (= ["'self'"
- "youtube.com"
- "*.youtube.com"
- "youtu.be"
- "*.youtu.be"
- "loom.com"
- "*.loom.com"
- "vimeo.com"
- "*.vimeo.com"
- "docs.google.com"
- "calendar.google.com"
- "airtable.com"
- "*.airtable.com"
- "typeform.com"
- "*.typeform.com"
- "canva.com"
- "*.canva.com"
- "codepen.io"
- "*.codepen.io"
- "figma.com"
- "*.figma.com"
- "grafana.com"
- "*.grafana.com"
- "miro.com"
- "*.miro.com"
- "excalidraw.com"
- "*.excalidraw.com"
- "notion.com"
- "*.notion.com"
- "atlassian.com"
- "*.atlassian.com"
- "trello.com"
- "*.trello.com"
- "asana.com"
- "*.asana.com"
- "gist.github.com"
- "linkedin.com"
- "*.linkedin.com"
- "twitter.com"
- "*.twitter.com"
- "x.com"
- "*.x.com"]
+ (is (= (concat @#'mw.security/always-allowed-iframe-hosts
+ ["youtube.com"
+ "*.youtube.com"
+ "youtu.be"
+ "*.youtu.be"
+ "loom.com"
+ "*.loom.com"
+ "vimeo.com"
+ "*.vimeo.com"
+ "docs.google.com"
+ "calendar.google.com"
+ "airtable.com"
+ "*.airtable.com"
+ "typeform.com"
+ "*.typeform.com"
+ "canva.com"
+ "*.canva.com"
+ "codepen.io"
+ "*.codepen.io"
+ "figma.com"
+ "*.figma.com"
+ "grafana.com"
+ "*.grafana.com"
+ "miro.com"
+ "*.miro.com"
+ "excalidraw.com"
+ "*.excalidraw.com"
+ "notion.com"
+ "*.notion.com"
+ "atlassian.com"
+ "*.atlassian.com"
+ "trello.com"
+ "*.trello.com"
+ "asana.com"
+ "*.asana.com"
+ "gist.github.com"
+ "linkedin.com"
+ "*.linkedin.com"
+ "twitter.com"
+ "*.twitter.com"
+ "x.com"
+ "*.x.com"])
(mw.security/parse-allowed-iframe-hosts default-hosts))))
(testing "Additional hosts a user may configure will parse correctly as well"
- (is (= ["'self'" "localhost"
- "http://localhost:8000"
- "my.domain.local:9876"
- "*"
- "mysite.com"
- "*.mysite.com"
- "www.mysite.com"
- "mysite.cool.com"
- "www.mysite.cool.com"]
+ (is (= (concat @#'mw.security/always-allowed-iframe-hosts
+ ["localhost"
+ "http://localhost:8000"
+ "my.domain.local:9876"
+ "*"
+ "mysite.com"
+ "*.mysite.com"
+ "www.mysite.com"
+ "mysite.cool.com"
+ "www.mysite.cool.com"])
(mw.security/parse-allowed-iframe-hosts "localhost, http://localhost:8000, my.domain.local:9876, *, www.mysite.com/, www.mysite.cool.com"))))
(testing "invalid hosts are not included"
- (is (= ["'self'"]
+ (is (= @#'mw.security/always-allowed-iframe-hosts
(mw.security/parse-allowed-iframe-hosts "asdf/wasd/:8000 */localhost:*")))))))
(defn- run-add-security-headers-mw-test! [enable-embedding-sdk-value