Setting updates

This commit is contained in:
Elio Struyf
2021-09-21 09:01:59 +02:00
parent cdf3dc7f2e
commit c27c5885b1
4 changed files with 87 additions and 57 deletions
-53
View File
@@ -23,58 +23,5 @@
"exportall.config.folderListener": [
"/src/pagesView/state/atom",
"/src/pagesView/state/selectors"
],
"frontMatter.content.pageFolders": [
{
"title": "documentation",
"path": "[[workspace]]/docs/content/docs"
}
],
"frontMatter.taxonomy.contentTypes": [
{
"name": "default",
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime"
},
{
"title": "Last modified date",
"name": "lastmod",
"type": "datetime"
},
{
"title": "Article preview",
"name": "preview",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "boolean"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
}
]
}
]
}
+56
View File
@@ -0,0 +1,56 @@
{
"$schema": "https://beta.frontmatter.codes/frontmatter.schema.json",
"frontMatter.content.pageFolders": [
{
"title": "documentation",
"path": "[[workspace]]/docs/content/docs"
}
],
"frontMatter.taxonomy.contentTypes": [
{
"name": "default",
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime"
},
{
"title": "Last modified date",
"name": "lastmod",
"type": "datetime"
},
{
"title": "Article preview",
"name": "preview",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "boolean"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
}
]
}
]
}
+3 -1
View File
@@ -82,7 +82,9 @@ export class Extension {
}
// Create team settings
Settings.createTeamSettings();
if (Settings.hasSettings()) {
Settings.createTeamSettings();
}
// Migration to version 4.0.0
const dateField = Settings.get<string>(SETTING_DATE_FIELD);
+28 -3
View File
@@ -172,11 +172,12 @@ export class Settings {
const settingNames = Object.keys(pkg.contributes.configuration.properties);
for (const name of settingNames) {
const setting = Settings.config.inspect(name.replace(`frontMatter.`, ''));
const settingName = name.replace(`${CONFIG_KEY}.`, '');
const setting = Settings.config.inspect(settingName);
if (setting && typeof setting.workspaceValue !== "undefined") {
await Settings.update(name, setting.workspaceValue, true);
await Settings.update(name.replace(`frontMatter.`, ''), undefined);
await Settings.update(settingName, setting.workspaceValue, true);
await Settings.update(settingName, undefined);
}
}
}
@@ -184,6 +185,30 @@ export class Settings {
Notifications.info(`All settings promoted to team level.`);
}
/**
* Check if there are any Front Matter settings in the workspace
* @returns
*/
public static hasSettings() {
let hasSetting = false;
const pkg = Extension.getInstance().packageJson;
if (pkg?.contributes?.configuration?.properties) {
const settingNames = Object.keys(pkg.contributes.configuration.properties);
for (const name of settingNames) {
const settingName = name.replace(`${CONFIG_KEY}.`, '');
const setting = Settings.config.inspect(settingName);
if (setting && typeof setting.workspaceValue !== "undefined") {
hasSetting = true;
}
}
}
return hasSetting;
}
/**
* Check if its the project config