From abe5b33ee1200399cfe5fbdecccc430c6f434063 Mon Sep 17 00:00:00 2001 From: harish-sethuraman Date: Tue, 20 Aug 2024 12:12:11 +0530 Subject: [PATCH 1/5] feat: add report an issue button --- .../components/playground-configuration.scss | 5 +++ src/playground/App.js | 1 + src/playground/components/Configuration.js | 3 +- src/playground/components/ShareURL.js | 32 +++++++++++++++++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/assets/scss/components/playground-configuration.scss b/src/assets/scss/components/playground-configuration.scss index a3037cf11..691d18765 100644 --- a/src/assets/scss/components/playground-configuration.scss +++ b/src/assets/scss/components/playground-configuration.scss @@ -242,6 +242,11 @@ } } +.report-issue-btn { + width: 100%; + margin-top: 20px; +} + .playground__config-options__section--rules { font-size: 0.875rem; } diff --git a/src/playground/App.js b/src/playground/App.js index 7609750c1..0dd727575 100644 --- a/src/playground/App.js +++ b/src/playground/App.js @@ -334,6 +334,7 @@ const App = () => { data-open={isConfigHidden ? true : showConfigMenu} > Object.keys(obj).length === 0; export default function Configuration({ rulesMeta, eslintVersion, + errors, onUpdate, options, ruleNames, @@ -227,7 +228,7 @@ export default function Configuration({ return (
- +
+ +
)} From e9b4fbbcc1aae25d54f311b6b929da28aa1f485f Mon Sep 17 00:00:00 2001 From: harish-sethuraman Date: Wed, 28 Aug 2024 12:47:10 +0530 Subject: [PATCH 2/5] chore: add configuration to report button --- src/playground/components/Configuration.js | 6 +++++- src/playground/components/ShareURL.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/playground/components/Configuration.js b/src/playground/components/Configuration.js index 980ccbe9d..c17913c60 100644 --- a/src/playground/components/Configuration.js +++ b/src/playground/components/Configuration.js @@ -228,7 +228,11 @@ export default function Configuration({ return (
- +
diff --git a/src/playground/components/ShareURL.js b/src/playground/components/ShareURL.js index ed8aa43a7..ab57cbdb8 100644 --- a/src/playground/components/ShareURL.js +++ b/src/playground/components/ShareURL.js @@ -1,5 +1,9 @@ import React, { useState } from "react"; +const getTemplate = code => `\`\`\`js +${code} +\`\`\``; + export default function ShareURL({ url, errors, config }) { const [isDataCopied, setIsDataCopied] = useState(false); const [showShareURL, setShowShareURL] = useState(false); @@ -105,7 +109,7 @@ export default function ShareURL({ url, errors, config }) { `${line}:${column} ${message} (${ruleId})`, ) .join("\n"), - description: `
Configuration${config}
`, + description: getTemplate(config), }; Object.entries(params).forEach(([key, value]) => { From c8a1fc55dabcd0ab6c3b50634ab143829b0bdd59 Mon Sep 17 00:00:00 2001 From: harish-sethuraman Date: Wed, 11 Sep 2024 22:23:15 +0530 Subject: [PATCH 5/5] fix: longer urls --- src/playground/components/ShareURL.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/playground/components/ShareURL.js b/src/playground/components/ShareURL.js index ab57cbdb8..17e22c48e 100644 --- a/src/playground/components/ShareURL.js +++ b/src/playground/components/ShareURL.js @@ -116,6 +116,17 @@ export default function ShareURL({ url, errors, config }) { reportUrl.searchParams.append(key, value); }); + if (reportUrl.search.length > 8148) { + reportUrl.searchParams.set( + "description", + "", + ); + + navigator?.clipboard.writeText( + getTemplate(config), + ); + } + window.open(reportUrl, "_blank"); }} className="c-btn c-btn--secondary report-issue-btn"