File size: 5,293 Bytes
430354e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<html>
<head>
    <script type="module">
        import { store } from "/components/settings/plugins/plugins-subsection-store.js";
    </script>
</head>
<body>
    <!--
        Reusable plugin subsection for a settings tab.
        Parent must pass data-tab attribute on the x-component tag, e.g.:
          <x-component path="settings/plugins/plugins-subsection.html" data-tab="agent"></x-component>
        The tab value is read at init time from the x-component element's dataset.
    -->
    <div x-data="(() => ({ context: $instantiate($store.pluginsSubsectionPrototype) }))()">
        <template x-if="context">
            <div x-create="context.init($el)"
                 x-destroy="context.cleanup()">
                <template x-if="context.loading || context.plugins.length > 0">
                    <div>
                        <div class="section-title">Plugins</div>
                        <div class="section-description">
                            Plugin-specific settings for this tab.
                        </div>

                        <div x-show="context.loading" class="loading">
                            <span>Loading plugins...</span>
                        </div>

                        <div class="plugins-list">
                            <template x-for="plugin in context.plugins" :key="plugin.path || plugin.name">
                                <div class="plugin-card">
                                    <div class="plugin-header">
                                        <div class="plugin-heading">
                                            <div class="plugin-title" x-text="plugin.display_name || plugin.name || '(unnamed plugin)'"></div>
                                            <code class="plugin-path" x-text="plugin.path"></code>
                                        </div>
                                        <div class="plugin-actions">
                                            <button type="button"
                                                class="button"
                                                title="Config"
                                                @click="context.openPluginConfig(plugin)">
                                                <x-icon class="icon" name="settings"></x-icon> Config
                                            </button>
                                        </div>
                                    </div>
                                    <div class="plugin-description" x-text="plugin.description || 'No description provided.'"></div>
                                </div>
                            </template>
                        </div>
                    </div>
                </template>
            </div>
        </template>
    </div>

    <style>
        /* Reused styles from plugin-list.html for uniformity */
        .plugins-list {
            margin-top: 0.25rem;
        }

        .plugin-card {
            border: 1px solid var(--color-border);
            border-radius: 10px;
            padding: 0.75rem;
            margin-top: 0.75rem;
            background: var(--color-background);
        }

        .plugin-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 1rem;
            flex-wrap: nowrap;
            min-width: 0;
        }

        .plugin-heading {
            display: flex;
            flex-direction: column;
            min-width: 0;
            flex: 1 1 auto;
        }

        .plugin-title {
            font-weight: 600;
            font-size: 1rem;
            min-width: 0;
            flex: 1 1 auto;
        }

        .plugin-actions {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding-bottom: var(--spacing-sm);
            flex-wrap: nowrap;
            min-width: 0;
            flex: 0 0 auto;
            max-width: 100%;
            justify-content: flex-end;
        }

        .plugin-description {
            margin-top: 0.35rem;
            color: var(--color-text-secondary);
            font-size: var(--font-size-small);
        }

        .plugin-path {
            margin-top: 0.35rem;
            font-size: 0.85rem;
            color: var(--color-text-muted);
            min-width: 0;
            max-width: 100%;
            white-space: pre-wrap;
            word-break: break-word;
            overflow-wrap: anywhere;
        }

        .loading {
            width: 100%;
            text-align: center;
            margin-top: 0.75rem;
            margin-bottom: 0.75rem;
            color: var(--color-secondary);
        }

        @media (max-width: 640px) {
            .plugin-header {
                flex-direction: column;
                align-items: stretch;
            }

            .plugin-heading {
                width: 100%;
                flex: 0 0 auto;
            }

            .plugin-actions {
                width: 100%;
                justify-content: flex-start;
                padding-bottom: 0;
                flex-wrap: wrap;
            }

            .plugin-path {
                white-space: normal;
                word-break: break-word;
            }
        }
    </style>
</body>
</html>