Skip to content

Commit b53d9e2

Browse files
committed
Disabled tiles
1 parent 8c5acff commit b53d9e2

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

src/main/ui/common/DonutChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const DonutChart: FunctionComponent<ChartProps> = ({ data }) => {
2020
return (
2121
<svg class="donut-chart" viewBox="0 0 100 100" aria-hidden="true">
2222
{data.map((dp, i) => {
23-
const size = Math.ceil(circumference * dp.amount / total);
24-
const angle = Math.round((360 * offset) - 90);
23+
const size = Math.ceil(circumference * (dp.amount / total));
24+
const angle = Math.round(360 * offset - 90);
2525
offset += dp.amount / total;
2626

2727
return (

src/main/ui/tiles/DynamicAnalysisTile.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Props = ExtensionData["dynamicAnalysis"];
77

88
const DynamicAnalysisTile: FunctionComponent<Props> = ({ supported, background, jsType }) => {
99
return (
10-
<Tile title="Dynamic Analysis" cssClass="da" popup={createPopupOptions}>
10+
<Tile title="Dynamic Analysis" cssClass="da">
1111
<ul>
1212
<li>{supported ? "supported" : "not supported"}</li>
1313
<li>{background ? "has background scripts" : "no background scripts"}</li>
@@ -18,10 +18,3 @@ const DynamicAnalysisTile: FunctionComponent<Props> = ({ supported, background,
1818
};
1919

2020
export default DynamicAnalysisTile;
21-
22-
function createPopupOptions() {
23-
return {
24-
title: "Dynamic Analysis",
25-
content: "Not yet implemented."
26-
};
27-
}

src/main/ui/tiles/Tile.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "./tiles.css";
1010

1111
type Props = {
1212
title: string;
13-
popup: (extId: ExtensionData["id"]) => PopupWindowOptions;
13+
popup?: (extId: ExtensionData["id"]) => PopupWindowOptions;
1414
cssClass?: string;
1515
};
1616

@@ -19,23 +19,30 @@ const Tile: FunctionComponent<Props> = ({ title, cssClass, popup: popupOptions,
1919
const color = useContext(ExtensionColorContext);
2020
const [hasWindow, setHasWindow] = useState(false);
2121

22-
const clickHandler = (e: Event) => {
23-
e.stopPropagation();
24-
if (hasWindow) {
25-
return;
26-
}
22+
const clickHandler = popupOptions
23+
? (e: Event) => {
24+
e.stopPropagation();
25+
if (hasWindow) {
26+
return;
27+
}
2728

28-
const options = {
29-
color,
30-
...popupOptions(extensionId)
31-
};
29+
const options = {
30+
color,
31+
...popupOptions(extensionId)
32+
};
3233

33-
showPopupWindow(extensionId, options).then(() => setHasWindow(false));
34-
setHasWindow(true);
35-
};
34+
showPopupWindow(extensionId, options).then(() => setHasWindow(false));
35+
setHasWindow(true);
36+
}
37+
: undefined;
3638

3739
return (
38-
<button class={`tile ${cssClass ?? ""}`} onClick={clickHandler} type="button">
40+
<button
41+
class={`tile ${cssClass ?? ""}`}
42+
onClick={clickHandler}
43+
type="button"
44+
disabled={!popupOptions}
45+
>
3946
<h3>{title}</h3>
4047
<div class="content">{children}</div>
4148
</button>

src/main/ui/tiles/TranslationsTile.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@ const TranslationsTile: FunctionComponent<ExtensionData["translations"]> = (meta
1515
{ amount: 1 - percentage, color: "rgb(128, 128, 128)" }
1616
];
1717

18+
function createPopupOptions(id: ExtensionData["id"]): PopupWindowOptions {
19+
return {
20+
title: "Translations",
21+
content: <TranslationsViewer extId={id} meta={meta} />,
22+
initialWidth: 1280,
23+
initialHeight: 720
24+
};
25+
}
26+
1827
return (
19-
<Tile title="Translations" cssClass="translations" popup={(id) => createPopupOptions(id, meta)}>
28+
<Tile
29+
title="Translations"
30+
cssClass="translations"
31+
popup={locales.length > 0 ? createPopupOptions : undefined}
32+
>
2033
{locales.length === 0 ? (
2134
<span class="none">no translations</span>
2235
) : (
@@ -51,15 +64,3 @@ const TranslationsTile: FunctionComponent<ExtensionData["translations"]> = (meta
5164
};
5265

5366
export default TranslationsTile;
54-
55-
function createPopupOptions(
56-
id: ExtensionData["id"],
57-
data: ExtensionData["translations"]
58-
): PopupWindowOptions {
59-
return {
60-
title: "Translations",
61-
content: <TranslationsViewer extId={id} meta={data} />,
62-
initialWidth: 1280,
63-
initialHeight: 720
64-
};
65-
}

0 commit comments

Comments
 (0)