mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: hide empty publish diagnostic tabs
This commit is contained in:
1 parent
381c044469
commit
b3570427d2
2 files changed
+23
-7
No files matched your search
@@ -89,7 +89,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as
|
||||
expect(document.body.textContent).toContain("Warnings");
|
||||
expect(document.body.textContent).toContain("error-5");
|
||||
expect(document.body.textContent).not.toContain("warning-0");
|
||||
expect(document.body.querySelectorAll('[role="tab"]')).toHaveLength(3);
|
||||
expect(document.body.querySelectorAll('[role="tab"]')).toHaveLength(2);
|
||||
expect(
|
||||
getComputedStyle(document.body.querySelector('[role="dialog"]')!).resize
|
||||
).toBe("both");
|
||||
@@ -144,7 +144,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as
|
||||
});
|
||||
|
||||
test.each(["error", "warning"] as const)(
|
||||
"keeps all three tabs in the %s-only state",
|
||||
"shows only the populated tab in the %s-only state",
|
||||
(severity) => {
|
||||
const element = render([createFinding(severity, 0)]);
|
||||
openDetails(element);
|
||||
@@ -152,7 +152,7 @@ test.each(["error", "warning"] as const)(
|
||||
Array.from(document.body.querySelectorAll('[role="tab"]')).map(
|
||||
(tab) => tab.textContent
|
||||
)
|
||||
).toEqual(["Warnings", "Errors", "Publish"]);
|
||||
).toEqual([severity === "error" ? "Errors" : "Warnings"]);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -147,6 +147,16 @@ export const PublishDiagnosticsDialog = ({
|
||||
const selectedItem = items.find(({ buildId }) => buildId === selectedBuildId);
|
||||
const defaultTab = initialTab ?? (errors.length > 0 ? "errors" : "warnings");
|
||||
const [tab, setTab] = useState(defaultTab);
|
||||
const activeTab =
|
||||
(tab === "warnings" && warnings.length > 0) ||
|
||||
(tab === "errors" && errors.length > 0) ||
|
||||
(tab === "publish" && items.length > 0)
|
||||
? tab
|
||||
: errors.length > 0
|
||||
? "errors"
|
||||
: warnings.length > 0
|
||||
? "warnings"
|
||||
: "publish";
|
||||
const reportText = findings.map(({ reportText }) => reportText).join("\n\n");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -277,14 +287,20 @@ export const PublishDiagnosticsDialog = ({
|
||||
</PanelContent>
|
||||
) : (
|
||||
<PanelTabs
|
||||
value={tab}
|
||||
value={activeTab}
|
||||
onValueChange={(value) => setTab(value as typeof tab)}
|
||||
css={{ flex: 1, minHeight: 0, overflow: "hidden" }}
|
||||
>
|
||||
<PanelTabsList aria-label="Publish check severity">
|
||||
<PanelTabsTrigger value="warnings">Warnings</PanelTabsTrigger>
|
||||
<PanelTabsTrigger value="errors">Errors</PanelTabsTrigger>
|
||||
<PanelTabsTrigger value="publish">Publish</PanelTabsTrigger>
|
||||
{warnings.length > 0 && (
|
||||
<PanelTabsTrigger value="warnings">Warnings</PanelTabsTrigger>
|
||||
)}
|
||||
{errors.length > 0 && (
|
||||
<PanelTabsTrigger value="errors">Errors</PanelTabsTrigger>
|
||||
)}
|
||||
{items.length > 0 && (
|
||||
<PanelTabsTrigger value="publish">Publish</PanelTabsTrigger>
|
||||
)}
|
||||
</PanelTabsList>
|
||||
<PanelTabsContent
|
||||
value="warnings"
|
||||
|
||||
Reference in new issue
Block a user