Skip to content

Commit

Permalink
Enhancement: Better content type creation for Astro #704
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Nov 11, 2023
1 parent 41d2f3f commit 739dffe
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/dashboardWebView/DashboardMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum DashboardMessage {
setPageViewType = 'setPageViewType',
getMode = 'getMode',
showWarning = 'showWarning',
openConfig = 'openConfig',

// Project switching
switchProject = 'switchProject',
Expand Down
9 changes: 8 additions & 1 deletion src/dashboardWebView/components/Steps/StepsToGetStarted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const StepsToGetStarted: React.FunctionComponent<IStepsToGetStartedProps>
});
}

const showNotification = () => {
Messenger.send(DashboardMessage.openConfig);
};

const reload = () => {
const crntState: any = Messenger.getState() || {};

Expand Down Expand Up @@ -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
}
]
Expand Down
22 changes: 21 additions & 1 deletion src/listeners/dashboard/DashboardListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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;
Expand All @@ -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
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 @@ -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.
*/
Expand Down

0 comments on commit 739dffe

Please sign in to comment.