Skip to content

Commit

Permalink
Add enable all and disable all button
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Dec 21, 2024
1 parent 8e6709b commit 44cf290
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
49 changes: 45 additions & 4 deletions src/components/dialog/content/setting/ExtensionPanel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<template>
<PanelTemplate value="Extension" class="extension-panel">
<template #header>
<SearchBox
v-model="filters['global'].value"
:placeholder="$t('g.searchExtensions') + '...'"
/>
<div class="flex flex-row items-center">
<SearchBox
class="flex-grow"
v-model="filters['global'].value"
:placeholder="$t('g.searchExtensions') + '...'"
/>
<Button
icon="pi pi-ellipsis-v"
text
severity="secondary"
@click="menu.show($event)"
/>
<ContextMenu ref="menu" :model="contextMenuItems" />
</div>
<Message v-if="hasChanges" severity="info" pt:text="w-full">
<ul>
<li v-for="ext in changedExtensions" :key="ext.name">
Expand Down Expand Up @@ -58,6 +68,7 @@ import DataTable from 'primevue/datatable'
import Column from 'primevue/column'
import ToggleSwitch from 'primevue/toggleswitch'
import Button from 'primevue/button'
import ContextMenu from 'primevue/contextmenu'
import Message from 'primevue/message'
import { FilterMatchMode } from '@primevue/core/api'
import PanelTemplate from './PanelTemplate.vue'
Expand Down Expand Up @@ -104,8 +115,38 @@ const updateExtensionStatus = () => {
])
}
const enableAllExtensions = () => {
extensionStore.extensions.forEach((ext) => {
editingEnabledExtensions.value[ext.name] = true
})
updateExtensionStatus()
}
const disableAllExtensions = () => {
extensionStore.extensions.forEach((ext) => {
if (extensionStore.isExtensionAlwaysEnabled(ext.name)) return
editingEnabledExtensions.value[ext.name] = false
})
updateExtensionStatus()
}
const applyChanges = () => {
// Refresh the page to apply changes
window.location.reload()
}
const menu = ref<InstanceType<typeof ContextMenu>>()
const contextMenuItems = [
{
label: 'Enable All',
icon: 'pi pi-check',
command: enableAllExtensions
},
{
label: 'Disable All',
icon: 'pi pi-times',
command: disableAllExtensions
}
]
</script>
4 changes: 3 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"searchFailedMessage": "We couldn't find any settings matching your search. Try adjusting your search terms.",
"noTasksFound": "No Tasks Found",
"noTasksFoundMessage": "There are no tasks in the queue.",
"newFolder": "New Folder"
"newFolder": "New Folder",
"enableAll": "Enable All",
"disableAll": "Disable All"
},
"color": {
"default": "Default",
Expand Down

0 comments on commit 44cf290

Please sign in to comment.