AAE-21047 Get rid of enums (#11643)

* Refactor enums to const objects and update ESLint rules

- Converted several TypeScript enums to const objects for better type inference and immutability.
- Updated ESLint configuration to disable 'no-redeclare' rule and added new restrictions on schema usage.
- Adjusted package-lock.json to mark several dependencies as peer dependencies.

* Refactor enums to const objects in site-dropdown and new-version-uploader models

- Converted TypeScript enums to const objects for improved type safety and immutability in `sites-dropdown.component.ts` and `new-version-uploader.model.ts`.
- Updated related types to reflect the changes in both files.
- Enhanced error handling in the `DropdownSitesComponent` by using the `subscribe` method with an object for better readability.

* Refactor TypeScript types and improve error handling in component tests

- Updated type annotations in `upload.service.ts` and `node-actions.service.ts` for better type safety.
- Enhanced error handling in various component tests by using more descriptive error messages in `task-attachment-list.component.spec.ts`, `attach-file-widget-dialog.component.spec.ts`, and `task-form.component.spec.ts`.
- Removed unnecessary schemas from test configurations in several component spec files to streamline the testing setup.

* Refactor TypeScript enums to const objects for improved type safety

- Converted multiple TypeScript enums to const objects across various models, including `AppConfigValues`, `Status`, `ShowHeaderMode`, `WidgetTypeEnum`, and others.
- Updated related type definitions to enhance type inference and immutability.
- Adjusted ESLint configurations by removing the 'no-redeclare' rule to streamline code quality checks.

* Refactor TypeScript types for improved type safety and consistency

- Updated type annotations in `document-list.component.ts`, `document-actions.service.ts`, and `node-actions.service.ts` to use `Observable` instead of `Subject` for better reactive programming practices.
- Enhanced type definitions in `search-date-range.component.ts` and related spec files to allow `inLastValue` to be either a string or a number, improving flexibility in handling date range inputs.
- Adjusted test cases to reflect these type changes, ensuring consistency across the application.

* Enhance type safety in ViewerComponent by specifying type for closeButtonPosition

- Updated the type annotation for `closeButtonPosition` in `viewer.component.ts` to explicitly define it as `CloseButtonPosition`, improving type safety and clarity.

* Enhance type safety in DataTableComponent by specifying type for showHeader

- Updated the type annotation for `showHeader` in `datatable.component.ts` to explicitly define it as `ShowHeaderMode`, improving type safety and clarity.

* Update PDF viewer test to accommodate varying date formats

- Modified the test for the annotation popup in `pdf-viewer.component.spec.ts` to check for the presence of date components instead of a specific date format, enhancing test robustness across different locales.
This commit is contained in:
Denys Vuika
2026-02-12 16:28:45 +00:00
committed by GitHub
parent d274d62d73
commit 40b15689d5
54 changed files with 503 additions and 415 deletions
@@ -74,7 +74,6 @@
"no-bitwise": "off",
"no-duplicate-imports": "error",
"no-multiple-empty-lines": "error",
"no-redeclare": "error",
"no-return-await": "error",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
@@ -48,10 +48,12 @@ export interface Descriptor {
customUIAuthFlowType?: DescriptorCustomUIAuthFlowType;
}
export enum DescriptorCustomUIAuthFlowType {
CODE = 'CODE',
IMPLICIT = 'IMPLICIT'
}
export const DescriptorCustomUIAuthFlowType = {
CODE: 'CODE',
IMPLICIT: 'IMPLICIT'
} as const;
export type DescriptorCustomUIAuthFlowType = (typeof DescriptorCustomUIAuthFlowType)[keyof typeof DescriptorCustomUIAuthFlowType];
export interface DescriptorSecurity {
role: string;
@@ -18,7 +18,6 @@
/* eslint-disable no-shadow */
/* eslint-disable @typescript-eslint/naming-convention */
export class FormCloudRepresentation {
id?: string;
name?: string;
description?: string;
@@ -57,13 +56,17 @@ export interface DestinationFolderPathModel {
path: string;
}
export enum FileSourceTypes {
ALL_FILE_SOURCES_SERVICE_ID = 'all-file-sources',
ALFRESCO_CONTENT_SOURCES_SERVICE_ID = 'alfresco-content'
}
export const FileSourceTypes = {
ALL_FILE_SOURCES_SERVICE_ID: 'all-file-sources',
ALFRESCO_CONTENT_SOURCES_SERVICE_ID: 'alfresco-content'
} as const;
export enum DestinationFolderPathType {
STATIC_TYPE = 'value',
STRING_TYPE = 'string',
FOLDER_TYPE = 'folder'
}
export type FileSourceTypes = (typeof FileSourceTypes)[keyof typeof FileSourceTypes];
export const DestinationFolderPathType = {
STATIC_TYPE: 'value',
STRING_TYPE: 'string',
FOLDER_TYPE: 'folder'
} as const;
export type DestinationFolderPathType = (typeof DestinationFolderPathType)[keyof typeof DestinationFolderPathType];
@@ -17,18 +17,19 @@
/* eslint-disable @typescript-eslint/naming-convention */
// eslint-disable-next-line no-shadow
export enum DateCloudFilterType {
NO_DATE = 'NO_DATE',
TODAY = 'TODAY',
TOMORROW = 'TOMORROW',
NEXT_7_DAYS = 'NEXT_7_DAYS',
WEEK = 'WEEK',
MONTH = 'MONTH',
QUARTER = 'QUARTER',
YEAR = 'YEAR',
RANGE = 'RANGE'
}
export const DateCloudFilterType = {
NO_DATE: 'NO_DATE',
TODAY: 'TODAY',
TOMORROW: 'TOMORROW',
NEXT_7_DAYS: 'NEXT_7_DAYS',
WEEK: 'WEEK',
MONTH: 'MONTH',
QUARTER: 'QUARTER',
YEAR: 'YEAR',
RANGE: 'RANGE'
} as const;
export type DateCloudFilterType = (typeof DateCloudFilterType)[keyof typeof DateCloudFilterType];
export interface DateRangeFilter {
startDate: string;
@@ -15,9 +15,10 @@
* limitations under the License.
*/
// eslint-disable-next-line no-shadow
export enum ProcessListCloudPreferences {
columnOrder = 'processes-cloud-list-columns-order',
columnsVisibility = 'processes-cloud-columns-visibility',
columnsWidths = 'processes-cloud-columns-widths'
}
export const ProcessListCloudPreferences = {
columnOrder: 'processes-cloud-list-columns-order',
columnsVisibility: 'processes-cloud-columns-visibility',
columnsWidths: 'processes-cloud-columns-widths'
} as const;
export type ProcessListCloudPreferences = (typeof ProcessListCloudPreferences)[keyof typeof ProcessListCloudPreferences];
@@ -225,42 +225,43 @@ export interface TextField extends FormField {
placeholder: string | null;
}
// eslint-disable-next-line no-shadow
export enum PeopleModeOptions {
single = 'single',
multiple = 'multiple'
}
export const PeopleModeOptions = {
single: 'single',
multiple: 'multiple'
} as const;
export type PeopleModeOptions = (typeof PeopleModeOptions)[keyof typeof PeopleModeOptions];
export interface PeopleField extends FormField {
required: boolean;
optionType: PeopleModeOptions;
}
// eslint-disable-next-line no-shadow
export enum FormFieldType {
text = 'text',
multiline = 'multi-line-text',
// eslint-disable-next-line id-blacklist
number = 'integer',
checkbox = 'boolean',
date = 'date',
datetime = 'datetime',
dropdown = 'dropdown',
typeahead = 'typeahead',
amount = 'amount',
radio = 'radio-buttons',
people = 'people',
groupOfPeople = 'functional-group',
dynamicTable = 'dynamicTable',
hyperlink = 'hyperlink',
header = 'group',
uploadFile = 'upload',
uploadFolder = 'uploadFolder',
displayValue = 'readonly',
displayText = 'readonly-text',
fileViewer = 'file-viewer',
button = 'button'
}
export const FormFieldType = {
text: 'text',
multiline: 'multi-line-text',
number: 'integer',
checkbox: 'boolean',
date: 'date',
datetime: 'datetime',
dropdown: 'dropdown',
typeahead: 'typeahead',
amount: 'amount',
radio: 'radio-buttons',
people: 'people',
groupOfPeople: 'functional-group',
dynamicTable: 'dynamicTable',
hyperlink: 'hyperlink',
header: 'group',
uploadFile: 'upload',
uploadFolder: 'uploadFolder',
displayValue: 'readonly',
displayText: 'readonly-text',
fileViewer: 'file-viewer',
button: 'button'
} as const;
export type FormFieldType = (typeof FormFieldType)[keyof typeof FormFieldType];
export interface FormCloudDisplayModeConfigurationOptions {
onCompleteTask(id?: string): void;
@@ -280,12 +281,13 @@ export interface FormCloudDisplayModeConfiguration {
default?: boolean;
}
// eslint-disable-next-line no-shadow
export enum FormCloudDisplayMode {
inline = 'inline',
fullScreen = 'fullScreen',
standalone = 'standalone'
}
export const FormCloudDisplayMode = {
inline: 'inline',
fullScreen: 'fullScreen',
standalone: 'standalone'
} as const;
export type FormCloudDisplayMode = (typeof FormCloudDisplayMode)[keyof typeof FormCloudDisplayMode];
export interface FormCloudDisplayModeChange {
displayMode: string;
@@ -322,22 +322,26 @@ export interface FilterOptions {
value?: string;
}
export enum AssignmentType {
CURRENT_USER = 'CURRENT_USER',
UNASSIGNED = 'UNASSIGNED',
NONE = 'NONE',
CANDIDATE_GROUPS = 'CANDIDATE_GROUPS',
ASSIGNED_TO = 'ASSIGNED_TO'
}
export const AssignmentType = {
CURRENT_USER: 'CURRENT_USER',
UNASSIGNED: 'UNASSIGNED',
NONE: 'NONE',
CANDIDATE_GROUPS: 'CANDIDATE_GROUPS',
ASSIGNED_TO: 'ASSIGNED_TO'
} as const;
export enum TaskStatusFilter {
ALL = '',
CREATED = 'CREATED',
ASSIGNED = 'ASSIGNED',
SUSPENDED = 'SUSPENDED',
CANCELLED = 'CANCELLED',
COMPLETED = 'COMPLETED'
}
export type AssignmentType = (typeof AssignmentType)[keyof typeof AssignmentType];
export const TaskStatusFilter = {
ALL: '',
CREATED: 'CREATED',
ASSIGNED: 'ASSIGNED',
SUSPENDED: 'SUSPENDED',
CANCELLED: 'CANCELLED',
COMPLETED: 'COMPLETED'
} as const;
export type TaskStatusFilter = (typeof TaskStatusFilter)[keyof typeof TaskStatusFilter];
export interface TaskFilterProperties {
label?: string;
@@ -51,12 +51,13 @@ import { TaskCloudService } from '../../services/task-cloud.service';
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
// eslint-disable-next-line no-shadow
export enum TasksListCloudPreferences {
columnOrder = 'tasks-list-cloud-columns-order',
columnsVisibility = 'tasks-list-cloud-columns-visibility',
columnsWidths = 'tasks-list-cloud-columns-widths'
}
export const TasksListCloudPreferences = {
columnOrder: 'tasks-list-cloud-columns-order',
columnsVisibility: 'tasks-list-cloud-columns-visibility',
columnsWidths: 'tasks-list-cloud-columns-widths'
} as const;
export type TasksListCloudPreferences = (typeof TasksListCloudPreferences)[keyof typeof TasksListCloudPreferences];
const taskPresetsCloudDefaultModel = {
default: [