Skip to content
Snippets Groups Projects
Unverified Commit 160bb8dd authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

SecretKeyWidget accepts confirmation header and dialogs (#32598)

* SecretKeyWidget accepts confirmation header and dialogs

* removing default confirmation values, adding e2e test
parent 8fb5cf9f
Branches
Tags
No related merge requests found
......@@ -64,7 +64,13 @@ describeEE("scenarios > admin > settings > SSO > JWT", () => {
cy.visit("/admin/settings/authentication/jwt");
cy.button("Regenerate key").click();
modal().button("Yes").click();
modal().within(() => {
cy.findByText("Regenerate JWT signing key?").should("exist");
cy.findByText(
"This will cause existing tokens to stop working until the identity provider is updated with the new key.",
).should("exist");
cy.button("Yes").click();
});
cy.button("Save changes").click();
cy.wait("@updateSettings");
......
import { restore, modal } from "e2e/support/helpers";
const embeddingPage = "/admin/settings/embedding-in-other-applications";
describe("scenarios > embedding > standalone embedding", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("should allow you to set and regenerate an embedding token", () => {
cy.visit(embeddingPage);
cy.findByTestId("-standalone-embeds-setting")
.findByText("Standalone embeds")
.click();
cy.findByRole("button", { name: "Regenerate key" }).click();
modal().within(() => {
cy.findByText("Regenerate embedding key?").should("exist");
cy.findByText(
"This will cause existing embeds to stop working until they are updated with the new key.",
).should("exist");
});
});
});
......@@ -181,6 +181,12 @@ PLUGIN_ADMIN_SETTINGS_UPDATES.push(sections => ({
required: true,
widget: SecretKeyWidget,
getHidden: settings => !settings["jwt-enabled"],
props: {
confirmation: {
header: t`Regenerate JWT signing key?`,
dialog: t`This will cause existing tokens to stop working until the identity provider is updated with the new key.`,
},
},
},
{
key: "jwt-attribute-email",
......
......@@ -7,11 +7,16 @@ import { GenerateButton, SecretKeyWidgetRoot } from "./SecretKeyWidget.styled";
interface SecretKeyWidgetProps {
onChange: (token: string) => void;
setting: any;
confirmation: {
header: string;
dialog: string;
};
}
const SecretKeyWidget = ({
onChange,
setting,
confirmation,
...rest
}: SecretKeyWidgetProps) => {
const generateToken = async () => {
......@@ -25,8 +30,8 @@ const SecretKeyWidget = ({
{setting.value ? (
<Confirm
triggerClasses="full-height"
title={t`Regenerate embedding key?`}
content={t`This will cause existing embeds to stop working until they are updated with the new key.`}
title={confirmation.header}
content={confirmation.dialog}
action={generateToken}
>
<GenerateButton primary>{t`Regenerate key`}</GenerateButton>
......
......@@ -515,6 +515,12 @@ const SECTIONS = {
description: t`Standalone Embed Secret Key used to sign JSON Web Tokens for requests to /api/embed endpoints. This lets you create a secure environment limited to specific users or organizations.`,
widget: SecretKeyWidget,
getHidden: (_, derivedSettings) => !derivedSettings["enable-embedding"],
props: {
confirmation: {
header: t`Regenerate embedding key?`,
dialog: t`This will cause existing embeds to stop working until they are updated with the new key.`,
},
},
},
{
key: "-embedded-dashboards",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment