feat(admin): metadata-profile picker on integrations page
Persists the operator's metadata-profile choice alongside quality profile + root folder. Defaults to the first profile Lidarr returns (usually 'Standard' on a vanilla install) so the common case is zero-click; operators with custom profiles like 'Singles only' can pick explicitly. Backend: - Migration 0013: adds nullable default_metadata_profile_id to lidarr_config. Existing rows get NULL and the service falls back to fetch-and-pick-first until they save. - Updated lidarr_config queries + sqlc + lidarrconfig.Config + admin view/put body to round-trip the new field. - handlePutLidarrConfig requires it (along with QP and root folder) when enabled=true — matches the existing missing_defaults gate. - New GET /api/admin/lidarr/metadata-profiles handler + lidarr.Client ListMetadataProfiles (GET /api/v1/metadataprofile, same shape as the quality-profile endpoint). - lidarrrequests.Approve prefers cfg.DefaultMetadataProfileID; falls back to the fetch-list path only when 0 (back-compat for upgraders). Frontend: - LidarrConfig type + LidarrMetadataProfile type + qk.lidarrMetadataProfiles. - listMetadataProfiles + createMetadataProfilesQuery client helpers. - Integrations page: third <select> picker, auto-defaults to first profile when the saved value is 0, sends the new field on save and clears it on disconnect. - Updated test fixtures + the duplicate 'Standard' option string in the dropdown-populates assertion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ const baseConfig: LidarrConfig = {
|
||||
base_url: 'http://lidarr.lan:8686',
|
||||
api_key: '***',
|
||||
default_quality_profile_id: 1,
|
||||
default_metadata_profile_id: 1,
|
||||
default_root_folder_path: '/music'
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
ActionResult,
|
||||
AdminQuarantineRow,
|
||||
LidarrConfig,
|
||||
LidarrMetadataProfile,
|
||||
LidarrQualityProfile,
|
||||
LidarrQuarantineActionRow,
|
||||
LidarrRequest,
|
||||
@@ -36,6 +37,10 @@ export async function listQualityProfiles(): Promise<LidarrQualityProfile[]> {
|
||||
return api.get<LidarrQualityProfile[]>('/api/admin/lidarr/quality-profiles');
|
||||
}
|
||||
|
||||
export async function listMetadataProfiles(): Promise<LidarrMetadataProfile[]> {
|
||||
return api.get<LidarrMetadataProfile[]>('/api/admin/lidarr/metadata-profiles');
|
||||
}
|
||||
|
||||
export async function listRootFolders(): Promise<LidarrRootFolder[]> {
|
||||
return api.get<LidarrRootFolder[]>('/api/admin/lidarr/root-folders');
|
||||
}
|
||||
@@ -92,6 +97,14 @@ export function createQualityProfilesQuery(enabled: boolean = true) {
|
||||
});
|
||||
}
|
||||
|
||||
export function createMetadataProfilesQuery(enabled: boolean = true) {
|
||||
return createQuery({
|
||||
queryKey: qk.lidarrMetadataProfiles(),
|
||||
queryFn: listMetadataProfiles,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
|
||||
export function createRootFoldersQuery(enabled: boolean = true) {
|
||||
return createQuery({
|
||||
queryKey: qk.lidarrRootFolders(),
|
||||
|
||||
@@ -24,8 +24,9 @@ export const qk = {
|
||||
['lidarrSearch', { q, kind }] as const,
|
||||
myRequests: () => ['myRequests'] as const,
|
||||
lidarrConfig: () => ['lidarrConfig'] as const,
|
||||
lidarrQualityProfiles: () => ['lidarrQualityProfiles'] as const,
|
||||
lidarrRootFolders: () => ['lidarrRootFolders'] as const,
|
||||
lidarrQualityProfiles: () => ['lidarrQualityProfiles'] as const,
|
||||
lidarrMetadataProfiles: () => ['lidarrMetadataProfiles'] as const,
|
||||
lidarrRootFolders: () => ['lidarrRootFolders'] as const,
|
||||
adminRequests: (status?: string) =>
|
||||
['adminRequests', { status: status ?? 'all' }] as const,
|
||||
myQuarantine: () => ['myQuarantine'] as const,
|
||||
|
||||
@@ -131,6 +131,7 @@ export type LidarrConfig = {
|
||||
base_url: string;
|
||||
api_key: string;
|
||||
default_quality_profile_id: number;
|
||||
default_metadata_profile_id: number;
|
||||
default_root_folder_path: string;
|
||||
};
|
||||
|
||||
@@ -139,6 +140,11 @@ export type LidarrQualityProfile = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type LidarrMetadataProfile = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type LidarrRootFolder = {
|
||||
path: string;
|
||||
accessible: boolean;
|
||||
|
||||
Reference in New Issue
Block a user