mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-12 16:04:35 +08:00
Add a isIdentityRequired flag to plugin package.json’s, disable them when identity is not present
This commit is contained in:
parent
6a30d8aa31
commit
21fe6eeb7a
9 changed files with 49 additions and 8 deletions
|
@ -11,6 +11,7 @@
|
|||
},
|
||||
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
|
||||
"title":"Activity Notifications and Dashboard",
|
||||
"icon":"./assets/icon.png",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"description": "Track when links in an email have been clicked by recipients.",
|
||||
"icon": "./icon.png",
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
"supportedEnvs": ["development", "staging", "production"],
|
||||
|
||||
"repository": {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"description": "Track when email messages have been opened by recipients.",
|
||||
"icon": "./icon.png",
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
"supportedEnvs": ["development", "staging", "production"],
|
||||
|
||||
"repository": {
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"title": "Participant Profile",
|
||||
"description": "Information about a participant",
|
||||
|
||||
"isOptional": false,
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
|
||||
"main": "lib/main",
|
||||
"windowTypes": {
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
"version": "1.0.0",
|
||||
"title": "Send Reminders",
|
||||
"description": "Get reminded if you don't receive a reply for a message within a specified time in the future",
|
||||
"isHiddenOnPluginsPage": true,
|
||||
"icon": "./icon.png",
|
||||
"main": "lib/main",
|
||||
"supportedEnvs": ["development", "staging", "production"],
|
||||
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
@ -14,7 +16,6 @@
|
|||
"default": true,
|
||||
"composer": true
|
||||
},
|
||||
"isOptional": true,
|
||||
"engines": {
|
||||
"mailspring": "*"
|
||||
},
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
"production": "https://share.getmailspring.com"
|
||||
},
|
||||
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
"title": "Thread Sharing",
|
||||
"description": "Share a thread through the web.",
|
||||
"main": "./lib/main",
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
"title": "Thread Snooze",
|
||||
"description": "Snooze mail!",
|
||||
"main": "lib/main",
|
||||
"isOptional": true,
|
||||
"isIdentityRequired": true,
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
|
|
@ -11,10 +11,12 @@ export default class PackageManager {
|
|||
active: { [packageName: string]: Package } = {};
|
||||
resourcePath: string;
|
||||
configDirPath: string;
|
||||
identityPresent: boolean;
|
||||
|
||||
constructor({ configDirPath, devMode, safeMode, resourcePath, specMode }) {
|
||||
this.resourcePath = resourcePath;
|
||||
this.configDirPath = configDirPath;
|
||||
this.identityPresent = !!AppEnv.config.get('identity');
|
||||
|
||||
if (specMode) {
|
||||
this.packageDirectories.push(path.join(resourcePath, 'spec', 'fixtures', 'packages'));
|
||||
|
@ -29,6 +31,20 @@ export default class PackageManager {
|
|||
}
|
||||
|
||||
this.discoverPackages();
|
||||
|
||||
// If the user starts without a Mailspring ID and then links one, immediately turn on the
|
||||
// packages that require it. (Note: When you log OUT we currently just reboot the app, so
|
||||
// this only goes one way, which is also convenient because unloading the built-in packages
|
||||
// hasn't been tested much.)
|
||||
|
||||
// Note: Ideally we'd use the IdentityStore here but we can't load it this early in app
|
||||
// launch without introducing a circular import.
|
||||
AppEnv.config.onDidChange('identity', () => {
|
||||
if (!this.identityPresent && !!AppEnv.config.get('identity')) {
|
||||
this.identityPresent = true;
|
||||
this.activatePackages(AppEnv.getLoadSettings().windowType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
discoverPackages() {
|
||||
|
@ -58,7 +74,7 @@ export default class PackageManager {
|
|||
}
|
||||
}
|
||||
|
||||
activatePackages(windowType) {
|
||||
activatePackages(windowType: string) {
|
||||
for (const name of Object.keys(this.available)) {
|
||||
const pkg = this.available[name];
|
||||
|
||||
|
@ -79,7 +95,7 @@ export default class PackageManager {
|
|||
}, 2500);
|
||||
}
|
||||
|
||||
activatePackage(pkg) {
|
||||
activatePackage(pkg: Package) {
|
||||
if (this.active[pkg.name]) {
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +109,11 @@ export default class PackageManager {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!pkg.json.engines.mailspring) {
|
||||
if (pkg.isIdentityRequired() && !this.identityPresent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pkg.isEngineSet()) {
|
||||
// don't use AppEnv.reportError, I don't want to know about these.
|
||||
console.error(
|
||||
localized(
|
||||
|
@ -119,10 +139,14 @@ export default class PackageManager {
|
|||
return Object.values(this.active);
|
||||
}
|
||||
|
||||
getPackageNamed(packageName) {
|
||||
getPackageNamed(packageName: string) {
|
||||
return this.available[packageName];
|
||||
}
|
||||
|
||||
isPackageActive(packageName: string) {
|
||||
return packageName in this.active;
|
||||
}
|
||||
|
||||
// Installing and Creating Packages
|
||||
|
||||
installPackageManually() {
|
||||
|
@ -154,7 +178,7 @@ export default class PackageManager {
|
|||
);
|
||||
}
|
||||
|
||||
installPackageFromPath(packagePath, callback) {
|
||||
installPackageFromPath(packagePath: string, callback) {
|
||||
// check that the path contains a package.json file
|
||||
let json = null;
|
||||
try {
|
||||
|
|
|
@ -81,6 +81,14 @@ export default class Package {
|
|||
return !!this.json.isOptional;
|
||||
}
|
||||
|
||||
isEngineSet() {
|
||||
return !!this.json.engines.mailspring;
|
||||
}
|
||||
|
||||
isIdentityRequired() {
|
||||
return !!this.json.isIdentityRequired;
|
||||
}
|
||||
|
||||
isDefault() {
|
||||
return !!this.json.isDefault;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue