diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index bb9125fe1..dadc2a41d 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -11,6 +11,7 @@ import { ServerService } from '@app/core/server/server.service' import { getDevLocale, isOnDevLocale } from '@app/helpers' import { CustomModalComponent } from '@app/modal/custom-modal.component' import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager' +import { getKeys } from '@shared/core-utils' import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' import { ClientHook, @@ -134,7 +135,7 @@ export class PluginService implements ClientHook { } async translateSetting (npmName: string, setting: RegisterClientFormFieldOptions) { - for (const key of [ 'label', 'html', 'descriptionHTML' ]) { + for (const key of getKeys(setting, [ 'label', 'html', 'descriptionHTML' ])) { if (setting[key]) setting[key] = await this.translateBy(npmName, setting[key]) } diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html index c228069b5..2ef61ecfc 100644 --- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html @@ -1,4 +1,4 @@ -
+
(object: O, keys: K[]): Pick return result } +function getKeys (object: O, keys: K[]): K[] { + return (Object.keys(object) as K[]).filter(k => keys.includes(k)) +} + function sortObjectComparator (key: string, order: 'asc' | 'desc') { return (a: any, b: any) => { if (a[key] < b[key]) { @@ -26,5 +30,6 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') { export { pick, + getKeys, sortObjectComparator } diff --git a/shared/core-utils/videos/bitrate.ts b/shared/core-utils/videos/bitrate.ts index c1891188f..30d22df09 100644 --- a/shared/core-utils/videos/bitrate.ts +++ b/shared/core-utils/videos/bitrate.ts @@ -1,4 +1,4 @@ -import { VideoResolution } from "@shared/models" +import { VideoResolution } from '@shared/models' type BitPerPixel = { [ id in VideoResolution ]: number } diff --git a/shared/core-utils/videos/index.ts b/shared/core-utils/videos/index.ts index 8f6736d39..620e3a716 100644 --- a/shared/core-utils/videos/index.ts +++ b/shared/core-utils/videos/index.ts @@ -1,3 +1,2 @@ export * from './bitrate' export * from './privacy' -export * from './uuid' diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 373d27cb4..e2e161a7b 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts @@ -1,3 +1,4 @@ export * from './crypto' export * from './ffprobe' export * from './file' +export * from './uuid' diff --git a/shared/core-utils/videos/uuid.ts b/shared/extra-utils/uuid.ts similarity index 100% rename from shared/core-utils/videos/uuid.ts rename to shared/extra-utils/uuid.ts diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index ead57b9aa..21753ddc4 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts @@ -5,7 +5,8 @@ import { createReadStream, stat } from 'fs-extra' import got, { Response as GotResponse } from 'got' import { omit } from 'lodash' import validator from 'validator' -import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils' +import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils' +import { buildUUID } from '@shared/extra-utils' import { HttpStatusCode, ResultList,