Hide the deprecation message

This commit is contained in:
Elio Struyf
2022-03-14 10:18:44 +01:00
parent 99ebbab100
commit 09c2c44c0a
3 changed files with 35 additions and 23 deletions
+6
View File
@@ -13,5 +13,11 @@ export const ExtensionState = {
Media: {
Sorting: `frontMatter:Dashboard:Media:Sorting`,
}
},
Updates: {
v7_0_0: {
dateFields: `frontMatter:Updates:v7.0.0:dateFields`
}
}
};
+23 -17
View File
@@ -1,6 +1,6 @@
import { basename } from "path";
import { extensions, Uri, ExtensionContext, window, workspace, commands, ExtensionMode, DiagnosticCollection, languages } from "vscode";
import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState } from "../constants";
import { EXTENSION_NAME, GITHUB_LINK, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, EXTENSION_BETA_ID, EXTENSION_ID, ExtensionState, CONFIG_KEY } from "../constants";
import { Notifications } from "./Notifications";
import { Settings } from "./SettingsHelper";
@@ -137,23 +137,29 @@ export class Extension {
Settings.createTeamSettings();
}
// Migration scripts can be written here
const publishField = Settings.inspect(SETTING_DATE_FIELD);
const modifiedField = Settings.inspect(SETTING_MODIFIED_FIELD);
const hideDateDeprecation = await Extension.getInstance().getState<boolean>(ExtensionState.Updates.v7_0_0.dateFields, "workspace");
if (!hideDateDeprecation) {
// Migration scripts can be written here
const publishField = Settings.inspect(SETTING_DATE_FIELD);
const modifiedField = Settings.inspect(SETTING_MODIFIED_FIELD);
// Check for deprecation
if (publishField?.workspaceValue ||
publishField?.globalValue ||
publishField?.teamValue ||
modifiedField?.workspaceValue ||
modifiedField?.globalValue ||
modifiedField?.teamValue) {
Notifications.warning(`The "${SETTING_DATE_FIELD}" and "${SETTING_MODIFIED_FIELD}" settings have been deprecated. Please use the "isPublishDate" and "isModifiedDate" datetime field properties instead.`, "See migration guide").then(value => {
if (value === "See migration guide") {
const isProd = this.isProductionMode;
commands.executeCommand("vscode.open", Uri.parse(`https://${isProd ? '' : 'beta.'}frontmatter.codes/docs/troubleshooting#publish-and-modified-date-migration`));
}
});
// Check for deprecation
if (publishField?.workspaceValue ||
publishField?.globalValue ||
publishField?.teamValue ||
modifiedField?.workspaceValue ||
modifiedField?.globalValue ||
modifiedField?.teamValue) {
Notifications.warning(`The "${CONFIG_KEY}.${SETTING_DATE_FIELD}" and "${CONFIG_KEY}.${SETTING_MODIFIED_FIELD}" settings have been deprecated. Please use the "isPublishDate" and "isModifiedDate" datetime field properties instead.`, "Hide", "See migration guide").then(async (value) => {
if (value === "See migration guide") {
const isProd = this.isProductionMode;
commands.executeCommand("vscode.open", Uri.parse(`https://${isProd ? '' : 'beta.'}frontmatter.codes/docs/troubleshooting#publish-and-modified-date-migration`));
await Extension.getInstance().setState<boolean>(ExtensionState.Updates.v7_0_0.dateFields, true, "workspace");
} else if (value === "Hide") {
await Extension.getInstance().setState<boolean>(ExtensionState.Updates.v7_0_0.dateFields, true, "workspace");
}
});
}
}
if (major < 7) {
+6 -6
View File
@@ -6,31 +6,31 @@ import { Settings } from "./SettingsHelper";
export class Notifications {
public static info(message: string, items?: any): Thenable<string | undefined> {
public static info(message: string, ...items: any): Thenable<string | undefined> {
Logger.info(`${EXTENSION_NAME}: ${message}`, "INFO");
if (this.shouldShow("INFO")) {
return window.showInformationMessage(`${EXTENSION_NAME}: ${message}`, items);
return window.showInformationMessage(`${EXTENSION_NAME}: ${message}`, ...items);
}
return Promise.resolve(undefined);
}
public static warning(message: string, items?: any): Thenable<string | undefined> {
public static warning(message: string, ...items: any): Thenable<string | undefined> {
Logger.info(`${EXTENSION_NAME}: ${message}`, "WARNING");
if (this.shouldShow("WARNING")) {
return window.showWarningMessage(`${EXTENSION_NAME}: ${message}`, items);
return window.showWarningMessage(`${EXTENSION_NAME}: ${message}`, ...items);
}
return Promise.resolve(undefined);
}
public static error(message: string, items?: any): Thenable<string | undefined> {
public static error(message: string, ...items: any): Thenable<string | undefined> {
Logger.info(`${EXTENSION_NAME}: ${message}`, "ERROR");
if (this.shouldShow("ERROR")) {
return window.showErrorMessage(`${EXTENSION_NAME}: ${message}`, items);
return window.showErrorMessage(`${EXTENSION_NAME}: ${message}`, ...items);
}
return Promise.resolve(undefined);