feat: Add update_theme functionality with UI support
Backend: - Add PUT /api/themes/:id endpoint for updating existing themes Store: - Add updateTheme method to theme store MCP: - Add update_theme tool to modify name, description, or save current variables UI: - Add edit button to ThemeListItem (custom themes only) - Add edit modal with name and description fields - Support editing from both desktop sidebar and mobile dropdown
This commit is contained in:
@@ -138,6 +138,29 @@ export const useThemeStore = defineStore('theme', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateTheme(id: string, data: { name?: string; description?: string; variables?: ThemeVariables; metadata?: ThemeMetadata }) {
|
||||
saving.value = true
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/api/themes/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
const result = await res.json()
|
||||
if (result.error) {
|
||||
error.value = result.error
|
||||
return null
|
||||
}
|
||||
await fetchThemes()
|
||||
return result
|
||||
} catch (e) {
|
||||
error.value = 'Error updating theme'
|
||||
throw e
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTheme(id: string) {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/api/themes/${id}`, { method: 'DELETE' })
|
||||
@@ -281,6 +304,7 @@ export const useThemeStore = defineStore('theme', () => {
|
||||
fetchThemes,
|
||||
fetchDesignTokens,
|
||||
saveTheme,
|
||||
updateTheme,
|
||||
deleteTheme,
|
||||
setDefaultTheme,
|
||||
cloneTheme,
|
||||
|
||||
Reference in New Issue
Block a user