File size: 5,721 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
<html>
<head>
    <title>Existing plugin configurations</title>
    <script type="module">
        import { store } from "/components/plugins/plugin-settings-store.js";
    </script>
</head>
<body>
    <div x-data="(() => {
        const modals = Array.from(document.querySelectorAll('.modal.show'));
        const parentModal = /** @type {HTMLElement & { __pluginSettingsContext?: object }} */ (modals[modals.length - 2] || null);
        return {
            context: parentModal?.__pluginSettingsContext || null,
        };
    })()">
        <template x-if="context">
            <div x-create="context.loadConfigList()" class="plugin-configs-container">

                <div x-show="context.configsError" class="plugin-configs-error">
                    <x-icon name="error"></x-icon>
                    <span x-text="context.configsError"></span>
                </div>

                <div x-show="context.isListingConfigs" class="plugin-configs-loading">
                    <x-icon class="spinning" name="progress_activity"></x-icon>
                    <span>Loading configurations...</span>
                </div>

                <div x-show="!context.isListingConfigs" class="plugin-configs-list">
                    <template x-if="(context.configs || []).length === 0">
                        <div class="plugin-configs-empty">No configurations found.</div>
                    </template>

                    <template x-for="cfg in (context.configs || [])" :key="(cfg.project_name || '') + '|' + (cfg.agent_profile || '')">
                        <div class="plugin-configs-row">
                            <div class="plugin-configs-scope">
                                <div class="plugin-configs-scope-top">
                                    <div class="plugin-configs-scope-line">
                                        <span class="plugin-configs-scope-key">Project:</span>
                                        <span x-text="context.projectLabel(cfg.project_name || '')"></span>
                                    </div>
                                    <div class="plugin-configs-scope-line">
                                        <span class="plugin-configs-scope-key">Agent profile:</span>
                                        <span x-text="context.agentProfileLabel(cfg.agent_profile || '')"></span>
                                    </div>
                                </div>
                                <div class="plugin-configs-scope-sub" x-text="cfg.path || ''"></div>
                            </div>

                            <div class="plugin-configs-actions">
                                <button type="button" class="button" @click="context.switchToConfig(cfg.project_name || '', cfg.agent_profile || '')">
                                    <x-icon class="icon" name="list"></x-icon>
                                    Show
                                </button>
                                <button type="button" class="button cancel icon-button" title="Delete" @click="$confirmClick($event, () => context.deleteConfig(cfg.project_name || '', cfg.agent_profile || ''))">
                                    <x-icon class="icon" name="delete"></x-icon>
                                </button>
                            </div>
                        </div>
                    </template>
                </div>

            </div>
        </template>
    </div>

    <style>
        .plugin-configs-loading,
        .plugin-configs-error {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            margin-bottom: 0.75rem;
            font-size: var(--font-size-small);
        }

        .plugin-configs-container {
            padding: 0.75rem;
        }

        .plugin-configs-error {
            color: var(--color-error);
            background: rgba(255, 0, 0, 0.07);
            border: 1px solid rgba(255, 0, 0, 0.2);
            border-radius: 4px;
        }

        .plugin-configs-list {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .plugin-configs-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 0.75rem;
            border: 1px solid var(--color-border);
            border-radius: 6px;
            background: var(--color-surface);
        }

        .plugin-configs-scope {
            flex: 1 1 auto;
            min-width: 0;
        }

        .plugin-configs-scope-top {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            align-items: baseline;
        }

        .plugin-configs-scope-line {
            display: flex;
            gap: 0.35rem;
            align-items: baseline;
        }

        .plugin-configs-scope-key {
            font-weight: 600;
            color: var(--color-text-secondary);
            white-space: nowrap;
        }

        .plugin-configs-scope-sub {
            font-size: var(--font-size-small);
            color: var(--color-text-secondary);
            margin-top: 0.2rem;
            white-space: normal;
            overflow-wrap: break-word;
            word-break: normal;
        }

        .plugin-configs-actions {
            display: flex;
            gap: 0.5rem;
            flex-wrap: nowrap;
            justify-content: flex-end;
            flex: 0 0 auto;
        }

        .plugin-configs-empty {
            padding: 0.75rem;
            color: var(--color-text-secondary);
            font-size: var(--font-size-small);
        }
    </style>
</body>
</html>