Skip to content

Commit

Permalink
Merge pull request #423 from estruyf/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf authored Sep 23, 2022
2 parents 1fe0319 + b7b7902 commit eb99843
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 79 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [8.1.1] - 2022-09-23

### 🐞 Fixes

- [#422](https://github.com/estruyf/vscode-front-matter/issues/422): Fix in panel initialization logic

## [8.1.0] - 2022-09-22 - [Release notes](https://beta.frontmatter.codes/updates/v8.1.0)

### ✨ New features
Expand Down
6 changes: 6 additions & 0 deletions README.beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ A couple of our extension highlights that hopefully get you interested in giving

> If you see something missing in your article creation flow, please feel free to reach out.
**Version 8**

The taxonomy dashboard got introduced on which you can manage your tags, categories, and custom taxonomy.

![Taxonomy dashboard](https://beta.frontmatter.codes/assets/marketplace/v8.1.0/taxonomy-dashboard.png)

**Version 7**

Snippets support for Front Matter has been added!
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ A couple of our extension highlights that hopefully get you interested in giving

> If you see something missing in your article creation flow, please feel free to reach out.
**Version 8**

The taxonomy dashboard got introduced on which you can manage your tags, categories, and custom taxonomy.

![Taxonomy dashboard](https://frontmatter.codes/assets/marketplace/v8.1.0/taxonomy-dashboard.png)

**Version 7**

Snippets support for Front Matter has been added!
Expand Down
3 changes: 2 additions & 1 deletion assets/media/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@

.collapsible__body,
.ext_settings,
.git_actions {
.git_actions,
.initialize_actions {
padding: 1rem 1.25rem;
box-sizing: border-box;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Front Matter",
"description": "Front Matter is a CMS that runs within Visual Studio Code. It gives you the power and control of a full-blown CMS while also providing you the flexibility and speed of the static site generator of your choice like: Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...",
"icon": "assets/frontmatter-teal-128x128.png",
"version": "8.1.0",
"version": "8.1.1",
"preview": false,
"publisher": "eliostruyf",
"galleryBanner": {
Expand Down
35 changes: 0 additions & 35 deletions src/commands/Template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { SETTING_CONTENT_DEFAULT_FILETYPE, SETTING_TEMPLATES_FOLDER, TelemetryEv
import { ArticleHelper, Settings } from '../helpers';
import { Article } from '.';
import { Notifications } from '../helpers/Notifications';
import { CONTEXT } from '../constants';
import { Project } from './Project';
import { Folders } from './Folders';
import { ContentType } from '../helpers/ContentType';
import { ContentType as IContentType } from '../models';
import { PagesListener } from '../listeners/dashboard';
Expand All @@ -17,39 +15,6 @@ import { Telemetry } from '../helpers/Telemetry';

export class Template {

/**
* Check if the template folder is available
*/
public static async init() {
const isInitialized = await Template.isInitialized();
await vscode.commands.executeCommand('setContext', CONTEXT.canInit, !isInitialized);

if (isInitialized) {
await vscode.commands.executeCommand('setContext', CONTEXT.initialized, true);
}
}

/**
* Check if the project is already initialized
*/
public static async isInitialized() {
const wsFolder = Folders.getWorkspaceFolder();
const folder = Template.getSettings();

if (!folder || !wsFolder) {
return false;
}

const templatePath = vscode.Uri.file(path.join(wsFolder.fsPath, folder));

try {
await vscode.workspace.fs.stat(templatePath);
return true;
} catch (e) {
return false;
}
}

/**
* Generate a template
*/
Expand Down
2 changes: 0 additions & 2 deletions src/constants/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export const CONTEXT = {
canInit: "frontMatter:CanInit",
initialized: "frontMatter:Initialized",
canOpenPreview: "frontMatter:CanOpenPreview",
canOpenDashboard: "frontMatter:CanOpenDashboard",
isEnabled: "frontMatter:enabled",
Expand Down
17 changes: 8 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ export async function activate(context: vscode.ExtensionContext) {
);

// Initialize command
Template.init();
const projectInit = vscode.commands.registerCommand(COMMAND_NAME.init, async (cb: Function) => {
await Project.init();
subscriptions.push(
vscode.commands.registerCommand(COMMAND_NAME.init, async (cb: Function) => {
await Project.init();

if (cb) {
cb();
}
});
if (cb) {
cb();
}
})
);

// Settings promotion command
subscriptions.push(vscode.commands.registerCommand(COMMAND_NAME.promote, SettingsHelper.promote));
Expand All @@ -201,7 +202,6 @@ export async function activate(context: vscode.ExtensionContext) {

// Things to do when configuration changes
SettingsHelper.onConfigChange((global?: any) => {
Template.init();
Preview.init();
GitListener.init();

Expand Down Expand Up @@ -285,7 +285,6 @@ export async function activate(context: vscode.ExtensionContext) {
createContent,
createByContentType,
createByTemplate,
projectInit,
collapseAll,
createFolder
);
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/PanelSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { workspace } from "vscode"
import { Extension, Settings } from "."
import { Dashboard } from "../commands/Dashboard"
import { Preview } from "../commands/Preview"
import { Template } from "../commands/Template"
import { Project } from "../commands/Project"
import { CONTEXT, DefaultFields, SETTING_CONTENT_DRAFT_FIELD, SETTING_CONTENT_FRONTMATTER_HIGHLIGHT, SETTING_DATA_TYPES, SETTING_FRAMEWORK_ID, SETTING_FRAMEWORK_START, SETTING_AUTO_UPDATE_DATE, SETTING_COMMA_SEPARATED_FIELDS, SETTING_CUSTOM_SCRIPTS, SETTING_DATE_FORMAT, SETTING_PANEL_FREEFORM, SETTING_SEO_CONTENT_MIN_LENGTH, SETTING_SEO_DESCRIPTION_FIELD, SETTING_SEO_DESCRIPTION_LENGTH, SETTING_SEO_SLUG_LENGTH, SETTING_SEO_TITLE_LENGTH, SETTING_SLUG_PREFIX, SETTING_SLUG_SUFFIX, SETTING_SLUG_UPDATE_FILE_NAME, SETTING_TAXONOMY_CATEGORIES, SETTING_TAXONOMY_CONTENT_TYPES, SETTING_TAXONOMY_CUSTOM, SETTING_TAXONOMY_FIELD_GROUPS, SETTING_TAXONOMY_TAGS, SETTING_GIT_ENABLED } from "../constants"
import { GitListener } from "../listeners/general"
import { CustomScript, DataType, DraftField, FieldGroup, PanelSettings as IPanelSettings, ScriptType } from "../models"
Expand Down Expand Up @@ -37,7 +37,7 @@ export class PanelSettings {
customTaxonomy: Settings.get(SETTING_TAXONOMY_CUSTOM, true) || [],
freeform: Settings.get(SETTING_PANEL_FREEFORM),
scripts: (Settings.get<CustomScript[]>(SETTING_CUSTOM_SCRIPTS) || []).filter(s => (s.type === ScriptType.Content || !s.type) && !s.hidden),
isInitialized: await Template.isInitialized(),
isInitialized: Project.isInitialized(),
modifiedDateUpdate: Settings.get(SETTING_AUTO_UPDATE_DATE) || false,
writingSettingsEnabled: this.isWritingSettingsEnabled() || false,
fmHighlighting: Settings.get(SETTING_CONTENT_FRONTMATTER_HIGHLIGHT),
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/Questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ export class Questions {
placeHolder: `Select where you want to create your content`,
ignoreFocusOut: true
});
} else {
} else if (folders.length === 1) {
selectedFolder = folders[0].title;
} else {
Notifications.warning(`No page folders were configures.`);
return;
}

if (!selectedFolder && showWarning) {
Expand Down
3 changes: 1 addition & 2 deletions src/listeners/panel/ExtensionListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export class ExtensionListener extends BaseListener {
* Initialize project
*/
private static async initialize() {
await commands.executeCommand(COMMAND_NAME.init);
SettingsListener.getSettings();
await commands.executeCommand(COMMAND_NAME.dashboard);
}

/**
Expand Down
59 changes: 35 additions & 24 deletions src/panelWebView/components/BaseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,43 @@ const BaseView: React.FunctionComponent<IBaseViewProps> = ({settings, folderAndF
return (
<div className="frontmatter">
<div className={`ext_actions`}>
<GitAction settings={settings} />

<FeatureFlag features={mode?.features || []} flag={FEATURE_FLAG.panel.globalSettings}>
<GlobalSettings settings={settings} isBase />
</FeatureFlag>
{
!settings?.isInitialized && (
<div className={`initialize_actions`}>
<button onClick={initProject}>Initialize project</button>
</div>
)
}

<FeatureFlag features={mode?.features || []} flag={FEATURE_FLAG.panel.actions}>
<Collapsible id={`base_actions`} title="Actions">
<div className={`base__actions`}>
<button onClick={openDashboard}>Open dashboard</button>
<button onClick={openPreview} disabled={!settings?.preview?.host}>Open preview</button>
<StartServerButton settings={settings} />
{
!settings?.isInitialized && <button onClick={initProject}>Initialize project</button>
}

<button onClick={createContent} disabled={!settings?.isInitialized}>Create new content</button>
{
settings?.isInitialized && (
<>
<GitAction settings={settings} />

{
customActions.map((script) => (
<button key={script.title} onClick={() => runBulkScript(script)}>{ script.title }</button>
))
}
</div>
</Collapsible>
</FeatureFlag>
<FeatureFlag features={mode?.features || []} flag={FEATURE_FLAG.panel.globalSettings}>
<GlobalSettings settings={settings} isBase />
</FeatureFlag>

<FeatureFlag features={mode?.features || []} flag={FEATURE_FLAG.panel.actions}>
<Collapsible id={`base_actions`} title="Actions">
<div className={`base__actions`}>
<button onClick={openDashboard}>Open dashboard</button>
<button onClick={openPreview} disabled={!settings?.preview?.host}>Open preview</button>
<StartServerButton settings={settings} />

<button onClick={createContent}>Create new content</button>

{
customActions.map((script) => (
<button key={script.title} onClick={() => runBulkScript(script)}>{ script.title }</button>
))
}
</div>
</Collapsible>
</FeatureFlag>
</>
)
}

<FeatureFlag features={mode?.features || []} flag={FEATURE_FLAG.panel.recentlyModified}>
<FolderAndFiles data={folderAndFiles} isBase />
Expand Down

0 comments on commit eb99843

Please sign in to comment.