1 | import template from './sw-version.html.twig'; |
||
2 | import './sw-version.scss'; |
||
3 | |||
4 | const { Component } = Shopware; |
||
0 ignored issues
–
show
|
|||
5 | |||
6 | /** |
||
7 | * @private |
||
8 | * @description Shows the header in the administration main menu |
||
9 | * @status ready |
||
10 | * @example-type static |
||
11 | * @component-example |
||
12 | * <div style="background: linear-gradient(to bottom, #303A4F, #2A3345); padding: 30px;"> |
||
13 | * <sw-version class="collapsible-text"></sw-version> |
||
14 | * </div> |
||
15 | */ |
||
16 | Component.register('sw-version', { |
||
17 | template, |
||
18 | |||
19 | computed: { |
||
20 | version() { |
||
21 | const version = Shopware.Context.app.config.version; |
||
0 ignored issues
–
show
The variable
Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
22 | const match = version.match(/(\d+\.?\d+\.?\d+?\.?\d+?)-?([a-z]+)?(\d+(.\d+)*)?/i); |
||
23 | |||
24 | if (match === null) { |
||
25 | return version; |
||
26 | } |
||
27 | |||
28 | let output = `v${match[1]}`; |
||
29 | |||
30 | if (match[2]) { |
||
31 | output += ` ${this.getHumanReadableText(match[2])}`; |
||
32 | } else { |
||
33 | output += ' Stable Version'; |
||
34 | } |
||
35 | |||
36 | if (match[3]) { |
||
37 | output += ` ${match[3]}`; |
||
38 | } |
||
39 | |||
40 | return output; |
||
41 | } |
||
42 | }, |
||
43 | |||
44 | methods: { |
||
45 | getHumanReadableText(text) { |
||
46 | if (text === 'dp') { |
||
47 | return 'Developer Preview'; |
||
48 | } |
||
49 | |||
50 | if (text === 'rc') { |
||
51 | return 'Release Candidate'; |
||
52 | } |
||
53 | |||
54 | if (text === 'dev') { |
||
55 | return 'Developer Version'; |
||
56 | } |
||
57 | |||
58 | if (text === 'ea') { |
||
59 | return 'Early Access'; |
||
60 | } |
||
61 | |||
62 | return text; |
||
63 | } |
||
64 | } |
||
65 | }); |
||
66 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.