|
1 | 1 | <script> |
2 | 2 | import { onMount } from 'svelte'; |
3 | | - import { Shield, Calendar, Loader2, Terminal, Key, Users, UserCog, AlertTriangle, ChevronDown, ChevronUp } from '@lucide/svelte'; |
| 3 | + import { Shield, Calendar, Image as ImageIcon, Loader2, Terminal, Key, Users, UserCog, AlertTriangle, ChevronDown, ChevronUp } from '@lucide/svelte'; |
4 | 4 | import { agentSecurity, getSecuritySettings, updateSecuritySettings, authPolicy } from '../api.js'; |
5 | 5 | import AgentSecurityAllowlistEditor from './AgentSecurityAllowlistEditor.svelte'; |
6 | 6 | import Toggle from '../components/Toggle.svelte'; |
|
19 | 19 |
|
20 | 20 | let calendarFeedEnabled = $state(true); |
21 | 21 | let pluginCliExecEnabled = $state(false); |
| 22 | + let allowExternalImages = $state(false); |
22 | 23 | let allowUserManagedAgents = $state(false); |
23 | 24 | let maxAgentsPerUser = $state(5); |
24 | 25 | let workspaceManagedAgents = $state(true); |
|
111 | 112 | const settings = await getSecuritySettings(); |
112 | 113 | calendarFeedEnabled = settings.calendar_feed_enabled ?? true; |
113 | 114 | pluginCliExecEnabled = settings.plugin_cli_exec_enabled ?? false; |
| 115 | + allowExternalImages = settings.allow_external_images ?? false; |
114 | 116 | allowUserManagedAgents = settings.allow_user_managed_agents ?? false; |
115 | 117 | maxAgentsPerUser = settings.max_agents_per_user ?? 5; |
116 | 118 | workspaceManagedAgents = settings.workspace_managed_agents ?? true; |
|
151 | 153 | await updateSecuritySettings({ |
152 | 154 | calendar_feed_enabled: calendarFeedEnabled, |
153 | 155 | plugin_cli_exec_enabled: pluginCliExecEnabled, |
| 156 | + allow_external_images: allowExternalImages, |
154 | 157 | allow_user_managed_agents: allowUserManagedAgents, |
155 | 158 | max_agents_per_user: maxAgentsPerUser, |
156 | 159 | workspace_managed_agents: workspaceManagedAgents, |
157 | 160 | api_key_creation_policy: apiKeyCreationPolicy, |
158 | 161 | api_key_allowed_group_ids: apiKeyAllowedGroupIds |
159 | 162 | }); |
| 163 | + return true; |
160 | 164 | } catch (err) { |
161 | 165 | errorToast(t('settings.security.failedToSave')); |
162 | 166 | console.error('Failed to save settings:', err); |
| 167 | + return false; |
163 | 168 | } finally { |
164 | 169 | saving = false; |
165 | 170 | } |
|
192 | 197 | await saveSettings(); |
193 | 198 | } |
194 | 199 |
|
| 200 | + async function handleExternalImagesToggle(newValue) { |
| 201 | + allowExternalImages = newValue; |
| 202 | + if (!(await saveSettings())) { |
| 203 | + allowExternalImages = !newValue; |
| 204 | + } |
| 205 | + } |
| 206 | +
|
195 | 207 | async function handleUserManagedAgentsToggle(newValue) { |
196 | 208 | allowUserManagedAgents = newValue; |
197 | 209 | await saveSettings(); |
|
290 | 302 | </div> |
291 | 303 | </Panel> |
292 | 304 |
|
| 305 | + <!-- External Markdown Images --> |
| 306 | + <div class="mt-4"> |
| 307 | + <Panel padding="spacious"> |
| 308 | + <div class="flex items-start gap-4"> |
| 309 | + <div class="p-2 rounded-lg" style="background-color: var(--ds-background-neutral);"> |
| 310 | + <ImageIcon class="w-5 h-5" style="color: var(--ds-icon);" /> |
| 311 | + </div> |
| 312 | + <div class="min-w-0 flex-1"> |
| 313 | + <div class="flex items-center justify-between gap-4"> |
| 314 | + <div class="min-w-0"> |
| 315 | + <h3 class="text-base font-medium" style="color: var(--ds-text);"> |
| 316 | + {t('settings.security.externalImages')} |
| 317 | + </h3> |
| 318 | + <p class="text-sm mt-1" style="color: var(--ds-text-subtle);"> |
| 319 | + {t('settings.security.externalImagesDesc')} |
| 320 | + </p> |
| 321 | + <p class="text-xs mt-2" style="color: var(--ds-text-subtle);"> |
| 322 | + {t('settings.security.externalImagesRefresh')} |
| 323 | + </p> |
| 324 | + </div> |
| 325 | + <Toggle |
| 326 | + bind:checked={allowExternalImages} |
| 327 | + ariaLabel={t('settings.security.externalImages')} |
| 328 | + dataTestid="external-images-toggle" |
| 329 | + disabled={saving} |
| 330 | + onchange={handleExternalImagesToggle} |
| 331 | + /> |
| 332 | + </div> |
| 333 | +
|
| 334 | + {#if allowExternalImages} |
| 335 | + <div class="mt-3"> |
| 336 | + <AlertBox variant="warning" message={t('settings.security.externalImagesWarning')} /> |
| 337 | + </div> |
| 338 | + {/if} |
| 339 | + </div> |
| 340 | + </div> |
| 341 | + </Panel> |
| 342 | + </div> |
| 343 | +
|
293 | 344 | <!-- Plugin CLI Execution Settings --> |
294 | 345 | <div class="mt-4"> |
295 | 346 | <Panel padding="spacious"> |
|
0 commit comments