Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add report an issue button #616

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/assets/scss/components/playground-configuration.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
}
}

.report-issue-btn {
width: 100%;
margin-top: 20px;
}

.playground__config-options__section--rules {
font-size: 0.875rem;
}
Expand Down
1 change: 1 addition & 0 deletions src/playground/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const App = () => {
data-open={isConfigHidden ? true : showConfigMenu}
>
<Configuration
errors={messages}
ruleNames={ruleNames}
options={options}
onUpdate={updateOptions}
Expand Down
3 changes: 2 additions & 1 deletion src/playground/components/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const isEmpty = obj => Object.keys(obj).length === 0;
export default function Configuration({
rulesMeta,
eslintVersion,
errors,
onUpdate,
options,
ruleNames,
Expand Down Expand Up @@ -227,7 +228,7 @@ export default function Configuration({
return (
<div className="playground__config-options__sections">
<div className="playground__config-options__section">
<ShareURL url={window.location} />
<ShareURL errors={errors} url={window.location} />
</div>
<div className="playground__config-options__section">
<button
Expand Down
32 changes: 30 additions & 2 deletions src/playground/components/ShareURL.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";

export default function ShareURL({ url }) {
export default function ShareURL({ url, errors }) {
const [isDataCopied, setIsDataCopied] = useState(false);
const [showShareURL, setShowShareURL] = useState(false);

Expand All @@ -10,7 +10,7 @@ export default function ShareURL({ url }) {
className="playground-toggle c-btn c-btn--ghost"
onClick={() => setShowShareURL(currentValue => !currentValue)}
>
<h2 data-config-section-title>Share URL</h2>
<h2 data-config-section-title>Share</h2>
<svg
height="20"
width="20"
Expand Down Expand Up @@ -89,6 +89,34 @@ export default function ShareURL({ url }) {
</span>
)}
</div>

<button
onClick={() => {
const reportUrl = new URL(
"https://github.com/eslint/eslint/issues/new",
);
const params = {
labels: "bug,repro:yes",
template: "bug-report.yml",
"repro-url": window.location,
harish-sethuraman marked this conversation as resolved.
Show resolved Hide resolved
"lint-output": errors
.map(
({ line, column, message, ruleId }) =>
`${line}:${column} ${message} (${ruleId})`,
)
.join("\n"),
};

Object.entries(params).forEach(([key, value]) => {
reportUrl.searchParams.append(key, value);
});

window.open(reportUrl, "_blank");
}}
className="c-btn c-btn--secondary report-issue-btn"
>
Report an issue
</button>
</div>
)}
</div>
Expand Down
Loading