Skip to content

A platform for community discussion. Free, open, simple.

DEV: Refactor Wizard routes, controllers and templates (#24725)

David Taylorb3d1707b65ca
diff --git a/app/assets/javascripts/wizard/addon/components/discourse-logo.gjs b/app/assets/javascripts/wizard/addon/components/discourse-logo.gjs
new file mode 100644
index 00000000000..1e61913b70d
--- /dev/null
+++ b/app/assets/javascripts/wizard/addon/components/discourse-logo.gjs
@@ -0,0 +1,27 @@
+<template>
+ {{! prettier-ignore }}
+ <div class="discourse-logo">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 385 104">
+ <g id="discourse-logo-large" fill="none" fill-rule="nonzero">
+ <path class="logo-contour" fill="var(--primary)"
+ d="M117.4 22.22c1.649399-.0222812 3.233299.6446239 4.37 1.84 1.192379 1.1784439 1.850092 2.7938161 1.82 4.47.02983 1.6575188-.620685 3.2548933-1.8 4.42-1.119242 1.1834351-2.681214 1.8466391-4.31 1.83-1.662331.023056-3.258247-.6515814-4.4-1.86-1.195146-1.1971019-1.852129-2.8287301-1.82-4.52-.000018-3.3998017 2.750216-6.1589796 6.15-6.17l-.01-.01zm-4.84 21.05h9.68v40.36h-9.68V43.27zm42.1 6.39l-6 6C146.22 53.22 144 52 142 52c-.902316-.0524313-1.79724.1897247-2.55.69-.573152.3850847-.91784 1.0295007-.92 1.72.003314.536265.210697 1.0511472.58 1.44.861614.7548917 1.836939 1.3691103 2.89 1.82l3.55 1.77c3.733333 1.8466667 6.3 3.7266667 7.7 5.64 3.339481 4.8109001 2.622713 11.3471474-1.68 15.32-2.52 2.2933333-5.896667 3.44-10.13 3.44-5.290881.1460857-10.315591-2.3176674-13.44-6.59l6-6.49c1.120876 1.3107131 2.47767 2.3995407 4 3.21 1.21567.7242383 2.587439 1.1460572 4 1.23 1.104873.0554814 2.195409-.2692091 3.09-.92.709238-.481083 1.144441-1.2733748 1.17-2.13 0-1.4933333-1.406667-2.9466667-4.22-4.36l-3.26-1.63c-6.24-3.1466667-9.36-7.0833333-9.36-11.81-.023382-2.9974288 1.266494-5.8548879 3.53-7.82 2.467571-2.2051994 5.69282-3.3698724 9-3.25 5.010194-.0274064 9.731027 2.3441612 12.7 6.38h.01zm45.1 2.41l-8.06 4.43c-1.254605-1.396184-2.782926-2.5194486-4.49-3.3-1.65594-.6457398-3.423024-.9583778-5.2-.92-3.245832-.1417919-6.412693 1.0255155-8.79 3.24-2.246347 2.1649992-3.467702 5.1820368-3.36 8.3-.097501 3.0024572 1.075175 5.9069195 3.23 8 2.288229 2.1569486 5.347819 3.3029432 8.49 3.18 4.333333 0 7.706667-1.4766667 10.12-4.43l7.64 5.23c-4.14 5.38-9.98 8.07-17.52 8.07-6.786667 0-12.1-2-15.94-6-4.48358-4.5067211-6.564271-10.8726791-5.60785-17.1574451C161.22857 54.4277889 165.108765 48.968963 170.73 46c3.46735-1.8431696 7.343542-2.7821229 11.27-2.73 3.572088-.0575569 7.107523.7269532 10.32 2.29 2.995764 1.4982625 5.557329 3.739632 7.44 6.51zm23.85-8.8c3.604029-.010417 7.146863.9313491 10.27 2.73 6.327234 3.5564862 10.231011 10.261796 10.2 17.52.015895 3.5831575-.919258 7.106371-2.71 10.21-1.735583 3.1031601-4.283385 5.6751605-7.37 7.44-3.142134 1.7910684-6.703421 2.7158986-10.32 2.68-5.33854.0803277-10.470647-2.0601629-14.17-5.91-3.845791-3.7732443-5.968786-8.9631898-5.87-14.35-.050183-11.1185605 8.882044-20.1937022 20-20.32h-.03zm.16 9.12c-2.835339-.0656442-5.565196 1.0757341-7.51 3.14-2.022565 2.1625471-3.101902 5.0407776-3 8-.123784 3.0105402.955639 5.946572 3 8.16 1.941671 2.0665463 4.675583 3.202339 7.51 3.12 2.859128.0777168 5.61469-1.0725573 7.57-3.16 2.041067-2.199383 3.120812-5.1218929 3-8.12.116275-2.9824439-.963763-5.8877463-3-8.07-1.971249-2.0543004-4.724691-3.1709538-7.57-3.07zM250 44.27h9.79v18.58c-.125272 2.5360436.124076 5.0766997.74 7.54.433835 1.3191993 1.273923 2.467319 2.4 3.28 1.199326.8094698 2.623894 1.2189893 4.07 1.17 1.455597.0478904 2.890629-.3536395 4.11-1.15 1.176822-.8333654 2.056319-2.0212119 2.51-3.39.4-1.1133333.6-3.49.6-7.13v-18.9h9.68v16.35c0 6.74-.533333 11.35-1.6 13.83-1.155092 2.8668191-3.162099 5.3101316-5.75 7-2.915931 1.72144-6.266549 2.5651706-9.65 2.43-4.233333 0-7.656667-.9466667-10.27-2.84-2.656958-1.9585935-4.593682-4.7388994-5.51-7.91-.746667-2.36-1.12-6.6266667-1.12-12.8V44.27zm40.31 0h8.3v4.86c.767489-1.7562415 2.006682-3.2654259 3.58-4.36 1.442665-.9779714 3.147113-1.4973227 4.89-1.49 1.372409.0285016 2.720114.3705587 3.94 1l-3 8.34c-.858779-.4874025-1.815195-.7777428-2.8-.85-1.493333 0-2.753333.9233333-3.78 2.77-1.026667 1.8466667-1.54 5.4633333-1.54 10.85v17.47h-9.61l.02-38.59zm48.12 5.39l-6 6c-2.433333-2.44-4.643333-3.66-6.63-3.66-.902316-.0524313-1.79724.1897247-2.55.69-.573152.3850847-.91784 1.0295007-.92 1.72.003314.536265.210697 1.0511472.58 1.44.86418.7436068 1.839282 1.3475632 2.89 1.79l3.55 1.77c3.733333 1.8466667 6.3 3.7266667 7.7 5.64 3.334996 4.8120386 2.618581 11.3450638-1.68 15.32-2.52 2.2933333-5.896667 3.44-10.13 3.44-5.306684.1570903-10.34968-2.3120323-13.48-6.6l6-6.49c1.120544 1.311055 2.477408 2.3999384 4 3.21 1.234508.7295857 2.627813 1.1482637 4.06 1.22 1.104873.0554814 2.195409-.2692091 3.09-.92.665094-.487764 1.067432-1.2555276 1.09-2.08 0-1.4933333-1.406667-2.9466667-4.22-4.36l-3.26-1.63c-6.24-3.1466667-9.36-7.0833333-9.36-11.81-.023382-2.9974288 1.266494-5.8548879 3.53-7.82 2.468114-2.2042903 5.692983-3.3688266 9-3.25 5.010194-.0274064 9.731027 2.3441612 12.7 6.38h.04zm45.99 16.7h-31.1c.344633 2.5519358 1.628201 4.8837517 3.6 6.54 2.119278 1.6772588 4.769524 2.5393871 7.47 2.43 3.495035.0528887 6.861918-1.3147949 9.33-3.79l8.16 3.83c-1.849704 2.7229701-4.366447 4.9264112-7.31 6.4-3.168167 1.4515868-6.626273 2.1596264-10.11 2.07-6.053333 0-10.983333-1.91-14.79-5.73-3.778418-3.794868-5.828939-8.9772248-5.67-14.33-.169883-5.4590569 1.883549-10.7532295 5.69-14.67 3.730211-3.86226 8.912541-5.978015 14.28-5.83 6.073333 0 11.016667 1.9433333 14.83 5.83s5.716667 9.0233333 5.71 15.41l-.09 1.84zm-9.68-7.63c-.614521-2.121145-1.933733-3.9694522-3.74-5.24-1.914891-1.3466635-4.209472-2.0472991-6.55-2-2.555466-.0480087-5.055132.7500564-7.11 2.27-1.575496 1.3502917-2.794648 3.0674061-3.55 5l20.95-.03zM51.87 0C23.71 0 0 22.83 0 51v52.81l51.86-.05c28.16 0 51-23.71 51-51.87C102.86 23.73 80 0 51.87 0z">
+ </path>
+ <path fill="#FFF9AE"
+ d="M52.37 19.74c-11.1380058.0065739-21.451097 5.8725864-27.1495582 15.4424743C19.5219805 44.7523623 19.2787009 56.6145192 24.58 66.41l-5.72 18.4 20.54-4.64c11.7619991 5.29926 25.5640682 2.9191757 34.8718647-6.0134445 9.3077965-8.9326201 12.2534008-22.6251484 7.4422692-34.5951021C76.9030023 27.5914997 65.3006488 19.7462906 52.4 19.74h-.03z">
+ </path>
+ <path fill="#00AEEF"
+ d="M77.0874282 70.9138623C68.1087341 82.2404672 52.5895354 86.0314364 39.4 80.12l-20.54 4.7 20.91-2.47c13.8618885 8.120188 31.6101861 4.5474373 41.2505109-8.3037707C90.6608357 61.1950214 89.1246004 43.1559917 77.45 32.12c8.7654246 11.4924434 8.6161222 27.4672575-.3625718 38.7938623z">
+ </path>
+ <path fill="#00A94F"
+ d="M75.3191226 64.9088434C67.572355 77.1106513 52.5344195 82.5013605 38.8 78l-19.94 6.82 20.54-4.65c14.6285181 6.6078894 31.8869319 1.1988304 40.1270438-12.5764482C87.7671557 53.8182732 84.370682 36.05385 71.63 26.29c9.9167741 10.5144718 11.4358902 26.4170355 3.6891226 38.6188434z">
+ </path>
+ <path fill="#F15D22"
+ d="M26.47 67.11c-5.7247169-13.7992006-1.0069753-29.722128 11.3108878-38.1755635C50.0987509 20.4810011 66.6529755 21.8055203 77.47 32.11c-10.0181769-13.1470907-28.4736729-16.3561915-42.3417564-7.3625203C21.26016 33.7411508 16.6624984 51.9005882 24.58 66.41l-5.72 18.4 7.61-17.7z">
+ </path>
+ <path fill="#D0232B"
+ d="M24.58 66.41c-7.1032817-13.1205259-4.0652056-29.4212778 7.2876929-39.1020065C43.2205913 17.6272648 59.7966078 17.2028861 71.63 26.29c-11.3513195-11.9524832-29.9818586-13.1756566-42.7984647-2.8098996C16.0149293 33.8458575 13.3153477 52.3203102 22.63 65.92l-3.76 18.9 5.71-18.41z">
+ </path>
+ </g>
+ </svg>
+ </div>
+</template>
diff --git a/app/assets/javascripts/wizard/addon/components/discourse-logo.hbs b/app/assets/javascripts/wizard/addon/components/discourse-logo.hbs
deleted file mode 100644
index e1218bbdee3..00000000000
--- a/app/assets/javascripts/wizard/addon/components/discourse-logo.hbs
+++ /dev/null
@@ -1,23 +0,0 @@
-{{! prettier-ignore }}
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 385 104">
- <g id="discourse-logo-large" fill="none" fill-rule="nonzero">
- <path class="logo-contour" fill="var(--primary)"
- d="M117.4 22.22c1.649399-.0222812 3.233299.6446239 4.37 1.84 1.192379 1.1784439 1.850092 2.7938161 1.82 4.47.02983 1.6575188-.620685 3.2548933-1.8 4.42-1.119242 1.1834351-2.681214 1.8466391-4.31 1.83-1.662331.023056-3.258247-.6515814-4.4-1.86-1.195146-1.1971019-1.852129-2.8287301-1.82-4.52-.000018-3.3998017 2.750216-6.1589796 6.15-6.17l-.01-.01zm-4.84 21.05h9.68v40.36h-9.68V43.27zm42.1 6.39l-6 6C146.22 53.22 144 52 142 52c-.902316-.0524313-1.79724.1897247-2.55.69-.573152.3850847-.91784 1.0295007-.92 1.72.003314.536265.210697 1.0511472.58 1.44.861614.7548917 1.836939 1.3691103 2.89 1.82l3.55 1.77c3.733333 1.8466667 6.3 3.7266667 7.7 5.64 3.339481 4.8109001 2.622713 11.3471474-1.68 15.32-2.52 2.2933333-5.896667 3.44-10.13 3.44-5.290881.1460857-10.315591-2.3176674-13.44-6.59l6-6.49c1.120876 1.3107131 2.47767 2.3995407 4 3.21 1.21567.7242383 2.587439 1.1460572 4 1.23 1.104873.0554814 2.195409-.2692091 3.09-.92.709238-.481083 1.144441-1.2733748 1.17-2.13 0-1.4933333-1.406667-2.9466667-4.22-4.36l-3.26-1.63c-6.24-3.1466667-9.36-7.0833333-9.36-11.81-.023382-2.9974288 1.266494-5.8548879 3.53-7.82 2.467571-2.2051994 5.69282-3.3698724 9-3.25 5.010194-.0274064 9.731027 2.3441612 12.7 6.38h.01zm45.1 2.41l-8.06 4.43c-1.254605-1.396184-2.782926-2.5194486-4.49-3.3-1.65594-.6457398-3.423024-.9583778-5.2-.92-3.245832-.1417919-6.412693 1.0255155-8.79 3.24-2.246347 2.1649992-3.467702 5.1820368-3.36 8.3-.097501 3.0024572 1.075175 5.9069195 3.23 8 2.288229 2.1569486 5.347819 3.3029432 8.49 3.18 4.333333 0 7.706667-1.4766667 10.12-4.43l7.64 5.23c-4.14 5.38-9.98 8.07-17.52 8.07-6.786667 0-12.1-2-15.94-6-4.48358-4.5067211-6.564271-10.8726791-5.60785-17.1574451C161.22857 54.4277889 165.108765 48.968963 170.73 46c3.46735-1.8431696 7.343542-2.7821229 11.27-2.73 3.572088-.0575569 7.107523.7269532 10.32 2.29 2.995764 1.4982625 5.557329 3.739632 7.44 6.51zm23.85-8.8c3.604029-.010417 7.146863.9313491 10.27 2.73 6.327234 3.5564862 10.231011 10.261796 10.2 17.52.015895 3.5831575-.919258 7.106371-2.71 10.21-1.735583 3.1031601-4.283385 5.6751605-7.37 7.44-3.142134 1.7910684-6.703421 2.7158986-10.32 2.68-5.33854.0803277-10.470647-2.0601629-14.17-5.91-3.845791-3.7732443-5.968786-8.9631898-5.87-14.35-.050183-11.1185605 8.882044-20.1937022 20-20.32h-.03zm.16 9.12c-2.835339-.0656442-5.565196 1.0757341-7.51 3.14-2.022565 2.1625471-3.101902 5.0407776-3 8-.123784 3.0105402.955639 5.946572 3 8.16 1.941671 2.0665463 4.675583 3.202339 7.51 3.12 2.859128.0777168 5.61469-1.0725573 7.57-3.16 2.041067-2.199383 3.120812-5.1218929 3-8.12.116275-2.9824439-.963763-5.8877463-3-8.07-1.971249-2.0543004-4.724691-3.1709538-7.57-3.07zM250 44.27h9.79v18.58c-.125272 2.5360436.124076 5.0766997.74 7.54.433835 1.3191993 1.273923 2.467319 2.4 3.28 1.199326.8094698 2.623894 1.2189893 4.07 1.17 1.455597.0478904 2.890629-.3536395 4.11-1.15 1.176822-.8333654 2.056319-2.0212119 2.51-3.39.4-1.1133333.6-3.49.6-7.13v-18.9h9.68v16.35c0 6.74-.533333 11.35-1.6 13.83-1.155092 2.8668191-3.162099 5.3101316-5.75 7-2.915931 1.72144-6.266549 2.5651706-9.65 2.43-4.233333 0-7.656667-.9466667-10.27-2.84-2.656958-1.9585935-4.593682-4.7388994-5.51-7.91-.746667-2.36-1.12-6.6266667-1.12-12.8V44.27zm40.31 0h8.3v4.86c.767489-1.7562415 2.006682-3.2654259 3.58-4.36 1.442665-.9779714 3.147113-1.4973227 4.89-1.49 1.372409.0285016 2.720114.3705587 3.94 1l-3 8.34c-.858779-.4874025-1.815195-.7777428-2.8-.85-1.493333 0-2.753333.9233333-3.78 2.77-1.026667 1.8466667-1.54 5.4633333-1.54 10.85v17.47h-9.61l.02-38.59zm48.12 5.39l-6 6c-2.433333-2.44-4.643333-3.66-6.63-3.66-.902316-.0524313-1.79724.1897247-2.55.69-.573152.3850847-.91784 1.0295007-.92 1.72.003314.536265.210697 1.0511472.58 1.44.86418.7436068 1.839282 1.3475632 2.89 1.79l3.55 1.77c3.733333 1.8466667 6.3 3.7266667 7.7 5.64 3.334996 4.8120386 2.618581 11.3450638-1.68 15.32-2.52 2.2933333-5.896667 3.44-10.13 3.44-5.306684.1570903-10.34968-2.3120323-13.48-6.6l6-6.49c1.120544 1.311055 2.477408 2.3999384 4 3.21 1.234508.7295857 2.627813 1.1482637 4.06 1.22 1.104873.0554814 2.195409-.2692091 3.09-.92.665094-.487764 1.067432-1.2555276 1.09-2.08 0-1.4933333-1.406667-2.9466667-4.22-4.36l-3.26-1.63c-6.24-3.1466667-9.36-7.0833333-9.36-11.81-.023382-2.9974288 1.266494-5.8548879 3.53-7.82 2.468114-2.2042903 5.692983-3.3688266 9-3.25 5.010194-.0274064 9.731027 2.3441612 12.7 6.38h.04zm45.99 16.7h-31.1c.344633 2.5519358 1.628201 4.8837517 3.6 6.54 2.119278 1.6772588 4.769524 2.5393871 7.47 2.43 3.495035.0528887 6.861918-1.3147949 9.33-3.79l8.16 3.83c-1.849704 2.7229701-4.366447 4.9264112-7.31 6.4-3.168167 1.4515868-6.626273 2.1596264-10.11 2.07-6.053333 0-10.983333-1.91-14.79-5.73-3.778418-3.794868-5.828939-8.9772248-5.67-14.33-.169883-5.4590569 1.883549-10.7532295 5.69-14.67 3.730211-3.86226 8.912541-5.978015 14.28-5.83 6.073333 0 11.016667 1.9433333 14.83 5.83s5.716667 9.0233333 5.71 15.41l-.09 1.84zm-9.68-7.63c-.614521-2.121145-1.933733-3.9694522-3.74-5.24-1.914891-1.3466635-4.209472-2.0472991-6.55-2-2.555466-.0480087-5.055132.7500564-7.11 2.27-1.575496 1.3502917-2.794648 3.0674061-3.55 5l20.95-.03zM51.87 0C23.71 0 0 22.83 0 51v52.81l51.86-.05c28.16 0 51-23.71 51-51.87C102.86 23.73 80 0 51.87 0z">
- </path>
- <path fill="#FFF9AE"
- d="M52.37 19.74c-11.1380058.0065739-21.451097 5.8725864-27.1495582 15.4424743C19.5219805 44.7523623 19.2787009 56.6145192 24.58 66.41l-5.72 18.4 20.54-4.64c11.7619991 5.29926 25.5640682 2.9191757 34.8718647-6.0134445 9.3077965-8.9326201 12.2534008-22.6251484 7.4422692-34.5951021C76.9030023 27.5914997 65.3006488 19.7462906 52.4 19.74h-.03z">
- </path>
- <path fill="#00AEEF"
- d="M77.0874282 70.9138623C68.1087341 82.2404672 52.5895354 86.0314364 39.4 80.12l-20.54 4.7 20.91-2.47c13.8618885 8.120188 31.6101861 4.5474373 41.2505109-8.3037707C90.6608357 61.1950214 89.1246004 43.1559917 77.45 32.12c8.7654246 11.4924434 8.6161222 27.4672575-.3625718 38.7938623z">
- </path>
- <path fill="#00A94F"
- d="M75.3191226 64.9088434C67.572355 77.1106513 52.5344195 82.5013605 38.8 78l-19.94 6.82 20.54-4.65c14.6285181 6.6078894 31.8869319 1.1988304 40.1270438-12.5764482C87.7671557 53.8182732 84.370682 36.05385 71.63 26.29c9.9167741 10.5144718 11.4358902 26.4170355 3.6891226 38.6188434z">
- </path>
- <path fill="#F15D22"
- d="M26.47 67.11c-5.7247169-13.7992006-1.0069753-29.722128 11.3108878-38.1755635C50.0987509 20.4810011 66.6529755 21.8055203 77.47 32.11c-10.0181769-13.1470907-28.4736729-16.3561915-42.3417564-7.3625203C21.26016 33.7411508 16.6624984 51.9005882 24.58 66.41l-5.72 18.4 7.61-17.7z">
- </path>
- <path fill="#D0232B"
- d="M24.58 66.41c-7.1032817-13.1205259-4.0652056-29.4212778 7.2876929-39.1020065C43.2205913 17.6272648 59.7966078 17.2028861 71.63 26.29c-11.3513195-11.9524832-29.9818586-13.1756566-42.7984647-2.8098996C16.0149293 33.8458575 13.3153477 52.3203102 22.63 65.92l-3.76 18.9 5.71-18.41z">
- </path>
- </g>
-</svg>
\ No newline at end of file
diff --git a/app/assets/javascripts/wizard/addon/controllers/wizard-step.js b/app/assets/javascripts/wizard/addon/controllers/wizard-step.js
deleted file mode 100644
index 6ccd04fed59..00000000000
--- a/app/assets/javascripts/wizard/addon/controllers/wizard-step.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import Controller from "@ember/controller";
-import { action } from "@ember/object";
-import { inject as service } from "@ember/service";
-import getUrl from "discourse-common/lib/get-url";
-
-export default Controller.extend({
- router: service(),
-
- wizard: null,
- step: null,
-
- @action
- goNext(response) {
- const next = this.step.next;
-
- if (response?.refresh_required) {
- document.location = getUrl(`/wizard/steps/${next}`);
- } else if (response?.success && next) {
- this.router.transitionTo("wizard.step", next);
- } else if (response?.success) {
- this.router.transitionTo("discovery.latest");
- }
- },
-
- @action
- goBack() {
- this.router.transitionTo("wizard.step", this.step.previous);
- },
-});
diff --git a/app/assets/javascripts/wizard/addon/controllers/wizard.js b/app/assets/javascripts/wizard/addon/controllers/wizard.js
deleted file mode 100644
index e7ec5bf4789..00000000000
--- a/app/assets/javascripts/wizard/addon/controllers/wizard.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import Controller, { inject as controller } from "@ember/controller";
-
-export default class extends Controller {
- @controller wizardStep;
- get showCanvas() {
- return this.wizardStep.get("step.id") === "ready";
- }
-}
diff --git a/app/assets/javascripts/wizard/addon/routes/wizard-index.js b/app/assets/javascripts/wizard/addon/routes/wizard-index.js
index dfb521b7551..13263b139b9 100644
--- a/app/assets/javascripts/wizard/addon/routes/wizard-index.js
+++ b/app/assets/javascripts/wizard/addon/routes/wizard-index.js
@@ -1,10 +1,11 @@
import { inject as service } from "@ember/service";
import DiscourseRoute from "discourse/routes/discourse";
-export default DiscourseRoute.extend({
- router: service(),
+export default class WizardIndexRoute extends DiscourseRoute {
+ @service router;
+
beforeModel() {
- const appModel = this.modelFor("wizard");
- this.router.replaceWith("wizard.step", appModel.start);
- },
-});
+ const wizard = this.modelFor("wizard");
+ this.router.replaceWith("wizard.step", wizard.start);
+ }
+}
diff --git a/app/assets/javascripts/wizard/addon/routes/wizard-step.js b/app/assets/javascripts/wizard/addon/routes/wizard-step.js
index 76d78bc44d9..ae0a67e051d 100644
--- a/app/assets/javascripts/wizard/addon/routes/wizard-step.js
+++ b/app/assets/javascripts/wizard/addon/routes/wizard-step.js
@@ -1,17 +1,17 @@
+import { inject as service } from "@ember/service";
import DiscourseRoute from "discourse/routes/discourse";
-export default DiscourseRoute.extend({
- model(params) {
- const allSteps = this.modelFor("wizard").steps;
- const step = allSteps.findBy("id", params.step_id);
-
- return step || allSteps[0];
- },
+export default class WizardStepRoute extends DiscourseRoute {
+ @service router;
- setupController(controller, step) {
+ model(params) {
const wizard = this.modelFor("wizard");
- this.controllerFor("wizard").set("currentStepId", step.id);
+ const step = wizard.findStep(params.step_id);
+
+ if (!step) {
+ this.router.transitionTo("wizard.step", wizard.start);
+ }
- controller.setProperties({ step, wizard });
- },
-});
+ return { wizard, step };
+ }
+}
diff --git a/app/assets/javascripts/wizard/addon/routes/wizard.js b/app/assets/javascripts/wizard/addon/routes/wizard.js
index 49c92605d20..c78c766adb5 100644
--- a/app/assets/javascripts/wizard/addon/routes/wizard.js
+++ b/app/assets/javascripts/wizard/addon/routes/wizard.js
@@ -2,13 +2,13 @@ import Route from "@ember/routing/route";
import DisableSidebar from "discourse/mixins/disable-sidebar";
import Wizard from "wizard/models/wizard";
-export default Route.extend(DisableSidebar, {
+export default class WizardRoute extends Route.extend(DisableSidebar) {
model() {
return Wizard.load();
- },
+ }
activate() {
- this._super(...arguments);
+ super.activate(...arguments);
document.body.classList.add("wizard");
@@ -16,10 +16,10 @@ export default Route.extend(DisableSidebar, {
showTop: false,
showSiteHeader: false,
});
- },
+ }
deactivate() {
- this._super(...arguments);
+ super.deactivate(...arguments);
document.body.classList.remove("wizard");
@@ -27,5 +27,5 @@ export default Route.extend(DisableSidebar, {
showTop: true,
showSiteHeader: true,
});
- },
-});
+ }
+}
diff --git a/app/assets/javascripts/wizard/addon/templates/step.gjs b/app/assets/javascripts/wizard/addon/templates/step.gjs
new file mode 100644
index 00000000000..2b9d28b5137
--- /dev/null
+++ b/app/assets/javascripts/wizard/addon/templates/step.gjs
@@ -0,0 +1,52 @@
+import Component from "@glimmer/component";
+import { action } from "@ember/object";
+import { inject as service } from "@ember/service";
+import RouteTemplate from "ember-route-template";
+import getUrl from "discourse-common/lib/get-url";
+import WizardCanvas from "../components/wizard-canvas";
+import WizardStep from "../components/wizard-step";
+
+export default RouteTemplate(
+ class extends Component {
+ @service router;
+
+ <template>
+ {{#if this.showCanvas}}
+ <WizardCanvas />
+ {{/if}}
+
+ <WizardStep
+ @step={{@model.step}}
+ @wizard={{@model.wizard}}
+ @goNext={{this.goNext}}
+ @goBack={{this.goBack}}
+ />
+ </template>
+
+ get step() {
+ return this.args.model.step;
+ }
+
+ get showCanvas() {
+ return this.step.id === "ready";
+ }
+
+ @action
+ goNext(response) {
+ const next = this.step.next;
+
+ if (response?.refresh_required) {
+ document.location = getUrl(`/wizard/steps/${next}`);
+ } else if (response?.success && next) {
+ this.router.transitionTo("wizard.step", next);
+ } else if (response?.success) {
+ this.router.transitionTo("discovery.latest");
+ }
+ }
+
+ @action
+ goBack() {
+ this.router.transitionTo("wizard.step", this.step.previous);
+ }
+ }
+);
diff --git a/app/assets/javascripts/wizard/addon/templates/step.hbs b/app/assets/javascripts/wizard/addon/templates/step.hbs
deleted file mode 100644
index 4fad85a8287..00000000000
--- a/app/assets/javascripts/wizard/addon/templates/step.hbs
+++ /dev/null
@@ -1,6 +0,0 @@
-<WizardStep
- @step={{this.step}}
- @wizard={{this.wizard}}
- @goNext={{action "goNext"}}
- @goBack={{action "goBack"}}
-/>
\ No newline at end of file
diff --git a/app/assets/javascripts/wizard/addon/templates/wizard.gjs b/app/assets/javascripts/wizard/addon/templates/wizard.gjs
new file mode 100644
index 00000000000..1b35aa10bc2
--- /dev/null
+++ b/app/assets/javascripts/wizard/addon/templates/wizard.gjs
@@ -0,0 +1,12 @@
+import RouteTemplate from "ember-route-template";
+import hideApplicationFooter from "discourse/helpers/hide-application-footer";
+import DiscourseLogo from "../components/discourse-logo";
+
+export default RouteTemplate(<template>
+ {{hideApplicationFooter}}
+ <div id="wizard-main">
+ <DiscourseLogo />
+
+ {{outlet}}
+ </div>
+</template>);
diff --git a/app/assets/javascripts/wizard/addon/templates/wizard.hbs b/app/assets/javascripts/wizard/addon/templates/wizard.hbs
deleted file mode 100644
index 2374d33e10d..00000000000
--- a/app/assets/javascripts/wizard/addon/templates/wizard.hbs
+++ /dev/null
@@ -1,12 +0,0 @@
-{{hide-application-footer}}
-<div id="wizard-main">
- {{#if this.showCanvas}}
- <WizardCanvas />
- {{/if}}
-
- <div class="discourse-logo">
- <DiscourseLogo />
- </div>
-
- {{outlet}}
-</div>
\ No newline at end of file
diff --git a/app/assets/javascripts/wizard/package.json b/app/assets/javascripts/wizard/package.json
index 252feb74ce3..200ba7f774e 100644
--- a/app/assets/javascripts/wizard/package.json
+++ b/app/assets/javascripts/wizard/package.json
@@ -15,7 +15,8 @@
},
"dependencies": {
"ember-cli-babel": "^8.2.0",
- "ember-cli-htmlbars": "^6.3.0"
+ "ember-cli-htmlbars": "^6.3.0",
+ "ember-template-imports": "^4.0.0"
},
"devDependencies": {
"@babel/core": "^7.23.5",