From 8e09d1552280a1733f86be19bb1d75a9ee329b5f Mon Sep 17 00:00:00 2001 From: Timur Carpeev Date: Tue, 24 Jan 2023 09:35:29 +0100 Subject: [PATCH] Add playground headers (#3016) * Add playground headers * Small refactor, messages generation * Small refactor, messages generation * Ci * Ci Co-authored-by: andrzejewsky --- .github/workflows/approveAndMergeReleasePR.js | 4 +- locale/defaultMessages.json | 20 ++++++-- .../TokenCreateDialog/TokenCreateDialog.tsx | 50 ++++++++++++++++--- .../components/TokenCreateDialog/styles.ts | 7 +++ 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/.github/workflows/approveAndMergeReleasePR.js b/.github/workflows/approveAndMergeReleasePR.js index 5687b4320..09c524a41 100644 --- a/.github/workflows/approveAndMergeReleasePR.js +++ b/.github/workflows/approveAndMergeReleasePR.js @@ -91,8 +91,8 @@ program } requestBody += `\nIf this bugs won't be fixed in next patch release for this version mark them as known issues`; } - }else if(testsStatus === "ERRORED"){ - requestBody = `Tests ERRORED! Check log at ${options.dashboard_url}` + } else if (testsStatus === "ERRORED") { + requestBody = `Tests ERRORED! Check log at ${options.dashboard_url}`; } const event = "COMMENT"; diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 733b90735..7c263674d 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -300,6 +300,10 @@ "context": "min price in channel", "string": "Min. value" }, + "0KmZCN": { + "context": "button", + "string": "Open playground" + }, "0MetrR": { "context": "webhook input help text", "string": "This URL will receive webhook POST requests" @@ -827,6 +831,9 @@ "context": "tracking number", "string": "Tracking Number: {trackingNumber}" }, + "4T/RzC": { + "string": "Make sure to save token, you won’t be able to see it again." + }, "4VOIum": { "context": "product availability", "string": "Enabling this checkbox will remove product from search and category pages. It will be available on collection pages." @@ -975,6 +982,9 @@ "5ZvuVw": { "string": "No products matching given query" }, + "5ZxAiY": { + "string": "Token" + }, "5aiFbL": { "context": "tabel column header", "string": "Price" @@ -4567,6 +4577,9 @@ "context": "error message", "string": "Cannot choose a shipping method for an order without the shipping address" }, + "Wm+KUd": { + "string": "Headers" + }, "WnlZMO": { "context": "title", "string": "There’s a problem with app." @@ -4965,6 +4978,10 @@ "context": "button", "string": "Copy" }, + "ZhqH8J": { + "context": "button", + "string": "Copy headers" + }, "Zhxu58": { "context": "Fixed amount subtitle", "string": "Fixed amount" @@ -7275,9 +7292,6 @@ "context": "voucher status", "string": "Expired" }, - "t9a9GQ": { - "string": "We’ve created your token. Make sure to copy your new personal access token now. You won’t be able to see it again." - }, "tA5HJx": { "context": "webhook input help text", "string": "secret key is used to create a hash signature with each payload. *optional field" diff --git a/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx b/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx index 227fe83c0..cba743d78 100644 --- a/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx +++ b/src/custom-apps/components/TokenCreateDialog/TokenCreateDialog.tsx @@ -4,6 +4,7 @@ import CardSpacer from "@dashboard/components/CardSpacer"; import ConfirmButton from "@dashboard/components/ConfirmButton"; import Form from "@dashboard/components/Form"; import FormSpacer from "@dashboard/components/FormSpacer"; +import { getApiUrl } from "@dashboard/config"; import { SubmitPromise } from "@dashboard/hooks/useForm"; import useModalDialogOpen from "@dashboard/hooks/useModalDialogOpen"; import { buttonMessages } from "@dashboard/intl"; @@ -36,11 +37,18 @@ function handleCopy(token: string) { navigator.clipboard.writeText(token); } +const Mono = ({ children, className }) => ( + {children} +); +const createHeadersString = (token: string) => + `{\n "authorization": "Bearer ${token}"\n}`; + const TokenCreateDialog: React.FC = props => { const { confirmButtonState, open, token, onClose, onCreate } = props; const [step, setStep] = React.useState("form"); const intl = useIntl(); const classes = useStyles(props); + const headers = createHeadersString(token); React.useEffect(() => { if (token !== undefined) { @@ -52,6 +60,10 @@ const TokenCreateDialog: React.FC = props => { onClose: () => setStep("form"), }); + const openPlayground = () => { + window.open(getApiUrl(), "_blank"); + }; + return (
onCreate(data.name)}> @@ -89,20 +101,17 @@ const TokenCreateDialog: React.FC = props => { <> - + - {token} + {token} + + + + + + + {headers} + + + + + )} diff --git a/src/custom-apps/components/TokenCreateDialog/styles.ts b/src/custom-apps/components/TokenCreateDialog/styles.ts index ca7eff569..a55470578 100644 --- a/src/custom-apps/components/TokenCreateDialog/styles.ts +++ b/src/custom-apps/components/TokenCreateDialog/styles.ts @@ -8,12 +8,19 @@ export const useStyles = makeStyles( }, copy: { marginTop: theme.spacing(), + marginRight: theme.spacing(), position: "relative", right: theme.spacing(1), }, + mono: { + fontFamily: + "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace", + fontSize: theme.typography.caption.fontSize, + }, paper: { background: alpha(theme.palette.primary.main, 0.05), padding: theme.spacing(2, 3), + whiteSpace: "pre-wrap", }, }), {