Passed
Push — master ( 366f40...c67819 )
by Christian
13:04 queued 10s
created

app/component/app/sw-app-action-button/index.js (1 issue)

Labels
Severity
1
import template from './sw-app-action-button.html.twig';
2
import './sw-app-action-button.scss';
3
4
const { Component, State, Context } = Shopware;
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...
5
6
Component.register('sw-app-action-button', {
7
    template,
8
9
    props: {
10
        action: {
11
            type: Object,
12
            required: true
13
        }
14
    },
15
16
    computed: {
17
        buttonLabel() {
18
            const currentLocale = State.get('session').currentLocale;
19
            const fallbackLocale = Context.app.fallbackLocale;
20
21
            return this.action.label[currentLocale] || this.action.label[fallbackLocale] || '';
22
        },
23
24
        openInNewTab() {
25
            return !!this.action.openNewTab;
26
        },
27
28
        linkData() {
29
            if (this.openInNewTab) {
30
                return {
31
                    target: '_blank',
32
                    href: this.action.url
33
                };
34
            }
35
36
            return {};
37
        }
38
    },
39
40
    methods: {
41
        runAction() {
42
            if (this.openInNewTab) {
43
                return;
44
            }
45
46
            this.$emit('run-app-action', this.action.id);
47
        }
48
    }
49
});
50
51