Enhancement: Better content type creation for Astro #704

This commit is contained in:
Elio Struyf
2023-11-11 13:27:07 -08:00
parent 41d2f3f22b
commit 739dffe274
5 changed files with 35 additions and 2 deletions
+1
View File
@@ -669,6 +669,7 @@
"helpers.taxonomyHelper.move.progress.title": "{0}: Moving \"{1}\" from {2} to \"${3}\".",
"helpers.taxonomyHelper.move.success": "Move completed.",
"listeners.dashboard.dashboardListener.openConfig.notification": "Open the \"frontmatter.json\" file if you want to review the configuration.",
"listeners.dashboard.dashboardListener.pinItem.noPath.error": "No path provided.",
"listeners.dashboard.dashboardListener.pinItem.coundNotPin.error": "Could not pin item.",
"listeners.dashboard.dashboardListener.pinItem.coundNotUnPin.error": "Could not unpin item.",
+1
View File
@@ -4,6 +4,7 @@ export enum DashboardMessage {
setPageViewType = 'setPageViewType',
getMode = 'getMode',
showWarning = 'showWarning',
openConfig = 'openConfig',
// Project switching
switchProject = 'switchProject',
@@ -55,6 +55,10 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
});
}
const showNotification = () => {
Messenger.send(DashboardMessage.openConfig);
};
const reload = () => {
const crntState: any = Messenger.getState() || {};
@@ -260,7 +264,10 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
: Status.NotStarted,
onClick:
settings.initialized && settings.contentFolders && settings.contentFolders.length > 0
? reload
? () => {
showNotification();
reload();
}
: undefined
}
]
+21 -1
View File
@@ -2,12 +2,14 @@ import { Dashboard } from '../../commands/Dashboard';
import { ExtensionState } from '../../constants';
import { DashboardCommand } from '../../dashboardWebView/DashboardCommand';
import { DashboardMessage } from '../../dashboardWebView/DashboardMessage';
import { Extension, Notifications } from '../../helpers';
import { Extension, Notifications, Settings } from '../../helpers';
import { PostMessageData } from '../../models';
import { PinnedItems } from '../../services';
import { BaseListener } from './BaseListener';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../localization';
import { Uri, commands } from 'vscode';
import { existsAsync } from '../../utils';
export class DashboardListener extends BaseListener {
/**
@@ -29,6 +31,9 @@ export class DashboardListener extends BaseListener {
case DashboardMessage.setPageViewType:
Extension.getInstance().setState(ExtensionState.PagesView, msg.payload, 'workspace');
break;
case DashboardMessage.openConfig:
this.openConfig();
break;
case DashboardMessage.showWarning:
Notifications.warning(msg.payload);
break;
@@ -44,6 +49,21 @@ export class DashboardListener extends BaseListener {
}
}
private static async openConfig() {
const answer = await Notifications.info(
l10n.t(LocalizationKey.listenersDashboardDashboardListenerOpenConfigNotification),
l10n.t(LocalizationKey.commonOpenSettings)
);
if (answer && answer === l10n.t(LocalizationKey.commonOpenSettings)) {
const configPath = await Settings.projectConfigPath();
if (configPath && (await existsAsync(configPath))) {
commands.executeCommand('vscode.open', Uri.file(configPath));
}
}
}
/**
* Get the pinned items
* @param msg
+4
View File
@@ -2200,6 +2200,10 @@ export enum LocalizationKey {
* Move completed.
*/
helpersTaxonomyHelperMoveSuccess = 'helpers.taxonomyHelper.move.success',
/**
* Open the "frontmatter.json" file if you want to review the configuration.
*/
listenersDashboardDashboardListenerOpenConfigNotification = 'listeners.dashboard.dashboardListener.openConfig.notification',
/**
* No path provided.
*/