Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:estruyf/vscode-front-matter into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jan 29, 2024
2 parents aced5c5 + 93b096a commit 128644e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"dashboard.dataView.dataView.getStarted": "Select a data type to get started",
"dashboard.dataView.dataView.noDataFiles": "No data files found",
"dashboard.dataView.dataView.getStarted.link": "Read more to get started using data files",
"dashboard.dataView.dataView.update.message": "Updated your data entries",

"dashboard.dataView.emptyView.heading": "Select your date type first",

Expand Down
46 changes: 10 additions & 36 deletions src/dashboardWebView/components/DataView/DataView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ChevronRightIcon, CircleStackIcon } from '@heroicons/react/24/outline';
import { DataType } from '../../../models/DataType';
import { TelemetryEvent } from '../../../constants';
import { NavigationItem } from '../Layout';
import useThemeColors from '../../hooks/useThemeColors';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../../localization';

Expand All @@ -32,7 +31,6 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
const [selectedIndex, setSelectedIndex] = useState<number | null>(null);
const [dataEntries, setDataEntries] = useState<any | any[] | null>(null);
const settings = useRecoilValue(SettingsSelector);
const { getColors } = useThemeColors();

const setSchema = (dataFile: DataFile) => {
setSelectedData(dataFile);
Expand Down Expand Up @@ -109,7 +107,7 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
entries: data
});

Messenger.send(DashboardMessage.showNotification, 'Updated your data entries');
Messenger.send(DashboardMessage.showNotification, l10n.t(LocalizationKey.dashboardDataViewDataViewUpdateMessage));
},
[selectedData]
);
Expand Down Expand Up @@ -167,27 +165,15 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
<div className="relative w-full flex-grow mx-auto overflow-hidden">
<div className={`flex w-64 flex-col absolute inset-y-0`}>
<aside
className={`flex flex-col flex-grow overflow-y-auto border-r py-6 px-4 overflow-auto ${getColors(
'border-gray-200 dark:border-vulcan-300',
'border-[var(--frontmatter-border)]'
)
}`}
className={`flex flex-col flex-grow overflow-y-auto border-r py-6 px-4 overflow-auto border-[var(--frontmatter-border)]`}
>
<h2 className={`text-lg ${getColors(
`text-gray-500 dark:text-whisper-900`,
`text-[var(--frontmatter-text)]`
)
}`}>
<h2 className={`text-lg text-[var(--frontmatter-text)]`}>
{l10n.t(LocalizationKey.dashboardDataViewDataViewSelect)}
</h2>

<nav className={`flex-1 py-4 -mx-4`}>
<div
className={`divide-y border-t border-b ${getColors(
`divide-gray-200 dark:divide-vulcan-300 border-gray-200 dark:border-vulcan-300`,
`divide-[var(--frontmatter-border)] border-[var(--frontmatter-border)]`
)
}`}
className={`divide-y border-t border-b divide-[var(--frontmatter-border)] border-[var(--frontmatter-border)]`}
>
{dataFiles &&
dataFiles.length > 0 &&
Expand All @@ -211,17 +197,9 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
<>
{!selectedData.singleEntry && (
<div
className={`w-1/3 py-6 px-4 flex-1 border-r overflow-auto ${getColors(
`border-gray-200 dark:border-vulcan-300`,
`border-[var(--frontmatter-border)]`
)
}`}
className={`w-1/3 py-6 px-4 flex-1 border-r overflow-auto border-[var(--frontmatter-border)]`}
>
<h2 className={`text-lg ${getColors(
`text-gray-500 dark:text-whisper-900`,
`text-[var(--frontmatter-text)]`
)
}`}>
<h2 className={`text-lg text-[var(--frontmatter-text)]`}>
{l10n.t(LocalizationKey.dashboardDataViewDataViewTitle, selectedData?.title?.toLowerCase() || '')}
</h2>

Expand All @@ -247,7 +225,7 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
</>
) : (
<div className={`flex flex-col items-center justify-center`}>
<p className={getColors(`text-gray-500 dark:text-whisper-900`, `text-[var(--frontmatter-text)]`)}>
<p className={`text-[var(--frontmatter-text)]`}>
{l10n.t(LocalizationKey.dashboardDataViewDataViewEmpty, selectedData.title.toLowerCase())}
</p>
</div>
Expand All @@ -259,7 +237,7 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
className={`${selectedData.singleEntry ? 'w-full' : 'w-2/3'
} py-6 px-4 overflow-auto`}
>
<h2 className={`text-lg ${getColors(`text-gray-500 dark:text-whisper-900`, `text-[var(--frontmatter-text)]`)}`}>
<h2 className={`text-lg text-[var(--frontmatter-text)]`}>
{l10n.t(LocalizationKey.dashboardDataViewDataViewCreateOrModify, selectedData.title.toLowerCase())}
</h2>
{selectedData ? (
Expand All @@ -281,16 +259,12 @@ export const DataView: React.FunctionComponent<IDataViewProps> = (
</div>
) : (
<div className="w-full h-full flex items-center justify-center">
<div className={`flex flex-col items-center ${getColors(
'text-gray-500 dark:text-whisper-900',
'text-[var(--frontmatter-text)]'
)
}`}>
<div className={`flex flex-col items-center text-[var(--frontmatter-text)]`}>
<CircleStackIcon className="w-32 h-32" />
<p className="text-3xl mt-2">{l10n.t(LocalizationKey.dashboardDataViewDataViewNoDataFiles)}</p>
<p className="text-xl mt-4">
<a
className={getColors(`text-teal-700 hover:text-teal-900`, `text-[var(--frontmatter-link)] hover:text-[var(--frontmatter-link-hover)]`)}
className={`text-[var(--frontmatter-link)] hover:text-[var(--frontmatter-link-hover)]`}
href={`https://frontmatter.codes/docs/dashboard#data-files-view`}
title={l10n.t(LocalizationKey.dashboardDataViewDataViewGetStartedLink)}
>
Expand Down
21 changes: 20 additions & 1 deletion src/listeners/panel/DataListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import { ArticleHelper, ContentType, Extension, Logger, Settings } from '../../h
import {
COMMAND_NAME,
DefaultFields,
FEATURE_FLAG,
SETTING_COMMA_SEPARATED_FIELDS,
SETTING_DATE_FORMAT,
SETTING_GLOBAL_ACTIVE_MODE,
SETTING_GLOBAL_MODES,
SETTING_SEO_TITLE_FIELD,
SETTING_TAXONOMY_CONTENT_TYPES
} from '../../constants';
import { Article, Preview } from '../../commands';
import { ParsedFrontMatter } from '../../parsers';
import { processKnownPlaceholders } from '../../helpers/PlaceholderHelper';
import { Field, PostMessageData } from '../../models';
import { Field, Mode, PostMessageData } from '../../models';
import { encodeEmoji, fieldWhenClause } from '../../utils';
import { PanelProvider } from '../../panelWebView/PanelProvider';
import { MessageHandlerData } from '@estruyf/vscode';
Expand Down Expand Up @@ -144,6 +147,22 @@ export class DataListener extends BaseListener {
* Retrieve the information about the registered folders and its files
*/
public static async getFoldersAndFiles() {
const mode = Settings.get<string | null>(SETTING_GLOBAL_ACTIVE_MODE);
const modes = Settings.get<Mode[]>(SETTING_GLOBAL_MODES);

if (mode && modes && modes.length > 0) {
const crntMode = modes.find((m) => m.id === mode);
if (crntMode) {
const recentlyModified = crntMode.features.find(
(f) => f === FEATURE_FLAG.panel.recentlyModified
);
if (!recentlyModified) {
this.sendMsg(Command.folderInfo, null);
return;
}
}
}

const folders = (await Folders.getInfo(FILE_LIMIT)) || null;

this.sendMsg(Command.folderInfo, folders);
Expand Down
4 changes: 4 additions & 0 deletions src/localization/localization.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ export enum LocalizationKey {
* Read more to get started using data files
*/
dashboardDataViewDataViewGetStartedLink = 'dashboard.dataView.dataView.getStarted.link',
/**
* Updated your data entries
*/
dashboardDataViewDataViewUpdateMessage = 'dashboard.dataView.dataView.update.message',
/**
* Select your date type first
*/
Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/Git/GitAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const GitAction: React.FunctionComponent<IGitActionProps> = ({
onClick={pull}
title={
<div className="git_actions__sync">
<ArrowPathIcon className={isSyncing ? 'animate-spin' : ''} />
<ArrowPathIcon className={isSyncing ? 'animate-reverse-spin' : ''} />
<span>
{l10n.t(LocalizationKey.commonSync)}
</span>
Expand Down

0 comments on commit 128644e

Please sign in to comment.