From fb4db839112338ee953dd46f17c943345796edfd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:36:00 +1100 Subject: [PATCH] chore(ui): lint --- invokeai/frontend/web/public/locales/en.json | 1 + .../src/common/hooks/useModelCustomSelect.ts | 2 +- .../src/features/canvas/store/canvasTypes.ts | 2 -- .../features/gallery/hooks/useImageActions.ts | 2 +- .../components/MetadataT2IAdapters.tsx | 2 +- .../metadata/components/RecallButton.tsx | 2 +- .../web/src/features/metadata/exceptions.ts | 1 - .../metadata/hooks/useMetadataItem.tsx | 18 +++++++++++++----- .../ModelPanel/Fields/ModelTypeSelect.tsx | 2 +- .../hooks/useAnyOrDirectInputFieldNames.ts | 2 +- .../hooks/useConnectionInputFieldNames.ts | 2 +- .../nodes/hooks/useOutputFieldNames.ts | 2 +- .../parameters/hooks/usePreselectedImage.ts | 1 - .../GenerationSettingsAccordion.tsx | 2 +- .../web/src/services/api/endpoints/models.ts | 4 ++-- 15 files changed, 25 insertions(+), 20 deletions(-) diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index cdb1061bb3..2c50cbcb82 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -674,6 +674,7 @@ "noMetaData": "No metadata found", "noRecallParameters": "No parameters to recall found", "parameterSet": "Parameter {{parameter}} set", + "parsingFailed": "Parsing Failed", "perlin": "Perlin Noise", "positivePrompt": "Positive Prompt", "recallParameters": "Recall Parameters", diff --git a/invokeai/frontend/web/src/common/hooks/useModelCustomSelect.ts b/invokeai/frontend/web/src/common/hooks/useModelCustomSelect.ts index 6e5c8ca870..5626f4c395 100644 --- a/invokeai/frontend/web/src/common/hooks/useModelCustomSelect.ts +++ b/invokeai/frontend/web/src/common/hooks/useModelCustomSelect.ts @@ -1,6 +1,6 @@ import type { Item } from '@invoke-ai/ui-library'; import type { EntityState } from '@reduxjs/toolkit'; -import { EMPTY_ARRAY } from "app/store/constants"; +import { EMPTY_ARRAY } from 'app/store/constants'; import type { ModelIdentifierWithBase } from 'features/nodes/types/common'; import { MODEL_TYPE_SHORT_MAP } from 'features/parameters/types/constants'; import { filter } from 'lodash-es'; diff --git a/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts b/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts index e0e7d5b1cd..14248cd750 100644 --- a/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts +++ b/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts @@ -10,8 +10,6 @@ export const LAYER_NAMES_DICT: { label: string; value: CanvasLayer }[] = [ { label: 'Mask', value: 'mask' }, ]; -const LAYER_NAMES = ['base', 'mask'] as const; - const zBoundingBoxScaleMethod = z.enum(['none', 'auto', 'manual']); export type BoundingBoxScaleMethod = z.infer; export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod => diff --git a/invokeai/frontend/web/src/features/gallery/hooks/useImageActions.ts b/invokeai/frontend/web/src/features/gallery/hooks/useImageActions.ts index a61b2096da..c3ae0cea5f 100644 --- a/invokeai/frontend/web/src/features/gallery/hooks/useImageActions.ts +++ b/invokeai/frontend/web/src/features/gallery/hooks/useImageActions.ts @@ -58,5 +58,5 @@ export const useImageActions = (image_name?: string) => { parseAndRecallPrompts(metadata); }, [metadata]); - return { recallAll, remix, recallSeed, recallPrompts , hasMetadata, hasSeed, hasPrompts, isLoadingMetadata }; + return { recallAll, remix, recallSeed, recallPrompts, hasMetadata, hasSeed, hasPrompts, isLoadingMetadata }; }; diff --git a/invokeai/frontend/web/src/features/metadata/components/MetadataT2IAdapters.tsx b/invokeai/frontend/web/src/features/metadata/components/MetadataT2IAdapters.tsx index 6b1de889ff..82575783e9 100644 --- a/invokeai/frontend/web/src/features/metadata/components/MetadataT2IAdapters.tsx +++ b/invokeai/frontend/web/src/features/metadata/components/MetadataT2IAdapters.tsx @@ -53,7 +53,7 @@ const MetadataViewT2IAdapter = ({ } handlers.recallItem(t2iAdapter, true); }, [handlers, t2iAdapter]); - + const [renderedValue, setRenderedValue] = useState(null); useEffect(() => { const _renderValue = async () => { diff --git a/invokeai/frontend/web/src/features/metadata/components/RecallButton.tsx b/invokeai/frontend/web/src/features/metadata/components/RecallButton.tsx index 8803945b06..c531481a89 100644 --- a/invokeai/frontend/web/src/features/metadata/components/RecallButton.tsx +++ b/invokeai/frontend/web/src/features/metadata/components/RecallButton.tsx @@ -1,4 +1,4 @@ -import type { IconButtonProps} from '@invoke-ai/ui-library'; +import type { IconButtonProps } from '@invoke-ai/ui-library'; import { IconButton, Tooltip } from '@invoke-ai/ui-library'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; diff --git a/invokeai/frontend/web/src/features/metadata/exceptions.ts b/invokeai/frontend/web/src/features/metadata/exceptions.ts index 8b13789179..e69de29bb2 100644 --- a/invokeai/frontend/web/src/features/metadata/exceptions.ts +++ b/invokeai/frontend/web/src/features/metadata/exceptions.ts @@ -1 +0,0 @@ - diff --git a/invokeai/frontend/web/src/features/metadata/hooks/useMetadataItem.tsx b/invokeai/frontend/web/src/features/metadata/hooks/useMetadataItem.tsx index 63d987569b..18df0c7323 100644 --- a/invokeai/frontend/web/src/features/metadata/hooks/useMetadataItem.tsx +++ b/invokeai/frontend/web/src/features/metadata/hooks/useMetadataItem.tsx @@ -2,15 +2,23 @@ import { Text } from '@invoke-ai/ui-library'; import type { MetadataHandlers } from 'features/metadata/types'; import { MetadataParseFailedToken, MetadataParsePendingToken } from 'features/metadata/util/parsers'; import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; -const pendingRenderedValue = Loading; -const failedRenderedValue = Parsing Failed; +const Pending = () => { + const { t } = useTranslation(); + return {t('common.loading')}; +}; + +const Failed = () => { + const { t } = useTranslation(); + return {t('metadata.parsingFailed')}; +}; export const useMetadataItem = (metadata: unknown, handlers: MetadataHandlers) => { const [value, setValue] = useState( MetadataParsePendingToken ); - const [renderedValue, setRenderedValue] = useState(pendingRenderedValue); + const [renderedValue, setRenderedValue] = useState(Pending); useEffect(() => { const _parse = async () => { @@ -31,11 +39,11 @@ export const useMetadataItem = (metadata: unknown, handlers: MetadataHandler useEffect(() => { const _renderValue = async () => { if (value === MetadataParsePendingToken) { - setRenderedValue(pendingRenderedValue); + setRenderedValue(Pending); return; } if (value === MetadataParseFailedToken) { - setRenderedValue(failedRenderedValue); + setRenderedValue(Failed); return; } diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx index dc42ae89a8..a995ddc511 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx @@ -15,7 +15,7 @@ const options: ComboboxOption[] = [ { value: 'controlnet', label: MODEL_TYPE_LABELS['controlnet'] as string }, { value: 'ip_adapter', label: MODEL_TYPE_LABELS['ip_adapter'] as string }, { value: 't2i_adapater', label: MODEL_TYPE_LABELS['t2i_adapter'] as string }, -] as const +] as const; const ModelTypeSelect = (props: UseControllerProps) => { const { field } = useController(props); diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useAnyOrDirectInputFieldNames.ts b/invokeai/frontend/web/src/features/nodes/hooks/useAnyOrDirectInputFieldNames.ts index 13c78bae84..4d0e54b239 100644 --- a/invokeai/frontend/web/src/features/nodes/hooks/useAnyOrDirectInputFieldNames.ts +++ b/invokeai/frontend/web/src/features/nodes/hooks/useAnyOrDirectInputFieldNames.ts @@ -1,4 +1,4 @@ -import { EMPTY_ARRAY } from "app/store/constants"; +import { EMPTY_ARRAY } from 'app/store/constants'; import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppSelector } from 'app/store/storeHooks'; import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useConnectionInputFieldNames.ts b/invokeai/frontend/web/src/features/nodes/hooks/useConnectionInputFieldNames.ts index 43b6ed6ef1..d332bf46e3 100644 --- a/invokeai/frontend/web/src/features/nodes/hooks/useConnectionInputFieldNames.ts +++ b/invokeai/frontend/web/src/features/nodes/hooks/useConnectionInputFieldNames.ts @@ -1,4 +1,4 @@ -import { EMPTY_ARRAY } from "app/store/constants"; +import { EMPTY_ARRAY } from 'app/store/constants'; import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppSelector } from 'app/store/storeHooks'; import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useOutputFieldNames.ts b/invokeai/frontend/web/src/features/nodes/hooks/useOutputFieldNames.ts index bbcd7f2068..e16b329c22 100644 --- a/invokeai/frontend/web/src/features/nodes/hooks/useOutputFieldNames.ts +++ b/invokeai/frontend/web/src/features/nodes/hooks/useOutputFieldNames.ts @@ -1,5 +1,5 @@ import { createSelector } from '@reduxjs/toolkit'; -import { EMPTY_ARRAY } from "app/store/constants"; +import { EMPTY_ARRAY } from 'app/store/constants'; import { useAppSelector } from 'app/store/storeHooks'; import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; import { selectNodeTemplate } from 'features/nodes/store/selectors'; diff --git a/invokeai/frontend/web/src/features/parameters/hooks/usePreselectedImage.ts b/invokeai/frontend/web/src/features/parameters/hooks/usePreselectedImage.ts index ab0fdca0af..30f954dedb 100644 --- a/invokeai/frontend/web/src/features/parameters/hooks/usePreselectedImage.ts +++ b/invokeai/frontend/web/src/features/parameters/hooks/usePreselectedImage.ts @@ -10,7 +10,6 @@ import { t } from 'i18next'; import { useCallback, useEffect } from 'react'; import { useGetImageDTOQuery, useGetImageMetadataQuery } from 'services/api/endpoints/images'; - export const usePreselectedImage = (selectedImage?: { imageName: string; action: 'sendToImg2Img' | 'sendToCanvas' | 'useAllParameters'; diff --git a/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx b/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx index 8922bb414c..26a55b7c70 100644 --- a/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx +++ b/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx @@ -10,7 +10,7 @@ import { TabPanels, Tabs, } from '@invoke-ai/ui-library'; -import { EMPTY_ARRAY } from "app/store/constants"; +import { EMPTY_ARRAY } from 'app/store/constants'; import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppSelector } from 'app/store/storeHooks'; import { LoRAList } from 'features/lora/components/LoRAList'; diff --git a/invokeai/frontend/web/src/services/api/endpoints/models.ts b/invokeai/frontend/web/src/services/api/endpoints/models.ts index c125dcd371..a236868b79 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/models.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/models.ts @@ -46,7 +46,7 @@ type InstallModelArg = { access_token?: paths['/api/v2/models/install']['post']['parameters']['query']['access_token']; // TODO(MM2): This is typed as `Optional[Dict[str, Any]]` in backend... config?: JSONObject; - // config: NonNullable['content']['application/json']; + // config: NonNullable['content']['application/json']; }; type InstallModelResponse = paths['/api/v2/models/install']['post']['responses']['201']['content']['application/json']; @@ -180,7 +180,7 @@ export const modelsApi = api.injectEndpoints({ installModel: build.mutation({ query: ({ source, config, access_token }) => { return { - url: buildModelsUrl('heuristic_install'), + url: buildModelsUrl('install'), params: { source, access_token }, method: 'POST', body: config,