Skip to content

Commit

Permalink
Filter out empty folder settings + added the content type name
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Oct 30, 2023
1 parent fe9fbe8 commit 79ee660
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### ⚡️ Optimizations

- Dashboard layout grid optimizations
- Added the content-type name to the metadata section in the panel

### 🐞 Fixes

Expand Down
5 changes: 4 additions & 1 deletion src/commands/Folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ export class Folders {
*/
public static get(): ContentFolder[] {
const wsFolder = Folders.getWorkspaceFolder();
const folders: ContentFolder[] = Settings.get(SETTING_CONTENT_PAGE_FOLDERS) as ContentFolder[];
let folders: ContentFolder[] = Settings.get(SETTING_CONTENT_PAGE_FOLDERS) as ContentFolder[];

// Filter out folders without a path
folders = folders.filter((f) => f.path);

const contentFolders = folders.map((folder) => {
if (!folder.title) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useContentType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function useContentType(

// Get the content type by the folder name
const pageFolders = settings.contentFolders;
let pageFolderMatches = pageFolders.filter((folder) => metadata.filePath.includes(folder.path));
let pageFolderMatches = pageFolders.filter((folder) => metadata.filePath && folder.path && metadata.filePath.includes(folder.path));

// Sort by longest path
pageFolderMatches = pageFolderMatches.sort((a, b) => b.path.length - a.path.length);
Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const Metadata: React.FunctionComponent<IMetadataProps> = ({
};

return (
<Collapsible id={`tags`} title={l10n.t(LocalizationKey.panelMetadataTitle)} className={`inherit z-20`}>
<Collapsible id={`tags`} title={`${l10n.t(LocalizationKey.panelMetadataTitle)}${contentType?.name ? ` (${contentType?.name})` : ""}`} className={`inherit z-20`}>
<FeatureFlag features={features || []} flag={FEATURE_FLAG.panel.contentType}>
<ContentTypeValidator fields={contentType?.fields || []} metadata={metadata} />
</FeatureFlag>
Expand Down

0 comments on commit 79ee660

Please sign in to comment.