#760 - Type filter fix

This commit is contained in:
Elio Struyf
2024-02-23 08:39:43 +01:00
parent fe5df3779b
commit a8777c4032
4 changed files with 19 additions and 8 deletions
+5 -5
View File
@@ -365,8 +365,10 @@ export class Folders {
} else if (i18n.locale !== folder.defaultLocale && i18n.path) {
localeFolders.push({
...folder,
title: `${folder.title} (${i18n.title})`,
title: folder.title,
originalPath: folder.path,
locale: i18n.locale,
localeTitle: i18n?.title || i18n.locale,
localeSourcePath: sourcePath,
path: join(folderPath, i18n.path)
});
@@ -374,13 +376,11 @@ export class Folders {
}
}
const defaultTitle = defaultLocale?.title
? `${folder.title} (${defaultLocale.title})`
: folder.title;
contentFolders.push({
...folder,
title: defaultTitle,
title: folder.title,
locale: folder.defaultLocale,
localeTitle: defaultLocale?.title || folder.defaultLocale,
originalPath: folder.path,
localeSourcePath: sourcePath,
path: join(folderPath, defaultLocale?.path || '')
@@ -4,7 +4,7 @@ import { FolderAtom, SettingsSelector } from '../../state';
import { MenuButton, MenuItem } from '../Menu';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../../localization';
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '../../../components/shadcn/Dropdown';
import { DropdownMenu, DropdownMenuContent } from '../../../components/shadcn/Dropdown';
export interface IFoldersFilterProps { }
@@ -14,7 +14,11 @@ export const FoldersFilter: React.FunctionComponent<
const DEFAULT_TYPE = l10n.t(LocalizationKey.dashboardHeaderFoldersDefault);
const [crntFolder, setCrntFolder] = useRecoilState(FolderAtom);
const settings = useRecoilValue(SettingsSelector);
const contentFolders = settings?.contentFolders || [];
const contentFolders = React.useMemo(() => {
return settings?.contentFolders
.filter((folder, index, self) => index === self.findIndex((t) => t.originalPath === folder.originalPath)) || [];
}, [settings?.contentFolders]);
if (contentFolders.length <= 1) {
return null;
+7 -1
View File
@@ -8,6 +8,7 @@ import { Logger } from './Logger';
import { SponsorAi } from '../services/SponsorAI';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../localization';
import { ContentFolder } from '../models';
export class Questions {
/**
@@ -130,7 +131,12 @@ export class Questions {
let selectedFolder: string | undefined;
if (folders.length > 1) {
selectedFolder = await window.showQuickPick(
folders.map((f) => f.title),
folders.map((f: ContentFolder) => {
if (f.locale) {
return `${f.title} (${f.localeTitle || f.locale})`;
}
return f.title;
}),
{
title: l10n.t(LocalizationKey.helpersQuestionsSelectContentFolderQuickPickTitle),
placeHolder: l10n.t(
+1
View File
@@ -14,6 +14,7 @@ export interface ContentFolder {
extended?: boolean;
locale?: string;
localeTitle?: string;
localeSourcePath?: string;
defaultLocale?: string;
locales: I18nConfig[];