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: [playground]alert item add Disabled button. #546

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/playground/App.js
Expand Up @@ -233,6 +233,8 @@ const App = () => {
storeState({ newText: value });
}, 400), [storeState]);

const [rulesWithInvalidConfigs, setRulesWithInvalidConfigs] = useState(new Set([]));

return (
<div className="playground-wrapper">
<div className="playground__config-and-footer">
Expand All @@ -259,6 +261,8 @@ const App = () => {
rulesMeta={rulesMeta}
validationError={validationError}
eslintVersion={linter.version}
rulesWithInvalidConfigs={rulesWithInvalidConfigs}
setRulesWithInvalidConfigs={setRulesWithInvalidConfigs}
/>
<Footer />
</div>
Expand Down Expand Up @@ -302,6 +306,10 @@ const App = () => {
message={message}
suggestions={message.suggestions}
onFix={onFix}
options={options}
onUpdate={updateOptions}
rulesWithInvalidConfigs={rulesWithInvalidConfigs}
setRulesWithInvalidConfigs={setRulesWithInvalidConfigs}
/>
))}
</section>
Expand Down
22 changes: 18 additions & 4 deletions src/playground/components/Alert.js
@@ -1,6 +1,6 @@
import React from "react";

export default function Alert({ type, text, message, onFix }) {
export default function Alert({ type, text, message, onFix, options, onUpdate, rulesWithInvalidConfigs, setRulesWithInvalidConfigs }) {
if (!message) {
return (
<article aria-roledescription={type} className={`alert alert--${type}`}>
Expand Down Expand Up @@ -70,12 +70,26 @@ export default function Alert({ type, text, message, onFix }) {
</ul>
</>
) : (
fix && (
<button onClick={() => onFix(message)} className="alert__fix-btn">
<div style={{
display: "flex"
}}>
Comment on lines +73 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div style={{
display: "flex"
}}>
<div className="alert__actions">

Pls, avoid inline style. Create a class and add styles to that class.

In the alert.scss style file:

.alert__actions {
 display: flex:
}

{ fix && (
<button onClick={() => onFix(message)} className="alert__fix-btn" style={{ "border-radius": 0 }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<button onClick={() => onFix(message)} className="alert__fix-btn" style={{ "border-radius": 0 }}>
<button onClick={() => onFix(message)} className="alert__fix-btn">

Pls, avoid inline style. Try to add style to the existing class.

Fix
</button>
)}
<button
onClick={() => {
delete options.rules[ruleId];
setRulesWithInvalidConfigs(new Set([...rulesWithInvalidConfigs].filter(rule => rule !== ruleId)));
onUpdate(Object.assign({}, options));
}}
className="alert__fix-btn">
Turnoff
zhangenming marked this conversation as resolved.
Show resolved Hide resolved
</button>
)
</div>
)}

</article>
);
}
12 changes: 10 additions & 2 deletions src/playground/components/Configuration.js
Expand Up @@ -94,7 +94,16 @@ const defaultOption = {

const isEmpty = obj => Object.keys(obj).length === 0;

export default function Configuration({ rulesMeta, eslintVersion, onUpdate, options, ruleNames, validationError }) {
export default function Configuration({
rulesMeta,
eslintVersion,
onUpdate,
options,
ruleNames,
validationError,
rulesWithInvalidConfigs,
setRulesWithInvalidConfigs
}) {
const [showVersion, setShowVersions] = useState(false);
const [showRules, setShowRules] = useState(true);
const [configFileFormat, setConfigFileFormat] = useState("ESM");
Expand All @@ -111,7 +120,6 @@ export default function Configuration({ rulesMeta, eslintVersion, onUpdate, opti
}));
const [selectedRules, setSelectedRules] = useState([]);
const ruleInputRef = useRef(null);
const [rulesWithInvalidConfigs, setRulesWithInvalidConfigs] = useState(new Set([]));
const firstRuleRef = useRef();

useEffect(() => {
Expand Down