Skip to content

Commit 45169a3

Browse files
committed
allow selecting incompatible branches
1 parent 1da9c5f commit 45169a3

File tree

1 file changed

+87
-8
lines changed

1 file changed

+87
-8
lines changed

branches/mod/shelter/selector-ui.js

+87-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
(() => {
22
const {
33
plugins: { removePlugin },
4-
solid: { createSignal },
4+
solid: { createSignal, onCleanup },
55
solidH: { html },
6-
ui: { Text, LinkButton, Divider, Button, ButtonColors, showToast, Header, HeaderTags, SwitchItem, Space },
6+
ui: {
7+
Text,
8+
LinkButton,
9+
Divider,
10+
Button,
11+
ButtonColors,
12+
ButtonLooks,
13+
ButtonSizes,
14+
showToast,
15+
Header,
16+
HeaderTags,
17+
SwitchItem,
18+
Space,
19+
openModal,
20+
ModalRoot,
21+
ModalHeader,
22+
ModalBody,
23+
ModalFooter,
24+
},
725
} = shelter;
826

927
const {
@@ -135,16 +153,20 @@
135153
name=${() => branchName}
136154
data=${() => branchData}
137155
value=${() => pendingBranches().has(branchName)}
138-
onChange=${(e) => {
156+
onChange=${async (e) => {
139157
const pb = pendingBranches();
140158
if (e) {
141159
const foundIncompatibilities = branchData.incompatibilities.filter((i) => pb.has(i));
142160
if (foundIncompatibilities.length > 0) {
143-
showToast({
144-
title: `${branchData.displayName} is not compatible with ${prettyModNames(foundIncompatibilities)}`,
145-
duration: 3000,
146-
});
147-
foundIncompatibilities.forEach((b) => pb.delete(b));
161+
const res = await openIncompatibilityModal(
162+
branchData.displayName,
163+
foundIncompatibilities,
164+
);
165+
if (res === "disableOthers") {
166+
foundIncompatibilities.forEach((b) => pb.delete(b));
167+
} else if (res === "cancel") {
168+
return;
169+
}
148170
}
149171
pb.add(branchName);
150172
} else {
@@ -242,4 +264,61 @@
242264
</div>
243265
`;
244266
}
267+
268+
async function openIncompatibilityModal(branchName, incompatibleBranches) {
269+
return new Promise((resolve) => {
270+
openModal(({ close }) => {
271+
onCleanup(() => resolve("cancel"));
272+
const incompatibleBranchNames = prettyModNames(incompatibleBranches);
273+
return html`
274+
<${ModalRoot}>
275+
<${ModalHeader} close=${(e) => close()}>
276+
Things might break!
277+
<//>
278+
<${ModalBody}>
279+
${branchName} may not work properly alongside ${incompatibleBranchNames}.<br />
280+
Do you want to disable ${incompatibleBranchNames}?
281+
<//>
282+
<${ModalFooter}>
283+
<div style="display: flex; justify-content: flex-end; gap: .5rem;">
284+
<${Button}
285+
look=${ButtonLooks.LINK}
286+
size=${ButtonSizes.MEDIUM}
287+
grow
288+
onClick=${(e) => {
289+
resolve("cancel");
290+
close();
291+
}}
292+
>
293+
Cancel
294+
<//>
295+
<${Button}
296+
color=${ButtonColors.GREEN}
297+
size=${ButtonSizes.MEDIUM}
298+
grow
299+
onClick=${(e) => {
300+
resolve("disableOthers");
301+
close();
302+
}}
303+
>
304+
Disable ${incompatibleBranches.length > 1 ? "them" : "it"}
305+
<//>
306+
<${Button}
307+
color=${ButtonColors.RED}
308+
size=${ButtonSizes.MEDIUM}
309+
grow
310+
onClick=${(e) => {
311+
resolve("proceed");
312+
close();
313+
}}
314+
>
315+
Proceed anyways
316+
<//>
317+
</div>
318+
<//>
319+
<//>
320+
`;
321+
});
322+
});
323+
}
245324
})();

0 commit comments

Comments
 (0)