Add new types for integration configuration

This commit is contained in:
Meierschlumpf
2022-12-11 19:16:31 +01:00
parent 68a97e5f27
commit ed64d138c5
10 changed files with 153 additions and 66 deletions

View File

@@ -16,9 +16,13 @@ export interface ServiceType extends TileBaseType {
behaviour: ServiceBehaviourType;
network: ServiceNetworkType;
appearance: ServiceAppearanceType;
integration?: ServiceIntegrationType;
integration?: ServiceIntegrationType | null;
}
export type ConfigServiceType = Omit<ServiceType, 'integration'> & {
integration?: ConfigServiceIntegrationType | null;
};
interface ServiceBehaviourType {
onClickUrl: string;
isOpeningNewTab: boolean;
@@ -33,7 +37,7 @@ interface ServiceAppearanceType {
iconUrl: string;
}
type IntegrationType =
export type IntegrationType =
| 'readarr'
| 'radarr'
| 'sonarr'
@@ -51,12 +55,19 @@ export type ServiceIntegrationType = {
properties: ServiceIntegrationPropertyType[];
};
type ServiceIntegrationPropertyType = {
export type ConfigServiceIntegrationType = Omit<ServiceIntegrationType, 'properties'> & {
properties: ConfigServiceIntegrationPropertyType[];
};
export type ServiceIntegrationPropertyType = {
type: 'private' | 'public';
field: IntegrationField;
value?: string;
value?: string | null;
isDefined: boolean;
};
type ConfigServiceIntegrationPropertyType = Omit<ServiceIntegrationPropertyType, 'isDefined'>;
export type IntegrationField = 'apiKey' | 'password' | 'username';
export const integrationFieldProperties: {
@@ -76,6 +87,7 @@ export const integrationFieldProperties: {
};
export type IntegrationFieldDefinitionType = {
type: 'private' | 'public';
icon: TablerIcon;
iconUnset: TablerIcon;
label: string;
@@ -85,16 +97,19 @@ export const integrationFieldDefinitions: {
[key in IntegrationField]: IntegrationFieldDefinitionType;
} = {
apiKey: {
type: 'private',
icon: IconKey,
iconUnset: IconKeyOff,
label: 'API Key',
},
username: {
type: 'public',
icon: IconUser,
iconUnset: IconUserOff,
label: 'Username',
},
password: {
type: 'private',
icon: IconPassword,
iconUnset: IconLockOff,
label: 'Password',