Passed
Push — trunk ( 4eca33...149604 )
by Christian
26:07 queued 13s
created

index.ts ➔ data   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
dl 0
loc 4
rs 10
1
import type { ComponentSectionEntry } from 'src/app/state/extension-component-sections.store';
2
import template from './sw-extension-component-section.html.twig';
3
4
/**
5
 * @package admin
6
 *
7
 * @private
8
 * @description A card is a flexible and extensible content container.
9
 * @status ready
10
 * @example-type dynamic
11
 * @component-example
12
 * <sw-extension-component-section positionId="my-special-position" />
13
 */
14
Shopware.Component.register('sw-extension-component-section', {
15
    template,
16
17
    extensionApiDevtoolInformation: {
18
        property: 'ui.componentSection',
19
        method: 'add',
20
        // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
        positionId: (currentComponent) => currentComponent.positionIdentifier as string,
22
    },
23
24
    data() {
25
        return {
26
            activeTabName: '',
27
        };
28
    },
29
30
    methods: {
31
        setActiveTab(name: string) {
32
            this.activeTabName = name;
33
        },
34
35
        getActiveTab(componentSection: ComponentSectionEntry) {
36
            return this.activeTabName
37
                ? componentSection.props.tabs.find(tab => tab.name === this.activeTabName)
38
                : componentSection.props.tabs[0];
39
        },
40
    },
41
42
    props: {
43
        positionIdentifier: {
44
            type: String,
45
            required: true,
46
        },
47
    },
48
49
    computed: {
50
        componentSections(): ComponentSectionEntry[] {
51
            return Shopware.State.get('extensionComponentSections').identifier[this.positionIdentifier] ?? [];
52
        },
53
    },
54
});
55