Conditions | 9 |
Total Lines | 32 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* Is covered by E2E tests */ |
||
4 | |||
5 | export default function initializeWindow(): void { |
||
6 | // Handle incoming window requests from the ExtensionAPI |
||
7 | Shopware.ExtensionAPI.handle('windowReload', () => { |
||
8 | window.location.reload(); |
||
9 | }); |
||
10 | |||
11 | Shopware.ExtensionAPI.handle('windowRedirect', ({ newTab, url }) => { |
||
12 | if (newTab) { |
||
13 | window.open(url, '_blank'); |
||
14 | } else { |
||
15 | window.location.href = url; |
||
16 | } |
||
17 | }); |
||
18 | |||
19 | Shopware.ExtensionAPI.handle('windowRouterPush', ({ |
||
20 | name, |
||
21 | params, |
||
22 | path, |
||
23 | replace, |
||
24 | }) => { |
||
25 | const $router = Shopware.Application.view?.root?.$router as unknown as VueRouter; |
||
26 | |||
27 | if (!$router) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | $router.push({ |
||
32 | name: name && name.length > 0 ? name : undefined, |
||
33 | params, |
||
34 | path: path && path.length > 0 ? path : undefined, |
||
35 | replace: replace ?? false, |
||
36 | }); |
||
39 |