Tom Butcher 24c06c25d3 Refactor JavaScript Language Support and Enhance Autocomplete Functionality
- Consolidated JavaScript completion sources into a new module, improving organization and maintainability.
- Updated the `fcTemplateLang` to utilize the new `javascriptCompletionSources` for enhanced autocomplete capabilities.
- Removed redundant imports and streamlined the code in various components, including Invoices, Payments, TaxRecords, and Inventory sections, by replacing dropdown actions with a unified `ObjectActions` component.
- Improved the handling of object actions across multiple inventory and finance components, enhancing user experience and code consistency.
2026-08-20 19:35:09 +01:00

194 lines
4.6 KiB
JavaScript

import { createElement, lazy } from 'react'
const AppPasswordInfo = lazy(
() =>
import('../../components/Dashboard/Management/AppPasswords/AppPasswordInfo')
)
const NewAppPassword = lazy(
() => import('../../components/Dashboard/Management/AppPasswords/NewAppPassword')
)
const RegenerateAppPasswordSecret = lazy(
() =>
import('../../components/Dashboard/Management/AppPasswords/RegenerateAppPasswordSecret')
)
import AppPasswordIcon from '../../components/Icons/AppPasswordIcon'
import PlusIcon from '../../components/Icons/PlusIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import EditIcon from '../../components/Icons/EditIcon'
import CheckIcon from '../../components/Icons/CheckIcon'
import XMarkIcon from '../../components/Icons/XMarkIcon'
import LockIcon from '../../components/Icons/LockIcon'
export const AppPassword = {
name: 'appPassword',
label: 'App Password',
labelPlural: 'App Passwords',
url: '/dashboard/management/apppasswords',
prefix: 'APP',
icon: AppPasswordIcon,
actions: [
{
name: 'new',
type: 'modal',
pageName: 'list',
modalWidth: 700,
label: 'New App Password',
icon: PlusIcon,
content: (objectData, { onOk } = {}) => {
return createElement(NewAppPassword, { defaultValues: objectData, onOk, reset: true })
}
},
{
name: 'info',
type: 'page',
pageName: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon
},
{
name: 'edit',
type: 'page',
pageName: 'info',
label: 'Edit',
row: true,
icon: EditIcon,
visible: (objectData) => {
return !(objectData?._isEditing && objectData?._isEditing == true)
},
disabled: (objectData) => {
return objectData?._user?._id != objectData?.user?._id
}
},
{
name: 'cancelEdit',
label: 'Cancel Edits',
type: 'page',
pageName: 'info',
icon: XMarkIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{
name: 'finishEdit',
label: 'Save Edits',
type: 'page',
pageName: 'info',
icon: CheckIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{ type: 'divider' },
{
name: 'regenerateSecret',
type: 'modal',
modalWidth: 630,
label: 'Regenerate Secret',
row: true,
icon: LockIcon,
disabled: (objectData) => {
return objectData?._user?._id != objectData?.user?._id
},
content: (objectData, { onOk } = {}) => {
return createElement(RegenerateAppPasswordSecret, {
id: objectData._id,
onOk
})
}
}
],
pages: [
{
name: 'info',
content: () => createElement(AppPasswordInfo)
}
],
columns: ['_reference', 'name', 'user', 'active', 'createdAt', 'updatedAt'],
filters: [
'_id',
'name',
'user',
'active',
'createdAt',
'updatedAt',
'_reference'
],
sorters: ['name', 'user', 'active', 'createdAt', 'updatedAt'],
properties: [
{
name: '_id',
label: 'ID',
columnFixed: 'left',
type: 'id',
objectType: 'appPassword',
showCopy: true,
columnWidth: 140
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: '_reference',
label: 'Reference',
type: 'reference',
columnFixed: 'left',
objectType: 'appPassword',
showCopy: true,
readOnly: true,
columnWidth: 180
},
{
name: 'name',
label: 'Name',
columnFixed: 'left',
required: true,
type: 'text',
columnWidth: 200
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: 'user',
label: 'User',
required: true,
readOnly: (objectData) => {
return objectData?.createdAt != null
},
type: 'object',
objectType: 'user',
showHyperlink: true,
columnWidth: 200
},
{
name: 'active',
label: 'Active',
required: true,
type: 'bool',
columnWidth: 125
},
{
name: 'secret',
label: 'Secret',
type: 'password',
required: false,
readOnly: true,
value: (objectData) =>
objectData?._id ? '••••••••••••••••••••••••••••••••' : undefined,
columnWidth: 200
}
]
}