|
1 | 1 | (() => {
|
2 | 2 | const {
|
3 | 3 | plugins: { removePlugin },
|
4 |
| - solid: { createSignal }, |
| 4 | + solid: { createSignal, onCleanup }, |
5 | 5 | 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 | + }, |
7 | 25 | } = shelter;
|
8 | 26 |
|
9 | 27 | const {
|
|
135 | 153 | name=${() => branchName}
|
136 | 154 | data=${() => branchData}
|
137 | 155 | value=${() => pendingBranches().has(branchName)}
|
138 |
| - onChange=${(e) => { |
| 156 | + onChange=${async (e) => { |
139 | 157 | const pb = pendingBranches();
|
140 | 158 | if (e) {
|
141 | 159 | const foundIncompatibilities = branchData.incompatibilities.filter((i) => pb.has(i));
|
142 | 160 | 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 | + } |
148 | 170 | }
|
149 | 171 | pb.add(branchName);
|
150 | 172 | } else {
|
|
242 | 264 | </div>
|
243 | 265 | `;
|
244 | 266 | }
|
| 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 | + } |
245 | 324 | })();
|
0 commit comments