Rename NylasEnv to AppEnv

This commit is contained in:
Ben Gotow 2017-09-26 11:36:58 -07:00
parent 79d848d727
commit 21a2427ddc
186 changed files with 789 additions and 789 deletions

View file

@ -10,8 +10,8 @@
},
"extends": ["react-app", "prettier", "prettier/react"],
"globals": {
"NylasEnv": false,
"$n": false,
"AppEnv": false,
"$m": false,
"waitsForPromise": false,
"advanceClock": false,
"TEST_ACCOUNT_ID": false,

View file

@ -30,7 +30,7 @@
* [Config](/classes/Config.md)
* [Contenteditable](/classes/Contenteditable.md)
* [KeyCommandsRegion](/classes/KeyCommandsRegion.md)
* [NylasEnvConstructor](/classes/NylasEnvConstructor.md)
* [AppEnvConstructor](/classes/AppEnvConstructor.md)
* [QueryResultSet](/classes/QueryResultSet.md)
* [QuerySubscriptionPool](/classes/QuerySubscriptionPool.md)
* [StyleManager](/classes/StyleManager.md)
@ -94,7 +94,7 @@
* [DraftEditingSession](/classes/DraftEditingSession.md)
* [DraftStore](/classes/DraftStore.md)
* NylasEnv
* AppEnv
* [PackageManager](/classes/PackageManager.md)
* Atom

View file

@ -34,8 +34,8 @@
* [{{this}}](/classes/{{this}}.md)
{{/each}}
## NylasEnv
{{#each sidebar.[NylasEnv]}}
## AppEnv
{{#each sidebar.[AppEnv]}}
* [{{this}}](/classes/{{this}}.md)
{{/each}}

View file

@ -6,7 +6,7 @@ class AccountCommands
@_focusAccounts: (accounts) ->
Actions.focusDefaultMailboxPerspectiveForAccounts(accounts)
NylasEnv.show() unless NylasEnv.isVisible()
AppEnv.show() unless AppEnv.isVisible()
@_isSelected: (account, sidebarAccountIds) =>
if sidebarAccountIds.length > 1
@ -29,10 +29,10 @@ class AccountCommands
key = "window:select-account-#{index}"
commands[key] = @_focusAccounts.bind(@, [account])
@_commandsDisposable = NylasEnv.commands.add(document.body, commands)
@_commandsDisposable = AppEnv.commands.add(document.body, commands)
@registerMenuItems: (accounts, sidebarAccountIds) ->
windowMenu = _.find NylasEnv.menu.template, ({label}) ->
windowMenu = _.find AppEnv.menu.template, ({label}) ->
MenuHelpers.normalizeLabel(label) is 'Window'
return unless windowMenu
@ -45,7 +45,7 @@ class AccountCommands
template = @menuTemplate(accounts, sidebarAccountIds)
submenu.splice(idx + 1, 0, template...)
windowMenu.submenu = submenu
NylasEnv.menu.update()
AppEnv.menu.update()
@menuItem: (account, idx, {isSelected, clickHandlers} = {}) =>
item = {

View file

@ -17,7 +17,7 @@ idForCategories = (categories) ->
_.pluck(categories, 'id').join('-')
countForItem = (perspective) ->
unreadCountEnabled = NylasEnv.config.get('core.workspace.showUnreadForAllCategories')
unreadCountEnabled = AppEnv.config.get('core.workspace.showUnreadForAllCategories')
if perspective.isInbox() or unreadCountEnabled
return perspective.unreadCount()
return 0
@ -27,8 +27,8 @@ isItemSelected = (perspective) ->
FocusedPerspectiveStore.current().isEqual(perspective))
isItemCollapsed = (id) ->
if NylasEnv.savedState.sidebarKeysCollapsed[id] isnt undefined
NylasEnv.savedState.sidebarKeysCollapsed[id]
if AppEnv.savedState.sidebarKeysCollapsed[id] isnt undefined
AppEnv.savedState.sidebarKeysCollapsed[id]
else
true

View file

@ -10,8 +10,8 @@ SidebarItem = require './sidebar-item'
SidebarActions = require './sidebar-actions'
isSectionCollapsed = (title) ->
if NylasEnv.savedState.sidebarKeysCollapsed[title] isnt undefined
NylasEnv.savedState.sidebarKeysCollapsed[title]
if AppEnv.savedState.sidebarKeysCollapsed[title] isnt undefined
AppEnv.savedState.sidebarKeysCollapsed[title]
else
false

View file

@ -20,7 +20,7 @@ Sections = {
class SidebarStore extends NylasStore
constructor: ->
NylasEnv.savedState.sidebarKeysCollapsed ?= {}
AppEnv.savedState.sidebarKeysCollapsed ?= {}
@_sections = {}
@_sections[Sections.Standard] = {}
@ -52,7 +52,7 @@ class SidebarStore extends NylasStore
@listenTo ThreadCountsStore, @_updateSections
@listenTo CategoryStore, @_updateSections
@configSubscription = NylasEnv.config.onDidChange(
@configSubscription = AppEnv.config.onDidChange(
'core.workspace.showUnreadForAllCategories',
@_updateSections
)
@ -60,9 +60,9 @@ class SidebarStore extends NylasStore
return
_onSetCollapsedByKey: (itemKey, collapsed) =>
currentValue = NylasEnv.savedState.sidebarKeysCollapsed[itemKey]
currentValue = AppEnv.savedState.sidebarKeysCollapsed[itemKey]
if currentValue isnt collapsed
NylasEnv.savedState.sidebarKeysCollapsed[itemKey] = collapsed
AppEnv.savedState.sidebarKeysCollapsed[itemKey] = collapsed
@_updateSections()
_onSetCollapsedByName: (itemName, collapsed) =>

View file

@ -5,7 +5,7 @@ describe('sidebar-item', function sidebarItemSpec() {
it('preserves nested labels on rename', () => {
spyOn(Actions, 'queueTask');
const categories = [new Folder({ path: 'a.b/c', accountId: window.TEST_ACCOUNT_ID })];
NylasEnv.savedState.sidebarKeysCollapsed = {};
AppEnv.savedState.sidebarKeysCollapsed = {};
const item = SidebarItem.forCategories(categories);
item.onEdited(item, 'd');
@ -17,7 +17,7 @@ describe('sidebar-item', function sidebarItemSpec() {
it('preserves labels on rename', () => {
spyOn(Actions, 'queueTask');
const categories = [new Folder({ path: 'a', accountId: window.TEST_ACCOUNT_ID })];
NylasEnv.savedState.sidebarKeysCollapsed = {};
AppEnv.savedState.sidebarKeysCollapsed = {};
const item = SidebarItem.forCategories(categories);
item.onEdited(item, 'b');

View file

@ -16,7 +16,7 @@ class ActivityListStore extends NylasStore {
this.listenTo(FocusedPerspectiveStore, this._updateActivity);
const start = () => this._getActivity();
if (NylasEnv.inSpecMode()) {
if (AppEnv.inSpecMode()) {
start();
} else {
setTimeout(start, 2000);
@ -41,19 +41,19 @@ class ActivityListStore extends NylasStore {
}
hasBeenViewed(action) {
if (!NylasEnv.savedState.activityListViewed) return false;
return action.timestamp < NylasEnv.savedState.activityListViewed;
if (!AppEnv.savedState.activityListViewed) return false;
return action.timestamp < AppEnv.savedState.activityListViewed;
}
focusThread(threadId) {
NylasEnv.displayWindow();
AppEnv.displayWindow();
Actions.closePopover();
DatabaseStore.find(Thread, threadId).then(thread => {
if (!thread) {
NylasEnv.reportError(
AppEnv.reportError(
new Error(`ActivityListStore::focusThread: Can't find thread`, { threadId })
);
NylasEnv.showErrorDialog(`Can't find the selected thread in your mailbox`);
AppEnv.showErrorDialog(`Can't find the selected thread in your mailbox`);
return;
}
Actions.ensureCategoryIsFocused('sent', thread.accountId);
@ -79,7 +79,7 @@ class ActivityListStore extends NylasStore {
}
_onResetSeen() {
NylasEnv.savedState.activityListViewed = Date.now() / 1000;
AppEnv.savedState.activityListViewed = Date.now() / 1000;
this._unreadCount = 0;
this.trigger();
}
@ -88,8 +88,8 @@ class ActivityListStore extends NylasStore {
const dataSource = this._dataSource();
this._subscription = dataSource
.buildObservable({
openTrackingId: NylasEnv.packages.pluginIdFor('open-tracking'),
linkTrackingId: NylasEnv.packages.pluginIdFor('link-tracking'),
openTrackingId: AppEnv.packages.pluginIdFor('open-tracking'),
linkTrackingId: AppEnv.packages.pluginIdFor('link-tracking'),
messageLimit: 500,
})
.subscribe(messages => {
@ -110,8 +110,8 @@ class ActivityListStore extends NylasStore {
const sidebarAccountIds = FocusedPerspectiveStore.sidebarAccountIds();
for (const message of messages) {
if (sidebarAccountIds.length > 1 || message.accountId === sidebarAccountIds[0]) {
const openTrackingId = NylasEnv.packages.pluginIdFor('open-tracking');
const linkTrackingId = NylasEnv.packages.pluginIdFor('link-tracking');
const openTrackingId = AppEnv.packages.pluginIdFor('open-tracking');
const linkTrackingId = AppEnv.packages.pluginIdFor('link-tracking');
if (
message.metadataForPluginId(openTrackingId) ||
message.metadataForPluginId(linkTrackingId)
@ -142,7 +142,7 @@ class ActivityListStore extends NylasStore {
}
_openActionsForMessage(message) {
const openTrackingId = NylasEnv.packages.pluginIdFor('open-tracking');
const openTrackingId = AppEnv.packages.pluginIdFor('open-tracking');
const openMetadata = message.metadataForPluginId(openTrackingId);
const recipients = message.to.concat(message.cc, message.bcc);
const actions = [];
@ -183,7 +183,7 @@ class ActivityListStore extends NylasStore {
}
_linkActionsForMessage(message) {
const linkTrackingId = NylasEnv.packages.pluginIdFor('link-tracking');
const linkTrackingId = AppEnv.packages.pluginIdFor('link-tracking');
const linkMetadata = message.metadataForPluginId(linkTrackingId);
const recipients = message.to.concat(message.cc, message.bcc);
const actions = [];

View file

@ -1,6 +1,6 @@
export function pluginFor(id) {
const openTrackingId = NylasEnv.packages.pluginIdFor('open-tracking');
const linkTrackingId = NylasEnv.packages.pluginIdFor('link-tracking');
const openTrackingId = AppEnv.packages.pluginIdFor('open-tracking');
const linkTrackingId = AppEnv.packages.pluginIdFor('link-tracking');
if (id === openTrackingId) {
return {
name: 'open',

View file

@ -129,7 +129,7 @@ messages[2].directlyAttachMetadata(LINK_TRACKING_ID, pluginValue);
describe('ActivityList', function activityList() {
beforeEach(() => {
this.testSource = new TestDataSource();
spyOn(NylasEnv.packages, 'pluginIdFor').andCallFake(pluginName => {
spyOn(AppEnv.packages, 'pluginIdFor').andCallFake(pluginName => {
if (pluginName === 'open-tracking') {
return OPEN_TRACKING_ID;
}
@ -151,7 +151,7 @@ describe('ActivityList', function activityList() {
return null;
});
spyOn(ActivityListStore, 'focusThread').andCallThrough();
spyOn(NylasEnv, 'displayWindow');
spyOn(AppEnv, 'displayWindow');
spyOn(Actions, 'closePopover');
spyOn(Actions, 'setFocus');
spyOn(Actions, 'ensureCategoryIsFocused');
@ -234,7 +234,7 @@ describe('ActivityList', function activityList() {
return ActivityListStore.focusThread.calls.length > 0;
});
runs(() => {
expect(NylasEnv.displayWindow.calls.length).toBe(1);
expect(AppEnv.displayWindow.calls.length).toBe(1);
expect(Actions.closePopover.calls.length).toBe(1);
expect(Actions.setFocus.calls.length).toBe(1);
expect(Actions.ensureCategoryIsFocused.calls.length).toBe(1);

View file

@ -65,13 +65,13 @@ class AnalyticsStore extends NylasStore {
// Properties applied to all events and all people during an identify.
superTraits() {
const theme = NylasEnv.themes ? NylasEnv.themes.getActiveTheme() : null;
const theme = AppEnv.themes ? AppEnv.themes.getActiveTheme() : null;
return {
version: NylasEnv.getVersion().split('-')[0],
version: AppEnv.getVersion().split('-')[0],
platform: process.platform,
activeTheme: theme ? theme.name : null,
workspaceMode: NylasEnv.config.get('core.workspace.mode'),
workspaceMode: AppEnv.config.get('core.workspace.mode'),
};
}
@ -98,7 +98,7 @@ class AnalyticsStore extends NylasStore {
}
track(eventName, eventArgs = {}) {
// if (NylasEnv.inDevMode()) { return }
// if (AppEnv.inDevMode()) { return }
const identity = IdentityStore.identity();
if (!(identity && identity.id)) {
@ -113,17 +113,17 @@ class AnalyticsStore extends NylasStore {
}
firstDaySeen() {
let firstDaySeen = NylasEnv.config.get('firstDaySeen');
let firstDaySeen = AppEnv.config.get('firstDaySeen');
if (!firstDaySeen) {
const [y, m, d] = new Date().toISOString().split(/[-|T]/);
firstDaySeen = `${m}/${d}/${y}`;
NylasEnv.config.set('firstDaySeen', firstDaySeen);
AppEnv.config.set('firstDaySeen', firstDaySeen);
}
return firstDaySeen;
}
identify = () => {
if (!NylasEnv.isMainWindow()) {
if (!AppEnv.isMainWindow()) {
return;
}

View file

@ -49,7 +49,7 @@ class MessageAttachments extends Component {
const displayName = file.displayName();
const displaySize = file.displayFileSize();
const contentType = file.contentType;
const displayFilePreview = NylasEnv.config.get('core.attachments.displayFilePreview');
const displayFilePreview = AppEnv.config.get('core.attachments.displayFilePreview');
const filePreviewPath = displayFilePreview ? filePreviewPaths[file.id] : null;
return (

View file

@ -106,7 +106,7 @@ export default class LabelPickerPopover extends Component {
TaskQueue.waitForPerformRemote(syncbackTask).then(finishedTask => {
if (!finishedTask.created) {
NylasEnv.showErrorDialog({ title: 'Error', message: `Could not create label.` });
AppEnv.showErrorDialog({ title: 'Error', message: `Could not create label.` });
return;
}
Actions.queueTask(

View file

@ -136,7 +136,7 @@ export default class MovePickerPopover extends Component {
TaskQueue.waitForPerformRemote(syncbackTask).then(finishedTask => {
if (!finishedTask.created) {
NylasEnv.showErrorDialog({ title: 'Error', message: `Could not create folder.` });
AppEnv.showErrorDialog({ title: 'Error', message: `Could not create folder.` });
return;
}
this._onMoveToCategory({ category: finishedTask.created });

View file

@ -15,7 +15,7 @@ describe('SignatureComposerExtension', function signatureComposerExtension() {
describe('prepareNewDraft', () => {
describe('when a signature is defined', () => {
beforeEach(() => {
spyOn(NylasEnv.config, 'get').andCallFake(
spyOn(AppEnv.config, 'get').andCallFake(
key => (key === 'nylas.signatures' ? TEST_SIGNATURES : null)
);
spyOn(SignatureStore, 'signatureForEmail').andReturn(TEST_SIGNATURE);

View file

@ -22,12 +22,12 @@ const DEFAULTS = {
describe('SignatureStore', function signatureStore() {
beforeEach(() => {
spyOn(NylasEnv.config, 'get').andCallFake(
spyOn(AppEnv.config, 'get').andCallFake(
key => (key === 'nylas.signatures' ? SIGNATURES : null)
);
spyOn(SignatureStore, '_saveSignatures').andCallFake(() => {
NylasEnv.config.set(`nylas.signatures`, SignatureStore.signatures);
AppEnv.config.set(`nylas.signatures`, SignatureStore.signatures);
});
spyOn(SignatureStore, 'signatureForEmail').andCallFake(email => SIGNATURES[DEFAULTS[email]]);
spyOn(SignatureStore, 'selectedSignature').andCallFake(() => SIGNATURES['1']);
@ -45,7 +45,7 @@ describe('SignatureStore', function signatureStore() {
describe('removeSignature', () => {
beforeEach(() => {
spyOn(NylasEnv.config, 'set').andCallFake((key, newObject) => {
spyOn(AppEnv.config, 'set').andCallFake((key, newObject) => {
if (key === 'nylas.signatures') {
SIGNATURES = newObject;
}

View file

@ -2,13 +2,13 @@ import { ExtensionRegistry } from 'nylas-exports';
import SpellcheckComposerExtension from './spellcheck-composer-extension';
export function activate() {
if (NylasEnv.config.get('core.composing.spellcheck')) {
if (AppEnv.config.get('core.composing.spellcheck')) {
ExtensionRegistry.Composer.register(SpellcheckComposerExtension);
}
}
export function deactivate() {
if (NylasEnv.config.get('core.composing.spellcheck')) {
if (AppEnv.config.get('core.composing.spellcheck')) {
ExtensionRegistry.Composer.unregister(SpellcheckComposerExtension);
}
}

View file

@ -381,7 +381,7 @@ class PreferencesTemplates extends React.Component {
</p>
<p>
Reply templates are saved as HTML files in the{' '}
<strong>{`${NylasEnv.getConfigDirPath()}/templates`}</strong> directory on your
<strong>{`${AppEnv.getConfigDirPath()}/templates`}</strong> directory on your
computer. In raw HTML, variables are defined as HTML &lt;code&gt; tags with class
&quot;var empty&quot;.
</p>

View file

@ -15,7 +15,7 @@ class TemplateStore extends NylasStore {
this._init();
}
_init(templatesDir = path.join(NylasEnv.getConfigDirPath(), 'templates')) {
_init(templatesDir = path.join(AppEnv.getConfigDirPath(), 'templates')) {
this.items = this.items.bind(this);
this.templatesDirectory = this.templatesDirectory.bind(this);
this._setStoreDefaults = this._setStoreDefaults.bind(this);
@ -90,7 +90,7 @@ class TemplateStore extends NylasStore {
_populate() {
fs.readdir(this._templatesDir, (err, filenames) => {
if (err) {
NylasEnv.showErrorDialog({
AppEnv.showErrorDialog({
title: 'Cannot scan templates directory',
message: `N1 was unable to read the contents of your templates directory (${this
._templatesDir}). You may want to delete this folder or ensure filesystem permissions are set correctly.`,

View file

@ -59,7 +59,7 @@ export default class ComposerHeaderActions extends React.Component {
);
}
if (!NylasEnv.isComposerWindow()) {
if (!AppEnv.isComposerWindow()) {
items.push(
<span
className="action show-popout"

View file

@ -157,7 +157,7 @@ export default class ComposerView extends React.Component {
this._els.scrollregion = el;
};
_renderContentScrollRegion() {
if (NylasEnv.isComposerWindow()) {
if (AppEnv.isComposerWindow()) {
return (
<ScrollRegion
className="compose-body-scroll"

View file

@ -111,7 +111,7 @@ export default class InlineImageUploadContainer extends Component {
fs.writeFile(nextFilePath, buffer, err => {
if (err) {
NylasEnv.showErrorDialog(err.toString());
AppEnv.showErrorDialog(err.toString());
return;
}
const img = el.querySelector('.file-preview img');

View file

@ -26,7 +26,7 @@ class ComposerWithWindowProps extends React.Component {
super(props);
// We'll now always have windowProps by the time we construct this.
const windowProps = NylasEnv.getWindowProps();
const windowProps = AppEnv.getWindowProps();
const { draftJSON, headerMessageId } = windowProps;
if (!draftJSON) {
throw new Error('Initialize popout composer windows with valid draftJSON');
@ -48,7 +48,7 @@ class ComposerWithWindowProps extends React.Component {
_onDraftReady = () => {
this._composerComponent.focus().then(() => {
NylasEnv.displayWindow();
AppEnv.displayWindow();
if (this.state.errorMessage) {
this._showInitialErrorDialog(this.state.errorMessage, this.state.errorDetail);
@ -74,25 +74,25 @@ class ComposerWithWindowProps extends React.Component {
// don't delay the modal may come up in a state where the draft looks
// like it hasn't been restored or has been lost.
_.delay(() => {
NylasEnv.showErrorDialog({ title: 'Error', message: msg }, { detail: detail });
AppEnv.showErrorDialog({ title: 'Error', message: msg }, { detail: detail });
}, 100);
}
}
export function activate() {
if (NylasEnv.isMainWindow()) {
if (AppEnv.isMainWindow()) {
ComponentRegistry.register(ComposerViewForDraftClientId, {
role: 'Composer',
});
ComponentRegistry.register(ComposeButton, {
location: WorkspaceStore.Location.RootSidebar.Toolbar,
});
} else if (NylasEnv.isThreadWindow()) {
} else if (AppEnv.isThreadWindow()) {
ComponentRegistry.register(ComposerViewForDraftClientId, {
role: 'Composer',
});
} else {
NylasEnv.getCurrentWindow().setMinimumSize(480, 250);
AppEnv.getCurrentWindow().setMinimumSize(480, 250);
ComponentRegistry.register(ComposerWithWindowProps, {
location: WorkspaceStore.Location.Center,
});
@ -107,7 +107,7 @@ export function activate() {
}
export function deactivate() {
if (NylasEnv.isMainWindow()) {
if (AppEnv.isMainWindow()) {
ComponentRegistry.unregister(ComposerViewForDraftClientId);
ComponentRegistry.unregister(ComposeButton);
} else {

View file

@ -52,7 +52,7 @@ describe "ComposerHeaderActions", ->
expect(els.length).toBe 1
it "doesn't render 'popout composer' if in a composer window", ->
spyOn(NylasEnv, 'isComposerWindow').andReturn(true)
spyOn(AppEnv, 'isComposerWindow').andReturn(true)
makeField.call(@, {enabledFields: [Fields.To], participantsFocused: true})
els = ReactTestUtils.scryRenderedDOMComponentsWithClass(@component, "show-popout")
expect(els.length).toBe 0

View file

@ -174,7 +174,7 @@ describe "ComposerView", ->
describe "When sending a message", ->
beforeEach ->
spyOn(NylasEnv, "isMainWindow").andReturn true
spyOn(AppEnv, "isMainWindow").andReturn true
{remote} = require('electron')
@dialog = remote.dialog
spyOn(remote, "getCurrentWindow")

View file

@ -7,8 +7,8 @@ import { DraftDeleteButton } from './draft-toolbar-buttons';
export function activate() {
WorkspaceStore.defineSheet('Drafts', { root: true }, { list: ['RootSidebar', 'DraftList'] });
if (
NylasEnv.savedState.perspective &&
NylasEnv.savedState.perspective.type === 'DraftsMailboxPerspective'
AppEnv.savedState.perspective &&
AppEnv.savedState.perspective.type === 'DraftsMailboxPerspective'
) {
Actions.selectRootSheet(WorkspaceStore.Sheet.Drafts);
}

View file

@ -2,4 +2,4 @@ import plugin from '../package.json';
export const PLUGIN_NAME = plugin.title;
export const PLUGIN_ID = plugin.name;
export const PLUGIN_URL = plugin.serverUrl[NylasEnv.config.get('env')];
export const PLUGIN_URL = plugin.serverUrl[AppEnv.config.get('env')];

View file

@ -7,7 +7,7 @@
//
// function resolveHelperPath(callback) {
// const resourcesPath = NylasEnv.getLoadSettings().resourcePath;
// const resourcesPath = AppEnv.getLoadSettings().resourcePath;
// let pathToCalendarApp = path.join(resourcesPath, '..', 'Nylas Calendar.app');
//
// fs.exists(pathToCalendarApp, (exists) => {
@ -41,15 +41,15 @@ export function activate() {
// exec(`open "${helperPath}"`);
// });
//
// if (!NylasEnv.config.get('addedToDockCalendar')) {
// if (!AppEnv.config.get('addedToDockCalendar')) {
// exec(`defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>${helperPath}/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"`, () => {
// NylasEnv.config.set('addedToDockCalendar', true);
// AppEnv.config.set('addedToDockCalendar', true);
// exec(`killall Dock`);
// });
// }
// });
//
// NylasEnv.onBeforeUnload(() => {
// AppEnv.onBeforeUnload(() => {
// exec('killall "Nylas Calendar"');
// return true;
// });

View file

@ -32,7 +32,7 @@ export default class QuickEventPopover extends React.Component {
}
const cals = allCalendars.filter(c => !c.readOnly);
if (cals.length === 0) {
NylasEnv.showErrorDialog(
AppEnv.showErrorDialog(
"This account has no editable calendars. We can't " +
'create an event for you. Please make sure you have an editable calendar ' +
'with your account provider.'

View file

@ -16,20 +16,20 @@ class AutoloadImagesStore extends NylasStore {
this._whitelistMessageIds = {};
const filename = 'autoload-images-whitelist.txt';
this._whitelistEmailsPath = path.join(NylasEnv.getConfigDirPath(), filename);
this._whitelistEmailsPath = path.join(AppEnv.getConfigDirPath(), filename);
this._loadWhitelist();
this.listenTo(AutoloadImagesActions.temporarilyEnableImages, this._onTemporarilyEnableImages);
this.listenTo(AutoloadImagesActions.permanentlyEnableImages, this._onPermanentlyEnableImages);
NylasEnv.config.onDidChange('core.reading.autoloadImages', () => {
AppEnv.config.onDidChange('core.reading.autoloadImages', () => {
MessageBodyProcessor.resetCache();
});
}
shouldBlockImagesIn = message => {
if (NylasEnv.config.get('core.reading.autoloadImages') === true) {
if (AppEnv.config.get('core.reading.autoloadImages') === true) {
return false;
}
if (this._whitelistEmails[Utils.toEquivalentEmailForm(message.fromContact().email)]) {

View file

@ -89,7 +89,7 @@ export default class EmailFrame extends React.Component {
iframe: iframeNode,
});
} catch (e) {
NylasEnv.reportError(e);
AppEnv.reportError(e);
}
}

View file

@ -13,7 +13,7 @@ import SidebarPluginContainer from './sidebar-plugin-container';
import SidebarParticipantPicker from './sidebar-participant-picker';
export function activate() {
if (NylasEnv.isMainWindow()) {
if (AppEnv.isMainWindow()) {
// Register Message List Actions we provide globally
ComponentRegistry.register(MessageList, {
location: WorkspaceStore.Location.MessageList,
@ -29,7 +29,7 @@ export function activate() {
});
} else {
// This is for the thread-popout window.
const { threadId, perspectiveJSON } = NylasEnv.getWindowProps();
const { threadId, perspectiveJSON } = AppEnv.getWindowProps();
ComponentRegistry.register(MessageList, { location: WorkspaceStore.Location.Center });
// We need to locate the thread and focus it so that the MessageList displays it

View file

@ -30,7 +30,7 @@ export default class MessageControls extends React.Component {
if (!this.props.message.canReplyAll()) {
return [reply, forward];
}
const defaultReplyType = NylasEnv.config.get('core.sending.defaultReplyType');
const defaultReplyType = AppEnv.config.get('core.sending.defaultReplyType');
return defaultReplyType === 'reply-all'
? [replyAll, reply, forward]
: [reply, replyAll, forward];

View file

@ -188,7 +188,7 @@ class MessageList extends React.Component {
// Returns either "reply" or "reply-all"
_replyType() {
const defaultReplyType = NylasEnv.config.get('core.sending.defaultReplyType');
const defaultReplyType = AppEnv.config.get('core.sending.defaultReplyType');
const lastMessage = this._lastMessage();
if (!lastMessage) {
return 'reply';
@ -214,7 +214,7 @@ class MessageList extends React.Component {
return;
}
Actions.focusThreadMainWindow(this.state.currentThread);
NylasEnv.close();
AppEnv.close();
};
_onPopoutThread = () => {
@ -248,7 +248,7 @@ class MessageList extends React.Component {
const hasReplyArea = mostRecentMessage && !mostRecentMessage.draft;
// Invert the message list if the descending option is set
if (NylasEnv.config.get('core.reading.descendingOrderMessageList')) {
if (AppEnv.config.get('core.reading.descendingOrderMessageList')) {
messages = messages.reverse();
}
@ -437,7 +437,7 @@ class MessageList extends React.Component {
}
_renderPopoutToggle() {
if (NylasEnv.isThreadWindow()) {
if (AppEnv.isThreadWindow()) {
return (
<div onClick={this._onPopThreadIn}>
<RetinaImg

View file

@ -60,7 +60,7 @@ export default class MessageParticipants extends React.Component {
click: () => Actions.composeNewDraftToRecipient(contact),
})
);
menu.popup(NylasEnv.getCurrentWindow());
menu.popup(AppEnv.getCurrentWindow());
};
_renderFullContacts(contacts = []) {

View file

@ -219,7 +219,7 @@ describe "MessageList", ->
expect(cs.length).toBe 1
it "prompts for a reply-all when there's more than one participant and the default is reply-all", ->
spyOn(NylasEnv.config, "get").andReturn "reply-all"
spyOn(AppEnv.config, "get").andReturn "reply-all"
MessageStore._items = [m5, m3]
MessageStore._thread = testThread
MessageStore.trigger()
@ -228,7 +228,7 @@ describe "MessageList", ->
expect(cs.length).toBe 1
it "prompts for a reply-all when there's more than one participant and the default is reply", ->
spyOn(NylasEnv.config, "get").andReturn "reply"
spyOn(AppEnv.config, "get").andReturn "reply"
MessageStore._items = [m5, m3]
MessageStore._thread = testThread
MessageStore.trigger()

View file

@ -60,7 +60,7 @@ export default class AccountErrorNotification extends React.Component {
this.setState({ checking: true });
this._checkingTimeout = setTimeout(() => this.setState({ checking: false }), 10000);
accounts.forEach(acct => NylasEnv.mailsyncBridge.forceRelaunchClient(acct));
accounts.forEach(acct => AppEnv.mailsyncBridge.forceRelaunchClient(acct));
}
render() {

View file

@ -24,7 +24,7 @@ export default class DefaultClientNotification extends React.Component {
});
}
});
this.disposable = NylasEnv.config.onDidChange(SETTINGS_KEY, () =>
this.disposable = AppEnv.config.onDidChange(SETTINGS_KEY, () =>
this.setState(this.getStateFromStores())
);
}
@ -36,21 +36,21 @@ export default class DefaultClientNotification extends React.Component {
getStateFromStores() {
return {
alreadyPrompted: NylasEnv.config.get(SETTINGS_KEY),
alreadyPrompted: AppEnv.config.get(SETTINGS_KEY),
};
}
_onAccept = () => {
this.helper.registerForURLScheme('mailto', err => {
if (err) {
NylasEnv.reportError(err);
AppEnv.reportError(err);
}
});
NylasEnv.config.set(SETTINGS_KEY, true);
AppEnv.config.set(SETTINGS_KEY, true);
};
_onDecline = () => {
NylasEnv.config.set(SETTINGS_KEY, true);
AppEnv.config.set(SETTINGS_KEY, true);
};
render() {

View file

@ -9,7 +9,7 @@ export default class DevModeNotification extends React.Component {
// Don't need listeners to update this, since toggling dev mode reloads
// the entire window anyway
this.state = {
inDevMode: NylasEnv.inDevMode(),
inDevMode: AppEnv.inDevMode(),
};
}

View file

@ -26,7 +26,7 @@ export default class UnstableChannelNotification extends React.Component {
}
_onReportIssue = () => {
NylasEnv.windowEventHandler.openLink({ href: 'mailto:support@getmailspring.com' });
AppEnv.windowEventHandler.openLink({ href: 'mailto:support@getmailspring.com' });
};
render() {

View file

@ -11,7 +11,7 @@ export default class UpdateNotification extends React.Component {
}
componentDidMount() {
this.disposable = NylasEnv.onUpdateAvailable(() => {
this.disposable = AppEnv.onUpdateAvailable(() => {
this.setState(this.getStateFromStores());
});
}

View file

@ -28,10 +28,10 @@ describe('AccountErrorNotif', function AccountErrorNotifTests() {
});
it('allows the user to refresh the account', () => {
spyOn(NylasEnv.mailsyncBridge, 'forceRelaunchClient').andReturn(Promise.resolve());
spyOn(AppEnv.mailsyncBridge, 'forceRelaunchClient').andReturn(Promise.resolve());
const notif = mount(<AccountErrorNotification />);
notif.find('#action-0').simulate('click'); // Expects first action to be the refresh action
expect(NylasEnv.mailsyncBridge.forceRelaunchClient).toHaveBeenCalled();
expect(AppEnv.mailsyncBridge.forceRelaunchClient).toHaveBeenCalled();
});
it('allows the user to reconnect the account', () => {
@ -67,10 +67,10 @@ describe('AccountErrorNotif', function AccountErrorNotifTests() {
});
it('allows the user to refresh the accounts', () => {
spyOn(NylasEnv.mailsyncBridge, 'forceRelaunchClient').andReturn(Promise.resolve());
spyOn(AppEnv.mailsyncBridge, 'forceRelaunchClient').andReturn(Promise.resolve());
const notif = mount(<AccountErrorNotification />);
notif.find('#action-0').simulate('click'); // Expects first action to be the refresh action
expect(NylasEnv.mailsyncBridge.forceRelaunchClient).toHaveBeenCalled();
expect(AppEnv.mailsyncBridge.forceRelaunchClient).toHaveBeenCalled();
});
it('allows the user to open preferences', () => {

View file

@ -28,9 +28,9 @@ describe('DefaultClientNotif', function DefaultClientNotifTests() {
});
describe('when the user has already responded', () => {
beforeEach(() => {
spyOn(NylasEnv.config, 'get').andReturn(true);
spyOn(AppEnv.config, 'get').andReturn(true);
this.notif = mount(<DefaultClientNotification />);
expect(NylasEnv.config.get).toHaveBeenCalledWith(SETTINGS_KEY);
expect(AppEnv.config.get).toHaveBeenCalledWith(SETTINGS_KEY);
});
it('renders nothing', () => {
expect(this.notif.find('.notification').exists()).toEqual(false);
@ -39,9 +39,9 @@ describe('DefaultClientNotif', function DefaultClientNotifTests() {
describe('when the user has yet to respond', () => {
beforeEach(() => {
spyOn(NylasEnv.config, 'get').andReturn(false);
spyOn(AppEnv.config, 'get').andReturn(false);
this.notif = mount(<DefaultClientNotification />);
expect(NylasEnv.config.get).toHaveBeenCalledWith(SETTINGS_KEY);
expect(AppEnv.config.get).toHaveBeenCalledWith(SETTINGS_KEY);
});
it('renders a notification', () => {
expect(this.notif.find('.notification').exists()).toEqual(true);
@ -57,9 +57,9 @@ describe('DefaultClientNotif', function DefaultClientNotifTests() {
});
it('allows the user to decline', () => {
spyOn(NylasEnv.config, 'set');
spyOn(AppEnv.config, 'set');
this.notif.find('#action-1').simulate('click'); // Expects second action to decline
expect(NylasEnv.config.set).toHaveBeenCalledWith(SETTINGS_KEY, true);
expect(AppEnv.config.set).toHaveBeenCalledWith(SETTINGS_KEY, true);
});
});
});

View file

@ -5,7 +5,7 @@ import DevModeNotification from '../lib/items/dev-mode-notif';
describe('DevModeNotif', function DevModeNotifTests() {
describe('When the window is in dev mode', () => {
beforeEach(() => {
spyOn(NylasEnv, 'inDevMode').andReturn(true);
spyOn(AppEnv, 'inDevMode').andReturn(true);
this.notif = mount(<DevModeNotification />);
});
it('displays a notification', () => {
@ -15,7 +15,7 @@ describe('DevModeNotif', function DevModeNotifTests() {
describe('When the window is not in dev mode', () => {
beforeEach(() => {
spyOn(NylasEnv, 'inDevMode').andReturn(false);
spyOn(AppEnv, 'inDevMode').andReturn(false);
this.notif = mount(<DevModeNotification />);
});
it("doesn't display a notification", () => {

View file

@ -55,9 +55,9 @@ describe('UpdateNotification', function describeBlock() {
});
it('should listen for `window:update-available`', () => {
spyOn(NylasEnv, 'onUpdateAvailable').andCallThrough();
spyOn(AppEnv, 'onUpdateAvailable').andCallThrough();
mount(<UpdateNotification />);
expect(NylasEnv.onUpdateAvailable).toHaveBeenCalled();
expect(AppEnv.onUpdateAvailable).toHaveBeenCalled();
});
});

View file

@ -8,7 +8,7 @@ export function activate() {
location: WorkspaceStore.Location.Center,
});
const accounts = NylasEnv.config.get('accounts') || [];
const accounts = AppEnv.config.get('accounts') || [];
if (accounts.length === 0) {
const startService = new SystemStartService();

View file

@ -143,7 +143,7 @@ export async function finalizeAndValidateAccount(account) {
}
// Test connections to IMAP and SMTP
const proc = new MailsyncProcess(NylasEnv.getLoadSettings(), IdentityStore.identity(), account);
const proc = new MailsyncProcess(AppEnv.getLoadSettings(), IdentityStore.identity(), account);
const response = await proc.test();
return new Account(response.account);
}

View file

@ -38,8 +38,8 @@ export default class OnboardingRoot extends React.Component {
componentDidMount() {
this.unsubscribe = OnboardingStore.listen(this._onStateChanged, this);
NylasEnv.center();
NylasEnv.displayWindow();
AppEnv.center();
AppEnv.displayWindow();
}
componentWillUnmount() {

View file

@ -24,7 +24,7 @@ class OnboardingStore extends NylasStore {
}
});
const { existingAccount, addingAccount, accountProvider } = NylasEnv.getWindowProps();
const { existingAccount, addingAccount, accountProvider } = AppEnv.getWindowProps();
const hasAccounts = AccountStore.accounts().length > 0;
const identity = IdentityStore.identity();
@ -140,7 +140,7 @@ class OnboardingStore extends NylasStore {
const isFirstAccount = AccountStore.accounts().length === 0;
AccountStore.addAccount(account);
NylasEnv.displayWindow();
AppEnv.displayWindow();
Actions.recordUserEvent('Email Account Auth Succeeded', {
provider: account.provider,
@ -159,8 +159,8 @@ class OnboardingStore extends NylasStore {
}, 2000);
}
} catch (e) {
NylasEnv.reportError(e);
NylasEnv.showErrorDialog(
AppEnv.reportError(e);
AppEnv.showErrorDialog(
'Unable to Connect Account',
"Sorry, something went wrong on the Nylas server. Please try again. If you're still having issues, contact us at support@getmailspring.com."
);

View file

@ -10,7 +10,7 @@ export default class AuthenticatePage extends React.Component {
};
_src() {
const n1Version = NylasEnv.getVersion();
const n1Version = AppEnv.getVersion();
return `${NylasAPIRequest.rootURLForServer(
'identity'
)}/onboarding?utm_medium=N1&utm_source=OnboardingPage&N1_version=${n1Version}&client_edition=basic`;

View file

@ -39,7 +39,7 @@ class InitialPreferencesOptions extends React.Component
@_loadTemplates()
_loadTemplates: =>
templatesDir = path.join(NylasEnv.getLoadSettings().resourcePath, 'keymaps', 'templates')
templatesDir = path.join(AppEnv.getLoadSettings().resourcePath, 'keymaps', 'templates')
fs.readdir templatesDir, (err, files) =>
return unless files and files instanceof Array
templates = files.filter (filename) =>

View file

@ -17,9 +17,9 @@ const PageTopBar = props => {
OnboardingActions.moveToPreviousPage();
} else {
if (AccountStore.accounts().length === 0) {
NylasEnv.quit();
AppEnv.quit();
} else {
NylasEnv.close();
AppEnv.close();
}
}
};

View file

@ -2,4 +2,4 @@ import plugin from '../package.json';
export const PLUGIN_NAME = plugin.title;
export const PLUGIN_ID = plugin.name;
export const PLUGIN_URL = plugin.serverUrl[NylasEnv.config.get('env')];
export const PLUGIN_URL = plugin.serverUrl[AppEnv.config.get('env')];

View file

@ -85,12 +85,12 @@ export default class CommandKeybinding extends React.Component {
_onEdit = () => {
this.setState({ editing: true, editingBinding: null, keys: [], modifiers: [] });
NylasEnv.keymaps.suspendAllKeymaps();
AppEnv.keymaps.suspendAllKeymaps();
};
_onFinishedEditing = () => {
if (this.state.editingBinding) {
const keymapPath = NylasEnv.keymaps.getUserKeymapPath();
const keymapPath = AppEnv.keymaps.getUserKeymapPath();
let keymaps = {};
try {
@ -107,13 +107,13 @@ export default class CommandKeybinding extends React.Component {
try {
fs.writeFileSync(keymapPath, JSON.stringify(keymaps, null, 2));
} catch (err) {
NylasEnv.showErrorDialog(
AppEnv.showErrorDialog(
`Nylas was unable to modify your keymaps at ${keymapPath}. ${err.toString()}`
);
}
}
this.setState({ editing: false, editingBinding: null });
NylasEnv.keymaps.resumeAllKeymaps();
AppEnv.keymaps.resumeAllKeymaps();
};
_onKey = event => {

View file

@ -23,7 +23,7 @@ class AppearanceModeSwitch extends React.Component {
}
_onApplyChanges = () => {
NylasEnv.commands.dispatch(`application:select-${this.state.value}-mode`);
AppEnv.commands.dispatch(`application:select-${this.state.value}-mode`);
};
_renderModeOptions() {
@ -86,7 +86,7 @@ class PreferencesAppearance extends React.Component {
};
onClick = () => {
NylasEnv.commands.dispatch('window:launch-theme-picker');
AppEnv.commands.dispatch('window:launch-theme-picker');
};
render() {

View file

@ -23,7 +23,7 @@ class PreferencesGeneral extends React.Component {
_resetAccountsAndSettings = () => {
const rimraf = require('rimraf');
rimraf(NylasEnv.getConfigDirPath(), { disableGlob: true }, err => {
rimraf(AppEnv.getConfigDirPath(), { disableGlob: true }, err => {
if (err) console.log(err);
else this._reboot();
});

View file

@ -25,7 +25,7 @@ export default class PreferencesKeymaps extends React.Component {
}
componentDidMount() {
this._disposable = NylasEnv.keymaps.onDidReloadKeymap(() => {
this._disposable = AppEnv.keymaps.onDidReloadKeymap(() => {
this.setState({ bindings: this._getStateFromKeymaps() });
});
}
@ -38,14 +38,14 @@ export default class PreferencesKeymaps extends React.Component {
const bindings = {};
for (const section of displayedKeybindings) {
for (const [command] of section.items) {
bindings[command] = NylasEnv.keymaps.getBindingsForCommand(command) || [];
bindings[command] = AppEnv.keymaps.getBindingsForCommand(command) || [];
}
}
return bindings;
}
_loadTemplates() {
const templatesDir = path.join(NylasEnv.getLoadSettings().resourcePath, 'keymaps', 'templates');
const templatesDir = path.join(AppEnv.getLoadSettings().resourcePath, 'keymaps', 'templates');
fs.readdir(templatesDir, (err, files) => {
if (!files || !(files instanceof Array)) return;
let templates = files.filter(filename => {
@ -59,7 +59,7 @@ export default class PreferencesKeymaps extends React.Component {
}
_onShowUserKeymaps() {
const keymapsFile = NylasEnv.keymaps.getUserKeymapPath();
const keymapsFile = AppEnv.keymaps.getUserKeymapPath();
if (!fs.existsSync(keymapsFile)) {
fs.writeFileSync(keymapsFile, '{}');
}
@ -67,7 +67,7 @@ export default class PreferencesKeymaps extends React.Component {
}
_onDeleteUserKeymap() {
const chosen = remote.dialog.showMessageBox(NylasEnv.getCurrentWindow(), {
const chosen = remote.dialog.showMessageBox(AppEnv.getCurrentWindow(), {
type: 'info',
message: 'Are you sure?',
detail: 'Delete your custom key bindings and reset to the template defaults?',
@ -75,7 +75,7 @@ export default class PreferencesKeymaps extends React.Component {
});
if (chosen === 1) {
const keymapsFile = NylasEnv.keymaps.getUserKeymapPath();
const keymapsFile = AppEnv.keymaps.getUserKeymapPath();
fs.writeFileSync(keymapsFile, '{}');
}
}

View file

@ -83,7 +83,7 @@ class PreferencesMailRules extends React.Component {
};
if (needsMessageBodies()) {
NylasEnv.showErrorDialog(
AppEnv.showErrorDialog(
"One or more of your mail rules requires the bodies of messages being processed. These rules can't be run on your entire mailbox."
);
}

View file

@ -41,7 +41,7 @@ class UpdateChannelSection extends React.Component {
// In the future we could implement this server-side via a "public" flag.
const allowedNames = ['stable', 'nylas-mail', 'beta'];
if (NylasEnv.config.get('salesforce')) {
if (AppEnv.config.get('salesforce')) {
allowedNames.push('salesforce');
}

View file

@ -4,7 +4,7 @@ style = null
module.exports =
activate: ->
NylasEnv.commands.add document.body, "window:toggle-screenshot-mode", ->
AppEnv.commands.add document.body, "window:toggle-screenshot-mode", ->
if not style
style = document.createElement('style')
style.innerText = fs.readFileSync(path.join(__dirname, '..', 'assets','font-override.css')).toString()

View file

@ -106,12 +106,12 @@ class SendLaterButton extends Component {
session.changes.addPluginMetadata(PLUGIN_ID, { expiration });
if (expiration && NylasEnv.isComposerWindow()) {
NylasEnv.close();
if (expiration && AppEnv.isComposerWindow()) {
AppEnv.close();
}
} catch (error) {
NylasEnv.reportError(error);
NylasEnv.showErrorDialog(`Sorry, we were unable to schedule this message. ${error.message}`);
AppEnv.reportError(error);
AppEnv.showErrorDialog(`Sorry, we were unable to schedule this message. ${error.message}`);
}
if (!this.mounted) {

View file

@ -60,26 +60,26 @@ xdescribe('SendLaterButton', function sendLaterButton() {
it('displays dialog if an auth error occurs', () => {
const button = makeButton(null, { sendLaterDate: 'date' });
spyOn(button, 'setState');
spyOn(NylasEnv, 'reportError');
spyOn(NylasEnv, 'showErrorDialog');
spyOn(AppEnv, 'reportError');
spyOn(AppEnv, 'showErrorDialog');
spyOn(NylasAPIHelpers, 'authPlugin').andReturn(Promise.reject(new Error('Oh no!')));
spyOn(Actions, 'finalizeDraftAndSyncbackMetadata');
button.onSendLater({ utc: () => 'utc' });
advanceClock();
expect(NylasEnv.reportError).toHaveBeenCalled();
expect(NylasEnv.showErrorDialog).toHaveBeenCalled();
expect(AppEnv.reportError).toHaveBeenCalled();
expect(AppEnv.showErrorDialog).toHaveBeenCalled();
});
it('closes the composer window if a sendLaterDate has been set', () => {
const button = makeButton(null, { sendLaterDate: 'date' });
spyOn(button, 'setState');
spyOn(NylasEnv, 'close');
spyOn(AppEnv, 'close');
spyOn(NylasAPIHelpers, 'authPlugin').andReturn(Promise.resolve());
spyOn(NylasEnv, 'isComposerWindow').andReturn(true);
spyOn(AppEnv, 'isComposerWindow').andReturn(true);
spyOn(Actions, 'finalizeDraftAndSyncbackMetadata');
button.onSendLater({ utc: () => 'utc' });
advanceClock();
expect(NylasEnv.close).toHaveBeenCalled();
expect(AppEnv.close).toHaveBeenCalled();
});
});

View file

@ -4,7 +4,7 @@ import { Actions, WorkspaceStore } from 'nylas-exports';
import ThemePicker from './theme-picker';
export function activate() {
this.disposable = NylasEnv.commands.add(document.body, 'window:launch-theme-picker', () => {
this.disposable = AppEnv.commands.add(document.body, 'window:launch-theme-picker', () => {
WorkspaceStore.popToRootSheet();
Actions.openModal({
component: <ThemePicker />,

View file

@ -26,7 +26,7 @@ class ThemeOption extends React.Component {
_getImportPaths() {
return [
this.props.theme.getStylesheetsPath(),
NylasEnv.themes.getBaseTheme().getStylesheetsPath(),
AppEnv.themes.getBaseTheme().getStylesheetsPath(),
];
}
@ -38,7 +38,7 @@ class ThemeOption extends React.Component {
}
_loadLessStylesheet(lessStylesheetPath) {
const { configDirPath, resourcePath } = NylasEnv.getLoadSettings();
const { configDirPath, resourcePath } = AppEnv.getLoadSettings();
if (this.lessCache) {
this.lessCache.setImportPaths(this._getImportPaths());
} else {
@ -64,7 +64,7 @@ class ThemeOption extends React.Component {
const doc = ReactDOM.findDOMNode(this._iframeComponent).contentDocument;
if (!doc) return;
const { resourcePath } = NylasEnv.getLoadSettings();
const { resourcePath } = AppEnv.getLoadSettings();
const css = `<style>${this._loadStylesheet(
`${resourcePath}/internal_packages/theme-picker/preview-styles/theme-option.less`
)}</style>`;

View file

@ -9,7 +9,7 @@ class ThemePicker extends React.Component {
constructor(props) {
super(props);
this.themes = NylasEnv.themes;
this.themes = AppEnv.themes;
this.state = this._getState();
}

View file

@ -5,14 +5,14 @@ import ReactTestUtils from 'react-dom/test-utils';
import Package from '../../../src/package';
import ThemePicker from '../lib/theme-picker';
const { resourcePath } = NylasEnv.getLoadSettings();
const { resourcePath } = AppEnv.getLoadSettings();
const light = new Package(`${resourcePath}/internal_packages/ui-light`);
const dark = new Package(`${resourcePath}/internal_packages/ui-dark`);
describe('ThemePicker', function themePicker() {
beforeEach(() => {
spyOn(NylasEnv.themes, 'getAvailableThemes').andReturn([light, dark]);
spyOn(NylasEnv.themes, 'getActiveTheme').andReturn(light);
spyOn(AppEnv.themes, 'getAvailableThemes').andReturn([light, dark]);
spyOn(AppEnv.themes, 'getActiveTheme').andReturn(light);
this.component = ReactTestUtils.renderIntoDocument(<ThemePicker />);
});

View file

@ -172,7 +172,7 @@ class ThreadList extends React.Component
Actions.queueTasks(tasks)
callback(true)
disabledPackages = NylasEnv.config.get('core.disabledPackages') ? []
disabledPackages = AppEnv.config.get('core.disabledPackages') ? []
if 'thread-snooze' in disabledPackages
return props
@ -266,7 +266,7 @@ class ThreadList extends React.Component
}))
_onSnoozeItem: =>
disabledPackages = NylasEnv.config.get('core.disabledPackages') ? []
disabledPackages = AppEnv.config.get('core.disabledPackages') ? []
if 'thread-snooze' in disabledPackages
return
@ -287,7 +287,7 @@ class ThreadList extends React.Component
_onSetImportant: (important) =>
threads = @_threadsForKeyboardAction()
return unless threads
return unless NylasEnv.config.get('core.workspace.showImportant')
return unless AppEnv.config.get('core.workspace.showImportant')
Actions.queueTasks(TaskFactory.tasksForThreadsByAccountId(threads, (accountThreads, accountId) =>
return new ChangeLabelsTask({

View file

@ -255,7 +255,7 @@ class ThreadArrowButton extends React.Component {
if (this.state.disabled) {
return;
}
NylasEnv.commands.dispatch(this.props.command);
AppEnv.commands.dispatch(this.props.command);
return;
};

View file

@ -7,7 +7,7 @@ SearchActions = require('../lib/search-actions').default
describe 'ThreadSearchBar', ->
beforeEach ->
spyOn(NylasEnv, "isMainWindow").andReturn true
spyOn(AppEnv, "isMainWindow").andReturn true
@searchBar = ReactTestUtils.renderIntoDocument(<ThreadSearchBar />)
@input = ReactDOM.findDOMNode(@searchBar).querySelector("input")

View file

@ -66,7 +66,7 @@ class SnoozePopover extends Component {
if (date) {
this.onSnooze(date, 'Custom');
} else {
NylasEnv.showErrorDialog(`Sorry, we can't parse ${inputValue} as a valid date.`);
AppEnv.showErrorDialog(`Sorry, we can't parse ${inputValue} as a valid date.`);
}
};

View file

@ -80,8 +80,8 @@ class SnoozeStore extends NylasStore {
}
moveThreads(threads, { snooze: false, description: 'Unsnoozed' });
Actions.closePopover();
NylasEnv.reportError(error);
NylasEnv.showErrorDialog(
AppEnv.reportError(error);
AppEnv.showErrorDialog(
`Sorry, we were unable to save your snooze settings. ${error.message}`
);
}

View file

@ -50,8 +50,8 @@ xdescribe('SnoozeStore', function snoozeStore() {
spyOn(NylasAPIHelpers, 'authPlugin').andReturn(Promise.resolve());
spyOn(SnoozeUtils, 'moveThreads');
spyOn(Actions, 'closePopover');
spyOn(NylasEnv, 'reportError');
spyOn(NylasEnv, 'showErrorDialog');
spyOn(AppEnv, 'reportError');
spyOn(AppEnv, 'showErrorDialog');
});
describe('groupUpdatedThreads', () => {
@ -124,8 +124,8 @@ xdescribe('SnoozeStore', function snoozeStore() {
//
}
expect(SnoozeUtils.moveThreads).toHaveBeenCalled();
expect(NylasEnv.reportError).toHaveBeenCalled();
expect(NylasEnv.showErrorDialog).toHaveBeenCalled();
expect(AppEnv.reportError).toHaveBeenCalled();
expect(AppEnv.showErrorDialog).toHaveBeenCalled();
});
});
});

View file

@ -8,7 +8,7 @@ export function activate() {
ComponentRegistry.register(UndoSendToast, {
location: WorkspaceStore.Sheet.Global.Footer,
});
if (NylasEnv.isMainWindow()) {
if (AppEnv.isMainWindow()) {
ComponentRegistry.register(UndoRedoThreadListToast, {
location: WorkspaceStore.Location.ThreadList,
});
@ -18,7 +18,7 @@ export function activate() {
export function deactivate() {
UndoSendStore.deactivate();
ComponentRegistry.unregister(UndoSendToast);
if (NylasEnv.isMainWindow()) {
if (AppEnv.isMainWindow()) {
ComponentRegistry.unregister(UndoRedoThreadListToast);
}
}

View file

@ -4,7 +4,7 @@ import { UndoRedoStore } from 'nylas-exports';
import { UndoToast, ListensToFluxStore } from 'nylas-component-kit';
function onUndo() {
NylasEnv.commands.dispatch('core:undo');
AppEnv.commands.dispatch('core:undo');
}
function UndoRedoThreadListToast(props) {

View file

@ -37,7 +37,7 @@ export class Notifier {
}
if (objectClass === Message.name) {
if (NylasEnv.config.get('core.notifications.enabled') === false) {
if (AppEnv.config.get('core.notifications.enabled') === false) {
return;
}
const newUnread = objects.filter(msg => {
@ -89,11 +89,11 @@ export class Notifier {
if (activationType === 'replied' && response && typeof response === 'string') {
Actions.sendQuickReply({ thread, message }, response);
} else {
NylasEnv.displayWindow();
AppEnv.displayWindow();
}
if (!thread) {
NylasEnv.showErrorDialog(`Can't find that thread`);
AppEnv.showErrorDialog(`Can't find that thread`);
return;
}
Actions.ensureCategoryIsFocused('inbox', thread.accountId);
@ -157,7 +157,7 @@ export class Notifier {
this.unnotifiedQueue.push({ message: msg, thread: threads[msg.threadId] });
}
if (!this.hasScheduledNotify) {
if (NylasEnv.config.get('core.notifications.sounds')) {
if (AppEnv.config.get('core.notifications.sounds')) {
this._playNewMailSound =
this._playNewMailSound ||
_.debounce(() => SoundRegistry.playSound('new-mail'), 5000, true);

View file

@ -338,7 +338,7 @@ describe('UnreadNotifications', function UnreadNotifications() {
});
it('should play a sound when it gets new mail', () => {
spyOn(NylasEnv.config, 'get').andCallFake(config => {
spyOn(AppEnv.config, 'get').andCallFake(config => {
if (config === 'core.notifications.enabled') return true;
if (config === 'core.notifications.sounds') return true;
return undefined;
@ -350,13 +350,13 @@ describe('UnreadNotifications', function UnreadNotifications() {
objectClass: Message.name,
objects: [this.msg1],
});
expect(NylasEnv.config.get.calls[1].args[0]).toBe('core.notifications.sounds');
expect(AppEnv.config.get.calls[1].args[0]).toBe('core.notifications.sounds');
expect(SoundRegistry.playSound).toHaveBeenCalledWith('new-mail');
});
});
it('should not play a sound if the config is off', () => {
spyOn(NylasEnv.config, 'get').andCallFake(config => {
spyOn(AppEnv.config, 'get').andCallFake(config => {
if (config === 'core.notifications.enabled') return true;
if (config === 'core.notifications.sounds') return false;
return undefined;
@ -367,13 +367,13 @@ describe('UnreadNotifications', function UnreadNotifications() {
objectClass: Message.name,
objects: [this.msg1],
});
expect(NylasEnv.config.get.calls[1].args[0]).toBe('core.notifications.sounds');
expect(AppEnv.config.get.calls[1].args[0]).toBe('core.notifications.sounds');
expect(SoundRegistry.playSound).not.toHaveBeenCalled();
});
});
it('should not play a sound if other notiications are still in flight', () => {
spyOn(NylasEnv.config, 'get').andCallFake(config => {
spyOn(AppEnv.config, 'get').andCallFake(config => {
if (config === 'core.notifications.enabled') return true;
if (config === 'core.notifications.sounds') return true;
return undefined;

View file

@ -14,18 +14,18 @@ function onDialogActionTaken(numAsks) {
return buttonIndex => {
if (numAsks >= 1) {
if (buttonIndex === 1) {
NylasEnv.config.set('asksAboutAppMove', 5);
AppEnv.config.set('asksAboutAppMove', 5);
} else {
NylasEnv.config.set('asksAboutAppMove', numAsks + 1);
AppEnv.config.set('asksAboutAppMove', numAsks + 1);
}
} else {
NylasEnv.config.set('asksAboutAppMove', numAsks + 1);
AppEnv.config.set('asksAboutAppMove', numAsks + 1);
}
};
}
export function activate() {
if (NylasEnv.inDevMode() || NylasEnv.inSpecMode()) {
if (AppEnv.inDevMode() || AppEnv.inSpecMode()) {
return;
}
@ -46,13 +46,13 @@ export function activate() {
return;
}
const numAsks = NylasEnv.config.get('asksAboutAppMove') || 0;
const numAsks = AppEnv.config.get('asksAboutAppMove') || 0;
if (numAsks <= 0) {
NylasEnv.config.set('asksAboutAppMove', 1);
AppEnv.config.set('asksAboutAppMove', 1);
return;
}
NylasEnv.config.set('asksAboutAppMove', numAsks + 1);
AppEnv.config.set('asksAboutAppMove', numAsks + 1);
if (numAsks >= 5) return;
let buttons;

View file

@ -22,11 +22,11 @@ const PackagesStore = Reflux.createStore({
// this._refreshFeatured();
// this.listenTo(PluginsActions.refreshFeaturedPackages, this._refreshFeatured);
// this.listenTo(PluginsActions.refreshInstalledPackages, this._refreshInstalled);
// NylasEnv.commands.add(document.body,
// AppEnv.commands.add(document.body,
// 'application:create-package',
// () => this._onCreatePackage()
// );
// NylasEnv.commands.add(document.body,
// AppEnv.commands.add(document.body,
// 'application:install-package',
// () => this._onInstallPackage()
// );
@ -36,7 +36,7 @@ const PackagesStore = Reflux.createStore({
// this.listenTo(PluginsActions.setGlobalSearchValue, this._onGlobalSearchChange);
// this.listenTo(PluginsActions.setInstalledSearchValue, this._onInstalledSearchChange);
// this.listenTo(PluginsActions.showPackage, (pkg) => {
// const dir = NylasEnv.packages.resolvePackagePath(pkg.name);
// const dir = AppEnv.packages.resolvePackagePath(pkg.name);
// if (dir) shell.showItemInFolder(dir);
// });
// this.listenTo(PluginsActions.installPackage, (pkg) => {
@ -47,17 +47,17 @@ const PackagesStore = Reflux.createStore({
// delete this._installing[pkg.name];
// this._displayMessage("Sorry, an error occurred", err.toString());
// } else {
// if (NylasEnv.packages.isPackageDisabled(pkg.name)) {
// NylasEnv.packages.enablePackage(pkg.name);
// if (AppEnv.packages.isPackageDisabled(pkg.name)) {
// AppEnv.packages.enablePackage(pkg.name);
// }
// }
// this._onPackagesChanged();
// });
// });
// this.listenTo(PluginsActions.uninstallPackage, (pkg) => {
// if (NylasEnv.packages.isPackageLoaded(pkg.name)) {
// NylasEnv.packages.disablePackage(pkg.name);
// NylasEnv.packages.unloadPackage(pkg.name);
// if (AppEnv.packages.isPackageLoaded(pkg.name)) {
// AppEnv.packages.disablePackage(pkg.name);
// AppEnv.packages.unloadPackage(pkg.name);
// }
// this._apm.uninstall(pkg, (err) => {
// if (err) this._displayMessage("Sorry, an error occurred", err.toString())
@ -65,14 +65,14 @@ const PackagesStore = Reflux.createStore({
// })
// });
// this.listenTo(PluginsActions.enablePackage, (pkg) => {
// if (NylasEnv.packages.isPackageDisabled(pkg.name)) {
// NylasEnv.packages.enablePackage(pkg.name);
// if (AppEnv.packages.isPackageDisabled(pkg.name)) {
// AppEnv.packages.enablePackage(pkg.name);
// this._onPackagesChanged();
// }
// });
// this.listenTo(PluginsActions.disablePackage, (pkg) => {
// if (!NylasEnv.packages.isPackageDisabled(pkg.name)) {
// NylasEnv.packages.disablePackage(pkg.name);
// if (!AppEnv.packages.isPackageDisabled(pkg.name)) {
// AppEnv.packages.disablePackage(pkg.name);
// this._onPackagesChanged();
// }
// });
@ -107,10 +107,10 @@ const PackagesStore = Reflux.createStore({
_prepareIfFresh: function _prepareIfFresh() {
if (this._hasPrepared) return;
NylasEnv.packages.onDidActivatePackage(() => this._onPackagesChangedDebounced());
NylasEnv.packages.onDidDeactivatePackage(() => this._onPackagesChangedDebounced());
NylasEnv.packages.onDidLoadPackage(() => this._onPackagesChangedDebounced());
NylasEnv.packages.onDidUnloadPackage(() => this._onPackagesChangedDebounced());
AppEnv.packages.onDidActivatePackage(() => this._onPackagesChangedDebounced());
AppEnv.packages.onDidDeactivatePackage(() => this._onPackagesChangedDebounced());
AppEnv.packages.onDidLoadPackage(() => this._onPackagesChangedDebounced());
AppEnv.packages.onDidUnloadPackage(() => this._onPackagesChangedDebounced());
this._onPackagesChanged();
this._hasPrepared = true;
},
@ -184,7 +184,7 @@ const PackagesStore = Reflux.createStore({
});
}
const available = NylasEnv.packages.getAvailablePackageMetadata();
const available = AppEnv.packages.getAvailablePackageMetadata();
const examples = available.filter(
({ isOptional, isHiddenOnPluginsPage }) => isOptional && !isHiddenOnPluginsPage
);
@ -210,7 +210,7 @@ const PackagesStore = Reflux.createStore({
},
_onInstallPackage: function _onInstallPackage() {
NylasEnv.showOpenDialog(
AppEnv.showOpenDialog(
{
title: 'Choose a Plugin Directory',
buttonLabel: 'Choose',
@ -218,7 +218,7 @@ const PackagesStore = Reflux.createStore({
},
filenames => {
if (!filenames || filenames.length === 0) return;
NylasEnv.packages.installPackageFromPath(filenames[0], (err, packageName) => {
AppEnv.packages.installPackageFromPath(filenames[0], (err, packageName) => {
if (err) {
this._displayMessage('Could not install plugin', err.message);
} else {
@ -232,7 +232,7 @@ const PackagesStore = Reflux.createStore({
},
_onCreatePackage: function _onCreatePackage() {
if (!NylasEnv.inDevMode()) {
if (!AppEnv.inDevMode()) {
const btn = dialog.showMessageBox({
type: 'warning',
message: 'Run with debug flags?',
@ -245,10 +245,10 @@ const PackagesStore = Reflux.createStore({
return;
}
const packagesDir = path.join(NylasEnv.getConfigDirPath(), 'dev', 'packages');
const packagesDir = path.join(AppEnv.getConfigDirPath(), 'dev', 'packages');
fs.makeTreeSync(packagesDir);
NylasEnv.showSaveDialog(
AppEnv.showSaveDialog(
{
title: 'Save New Package',
defaultPath: packagesDir,
@ -266,7 +266,7 @@ const PackagesStore = Reflux.createStore({
);
}
if (NylasEnv.packages.resolvePackagePath(packageName)) {
if (AppEnv.packages.resolvePackagePath(packageName)) {
this._displayMessage(
'Invalid plugin name',
'Sorry, you must give your plugin a unique name.'
@ -282,7 +282,7 @@ const PackagesStore = Reflux.createStore({
this._displayMessage('Could not create plugin', err.toString());
return;
}
const { resourcePath } = NylasEnv.getLoadSettings();
const { resourcePath } = AppEnv.getLoadSettings();
const packageTemplatePath = path.join(resourcePath, 'static', 'package-template');
const packageJSON = {
name: packageName,
@ -293,7 +293,7 @@ const PackagesStore = Reflux.createStore({
url: '',
},
engines: {
mailspring: `>=${NylasEnv.getVersion().split('-')[0]}`,
mailspring: `>=${AppEnv.getVersion().split('-')[0]}`,
},
windowTypes: {
default: true,
@ -311,8 +311,8 @@ const PackagesStore = Reflux.createStore({
);
shell.showItemInFolder(packageDir);
_.defer(() => {
NylasEnv.packages.enablePackage(packageDir);
NylasEnv.packages.activatePackage(packageName);
AppEnv.packages.enablePackage(packageDir);
AppEnv.packages.activatePackage(packageName);
});
});
}
@ -335,7 +335,7 @@ const PackagesStore = Reflux.createStore({
const installedNames = _.flatten(Object.values(this._installed)).map(pkg => pkg.name);
_.flatten(Object.values(pkgs)).forEach(pkg => {
pkg.enabled = !NylasEnv.packages.isPackageDisabled(pkg.name);
pkg.enabled = !AppEnv.packages.isPackageDisabled(pkg.name);
pkg.installed = installedNames.indexOf(pkg.name) !== -1;
pkg.installing = this._installing[pkg.name];
pkg.newerVersionAvailable = this._newerVersions[pkg.name];

View file

@ -61,7 +61,7 @@ class TabInstalled extends React.Component {
let devPackages = [];
let devEmpty = (
<span
>{`Run with debug flags enabled to load ${NylasEnv.getConfigDirPath()}/dev/packages.`}</span>
>{`Run with debug flags enabled to load ${AppEnv.getConfigDirPath()}/dev/packages.`}</span>
);
let devCTA = (
<div className="btn btn-small" onClick={this._onEnableDevMode}>
@ -69,11 +69,11 @@ class TabInstalled extends React.Component {
</div>
);
if (NylasEnv.inDevMode()) {
if (AppEnv.inDevMode()) {
devPackages = this.state.packages.dev || [];
devEmpty = (
<span>
{`You don't have any packages installed in ${NylasEnv.getConfigDirPath()}/dev/packages. `}
{`You don't have any packages installed in ${AppEnv.getConfigDirPath()}/dev/packages. `}
These plugins are only loaded when you run the app with debug flags enabled (via the
Developer menu).<br />
<br />Learn more about building plugins with{' '}
@ -109,7 +109,7 @@ class TabInstalled extends React.Component {
emptyText={
searchEmpty || (
<span
>{`You don't have any plugins installed in ${NylasEnv.getConfigDirPath()}/packages.`}</span>
>{`You don't have any plugins installed in ${AppEnv.getConfigDirPath()}/packages.`}</span>
)
}
/>

View file

@ -39,8 +39,8 @@ const _openExternalThread = (event, nylasUrl) => {
Actions.popoutThread(thread);
})
.catch(error => {
NylasEnv.reportError(error);
NylasEnv.showErrorDialog(`The thread ${subject} does not exist in your mailbox!`);
AppEnv.reportError(error);
AppEnv.showErrorDialog(`The thread ${subject} does not exist in your mailbox!`);
});
};

View file

@ -2,4 +2,4 @@ import plugin from '../package.json';
export const PLUGIN_NAME = plugin.title;
export const PLUGIN_ID = plugin.name;
export const PLUGIN_URL = plugin.serverUrl[NylasEnv.config.get('env')];
export const PLUGIN_URL = plugin.serverUrl[AppEnv.config.get('env')];

View file

@ -77,8 +77,8 @@ export default class ThreadSharingPopover extends React.Component {
})
);
} catch (error) {
NylasEnv.reportError(error);
NylasEnv.showErrorDialog(
AppEnv.reportError(error);
AppEnv.showErrorDialog(
`Sorry, we were unable to update your sharing settings.\n\n${error.message}`
);
}

View file

@ -12,8 +12,8 @@ describe "ActionBridge", ->
describe "in the main window", ->
beforeEach ->
spyOn(NylasEnv, "getWindowType").andReturn "default"
spyOn(NylasEnv, "isMainWindow").andReturn true
spyOn(AppEnv, "getWindowType").andReturn "default"
spyOn(AppEnv, "isMainWindow").andReturn true
@bridge = new ActionBridge(ipc)
it "should have the role Role.MAIN", ->
@ -39,8 +39,8 @@ describe "ActionBridge", ->
describe "in another window", ->
beforeEach ->
spyOn(NylasEnv, "getWindowType").andReturn "popout"
spyOn(NylasEnv, "isMainWindow").andReturn false
spyOn(AppEnv, "getWindowType").andReturn "popout"
spyOn(AppEnv, "isMainWindow").andReturn false
@bridge = new ActionBridge(ipc)
@message = new Message
id: 'test-id'
@ -69,8 +69,8 @@ describe "ActionBridge", ->
describe "onRebroadcast", ->
beforeEach ->
spyOn(NylasEnv, "getWindowType").andReturn "popout"
spyOn(NylasEnv, "isMainWindow").andReturn false
spyOn(AppEnv, "getWindowType").andReturn "popout"
spyOn(AppEnv, "isMainWindow").andReturn false
@bridge = new ActionBridge(ipc)
describe "when called with TargetWindows.ALL", ->

View file

@ -45,10 +45,10 @@ describe('DatePickerPopover', function sendLaterPopover() {
});
it('throws error if date is invalid', () => {
spyOn(NylasEnv, 'showErrorDialog')
spyOn(AppEnv, 'showErrorDialog')
const popover = makePopover()
popover.instance().onCustomDateSelected(null, 'abc')
expect(NylasEnv.showErrorDialog).toHaveBeenCalled()
expect(AppEnv.showErrorDialog).toHaveBeenCalled()
});
});

View file

@ -14,8 +14,8 @@ describe 'EventedIFrame', ->
@preventDefaultSpy = jasmine.createSpy('preventDefault')
@openLinkSpy = jasmine.createSpy("openLink")
@oldOpenLink = NylasEnv.windowEventHandler.openLink
NylasEnv.windowEventHandler.openLink = @openLinkSpy
@oldOpenLink = AppEnv.windowEventHandler.openLink
AppEnv.windowEventHandler.openLink = @openLinkSpy
@fakeEvent = (href) =>
stopPropagation: ->
@ -25,7 +25,7 @@ describe 'EventedIFrame', ->
setAttribute: @setAttributeSpy
afterEach ->
NylasEnv.windowEventHandler.openLink = @oldOpenLink
AppEnv.windowEventHandler.openLink = @oldOpenLink
it 'works for acceptable link types', ->
hrefs = [

View file

@ -21,7 +21,7 @@ const participant3 = new Contact({
xdescribe('ParticipantsTextField', function ParticipantsTextFieldSpecs() {
beforeEach(() => {
spyOn(NylasEnv, "isMainWindow").andReturn(true)
spyOn(AppEnv, "isMainWindow").andReturn(true)
this.propChange = jasmine.createSpy('change')
this.fieldName = 'to';

View file

@ -2,4 +2,4 @@ class TestItem
getUri: -> "test"
exports.activate = ->
NylasEnv.workspace.addOpener -> new TestItem
AppEnv.workspace.addOpener -> new TestItem

View file

@ -4,7 +4,7 @@ describe "MenuManager", ->
menu = null
beforeEach ->
menu = new MenuManager(resourcePath: NylasEnv.getLoadSettings().resourcePath)
menu = new MenuManager(resourcePath: AppEnv.getLoadSettings().resourcePath)
menu.template = []
describe "::add(items)", ->

View file

@ -4,23 +4,23 @@ import { TaskQueue } from 'nylas-exports';
class MasterAfterEach {
setup(loadSettings, afterEach) {
const styleElementsToRestore = NylasEnv.styles.getSnapshot();
const styleElementsToRestore = AppEnv.styles.getSnapshot();
const self = this;
afterEach(async function masterAfterEach() {
// await destroyTestDatabase() TODO BEN
NylasEnv.packages.deactivatePackages();
NylasEnv.menu.template = [];
AppEnv.packages.deactivatePackages();
AppEnv.menu.template = [];
if (!window.debugContent) {
document.getElementById('jasmine-content').innerHTML = '';
}
ReactTestUtils.unmountAll();
jasmine.unspy(NylasEnv, 'saveSync');
jasmine.unspy(AppEnv, 'saveSync');
self.ensureNoPathSubscriptions();
NylasEnv.styles.restoreSnapshot(styleElementsToRestore);
AppEnv.styles.restoreSnapshot(styleElementsToRestore);
this.removeAllSpies();
if (TaskQueue._queue.length > 0) {

View file

@ -27,7 +27,7 @@ class MasterBeforeEach {
toHaveLength: jasmineExtensions.toHaveLength,
});
self._resetNylasEnv();
self._resetAppEnv();
self._resetDatabase();
self._resetTaskQueue();
self._resetTimeOverride();
@ -41,14 +41,14 @@ class MasterBeforeEach {
});
}
_resetNylasEnv() {
NylasEnv.workspaceViewParentSelector = '#jasmine-content';
_resetAppEnv() {
AppEnv.workspaceViewParentSelector = '#jasmine-content';
// Don't actually write to disk
spyOn(NylasEnv, 'saveSync');
spyOn(AppEnv, 'saveSync');
// prevent specs from modifying N1's menus
spyOn(NylasEnv.menu, 'sendToBrowserProcess');
spyOn(AppEnv.menu, 'sendToBrowserProcess');
FocusedPerspectiveStore._current = MailboxPerspective.forNothing();
@ -70,7 +70,7 @@ class MasterBeforeEach {
//
// @_query("BEGIN IMMEDIATE TRANSACTION") never resolves because
// DatabaseStore._query never runs because the @_open flag is always
// false because we never setup the DB when `NylasEnv.inSpecMode` is
// false because we never setup the DB when `AppEnv.inSpecMode` is
// true.
spyOn(DatabaseStore, '_query').andCallFake(() => Promise.resolve([]));
}
@ -132,8 +132,8 @@ class MasterBeforeEach {
return this.load();
});
NylasEnv.config = new Config();
NylasEnv.loadConfig();
AppEnv.config = new Config();
AppEnv.loadConfig();
}
_resetClipboard() {

View file

@ -19,7 +19,7 @@ class N1SpecRunner {
this.loadSettings = loadSettings;
this._extendGlobalWindow();
this._setupJasmine();
this._setupNylasEnv();
this._setupAppEnv();
this._setupWindow();
Object.assign(ReactTestUtils, reactTestUtilsExtensions);
MasterBeforeEach.setup(this.loadSettings, window.beforeEach);
@ -103,25 +103,25 @@ class N1SpecRunner {
require('jasmine-json');
}
_setupNylasEnv() {
_setupAppEnv() {
// We need to mock the config even before `beforeEach` runs because it
// gets accessed on module definitions
const fakePersistedConfig = { env: 'production' };
NylasEnv.config = new Config();
NylasEnv.config.settings = fakePersistedConfig;
AppEnv.config = new Config();
AppEnv.config.settings = fakePersistedConfig;
NylasEnv.restoreWindowDimensions();
NylasEnv.themes.loadBaseStylesheets();
NylasEnv.themes.requireStylesheet('../../static/jasmine');
NylasEnv.themes.initialLoadComplete = true;
NylasEnv.keymaps.loadKeymaps();
AppEnv.restoreWindowDimensions();
AppEnv.themes.loadBaseStylesheets();
AppEnv.themes.requireStylesheet('../../static/jasmine');
AppEnv.themes.initialLoadComplete = true;
AppEnv.keymaps.loadKeymaps();
}
_setupWindow() {
window.addEventListener('core:close', () => window.close());
window.addEventListener('beforeunload', () => {
NylasEnv.storeWindowDimensions();
return NylasEnv.saveSync();
AppEnv.storeWindowDimensions();
return AppEnv.saveSync();
});
}
@ -129,7 +129,7 @@ class N1SpecRunner {
const timeReporter = new TimeReporter();
const consoleReporter = new ConsoleReporter();
const loadSettings = NylasEnv.getLoadSettings();
const loadSettings = AppEnv.getLoadSettings();
if (loadSettings.jUnitXmlPath) {
// jasmine-reporters extends the jasmine global with methods, so needs to
@ -145,7 +145,7 @@ class N1SpecRunner {
if (loadSettings.showSpecsInWindow) {
this.jasmineEnv.addReporter(N1GuiReporter);
NylasEnv.show();
AppEnv.show();
} else {
// this package's dep `jasmine-focused` also adds methods to the
// `jasmine` global

View file

@ -4,13 +4,13 @@
// do fancy things like handle exceptions inside promise blocks
import '../../src/promise-extensions';
import NylasEnvConstructor from '../../src/nylas-env';
window.NylasEnv = NylasEnvConstructor.loadOrCreate();
import AppEnvConstructor from '../../src/nylas-env';
window.AppEnv = AppEnvConstructor.loadOrCreate();
NylasEnv.initialize();
const loadSettings = NylasEnv.getLoadSettings();
AppEnv.initialize();
const loadSettings = AppEnv.getLoadSettings();
// This must be `required` instead of imported because
// NylasEnv.initialize() must complete before `nylas-exports` and other
// AppEnv.initialize() must complete before `nylas-exports` and other
// globals are available for import via es6 modules.
require('./n1-spec-runner').default.runSpecs(loadSettings);

View file

@ -10,9 +10,9 @@ export default class N1TerminalReporter extends TerminalReporter {
},
onComplete(runner) {
if (runner.results().failedCount > 0) {
return NylasEnv.exit(1);
return AppEnv.exit(1);
}
return NylasEnv.exit(0);
return AppEnv.exit(0);
},
});
super(options);

View file

@ -6,7 +6,7 @@ ReactTestUtils = require('react-dom/test-utils')
NylasTestUtils =
loadKeymap: (path) =>
NylasEnv.keymaps.loadKeymap(path)
AppEnv.keymaps.loadKeymap(path)
simulateCommand: (target, command) =>
target.dispatchEvent(new CustomEvent(command, {bubbles: true}))

View file

@ -10,7 +10,7 @@ AccountStore = require('../../src/flux/stores/account-store').default
xdescribe "ContactStore", ->
beforeEach ->
spyOn(NylasEnv, "isMainWindow").andReturn true
spyOn(AppEnv, "isMainWindow").andReturn true
ContactStore._contactCache = []
ContactStore._fetchOffset = 0
ContactStore._accountId = null

View file

@ -29,7 +29,7 @@ xdescribe('DraftStore', function draftStore() {
this.fakeThread = new Thread({ id: 'fake-thread', headerMessageId: 'fake-thread' });
this.fakeMessage = new Message({ id: 'fake-message', headerMessageId: 'fake-message' });
spyOn(NylasEnv, 'newWindow').andCallFake(() => {});
spyOn(AppEnv, 'newWindow').andCallFake(() => {});
spyOn(DatabaseWriter.prototype, 'persistModel').andReturn(Promise.resolve());
spyOn(DatabaseStore, 'run').andCallFake(query => {
if (query._klass === Thread) {
@ -139,7 +139,7 @@ xdescribe('DraftStore', function draftStore() {
return DatabaseWriter.prototype.persistModel.callCount > 0;
});
runs(() => {
expect(NylasEnv.newWindow).toHaveBeenCalledWith({
expect(AppEnv.newWindow).toHaveBeenCalledWith({
title: 'Message',
hidden: true,
windowKey: `composer-A`,
@ -161,7 +161,7 @@ xdescribe('DraftStore', function draftStore() {
return DatabaseWriter.prototype.persistModel.callCount > 0;
});
runs(() => {
expect(NylasEnv.newWindow).toHaveBeenCalledWith({
expect(AppEnv.newWindow).toHaveBeenCalledWith({
title: 'Message',
hidden: true,
windowKey: `composer-A`,
@ -214,17 +214,17 @@ xdescribe('DraftStore', function draftStore() {
});
it("should close the window if it's a popout", () => {
spyOn(NylasEnv, 'close');
spyOn(NylasEnv, 'isComposerWindow').andReturn(true);
spyOn(AppEnv, 'close');
spyOn(AppEnv, 'isComposerWindow').andReturn(true);
DraftStore._onDestroyDraft('abc');
expect(NylasEnv.close).toHaveBeenCalled();
expect(AppEnv.close).toHaveBeenCalled();
});
it("should NOT close the window if isn't a popout", () => {
spyOn(NylasEnv, 'close');
spyOn(NylasEnv, 'isComposerWindow').andReturn(false);
spyOn(AppEnv, 'close');
spyOn(AppEnv, 'isComposerWindow').andReturn(false);
DraftStore._onDestroyDraft('abc');
expect(NylasEnv.close).not.toHaveBeenCalled();
expect(AppEnv.close).not.toHaveBeenCalled();
});
});
@ -286,7 +286,7 @@ xdescribe('DraftStore', function draftStore() {
};
});
it('should still wait one tick before firing NylasEnv.close again', () => {
it('should still wait one tick before firing AppEnv.close again', () => {
const callback = jasmine.createSpy('callback');
expect(DraftStore._onBeforeUnload(callback)).toBe(false);
expect(callback).not.toHaveBeenCalled();
@ -341,23 +341,23 @@ xdescribe('DraftStore', function draftStore() {
});
it('plays a sound immediately when sending draft', () => {
spyOn(NylasEnv.config, 'get').andReturn(true);
spyOn(AppEnv.config, 'get').andReturn(true);
DraftStore._onSendDraft(this.draft.headerMessageId);
advanceClock();
expect(NylasEnv.config.get).toHaveBeenCalledWith('core.sending.sounds');
expect(AppEnv.config.get).toHaveBeenCalledWith('core.sending.sounds');
expect(SoundRegistry.playSound).toHaveBeenCalledWith('hit-send');
});
it("doesn't plays a sound if the setting is off", () => {
spyOn(NylasEnv.config, 'get').andReturn(false);
spyOn(AppEnv.config, 'get').andReturn(false);
DraftStore._onSendDraft(this.draft.headerMessageId);
advanceClock();
expect(NylasEnv.config.get).toHaveBeenCalledWith('core.sending.sounds');
expect(AppEnv.config.get).toHaveBeenCalledWith('core.sending.sounds');
expect(SoundRegistry.playSound).not.toHaveBeenCalled();
});
it('sets the sending state when sending', () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
DraftStore._onSendDraft(this.draft.headerMessageId);
advanceClock();
expect(DraftStore.isSendingDraft(this.draft.headerMessageId)).toBe(true);
@ -367,7 +367,7 @@ xdescribe('DraftStore', function draftStore() {
// no view of the draft renders the draft as if its sending, but with
// the wrong text.
it('does NOT trigger until the latest changes have been applied', () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
runs(() => {
DraftStore._onSendDraft(this.draft.headerMessageId);
expect(DraftStore.trigger).not.toHaveBeenCalled();
@ -391,36 +391,36 @@ xdescribe('DraftStore', function draftStore() {
});
it("returns false if the draft hasn't been seen", () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
expect(DraftStore.isSendingDraft(this.draft.headerMessageId)).toBe(false);
});
it("closes the window if it's a popout", () => {
spyOn(NylasEnv, 'getWindowType').andReturn('composer');
spyOn(NylasEnv, 'isMainWindow').andReturn(false);
spyOn(NylasEnv, 'close');
spyOn(AppEnv, 'getWindowType').andReturn('composer');
spyOn(AppEnv, 'isMainWindow').andReturn(false);
spyOn(AppEnv, 'close');
runs(() => {
return DraftStore._onSendDraft(this.draft.headerMessageId);
});
waitsFor('N1 to close', () => NylasEnv.close.calls.length > 0);
waitsFor('N1 to close', () => AppEnv.close.calls.length > 0);
});
it("doesn't close the window if it's inline", () => {
spyOn(NylasEnv, 'getWindowType').andReturn('other');
spyOn(NylasEnv, 'isMainWindow').andReturn(false);
spyOn(NylasEnv, 'close');
spyOn(NylasEnv, 'isComposerWindow').andCallThrough();
spyOn(AppEnv, 'getWindowType').andReturn('other');
spyOn(AppEnv, 'isMainWindow').andReturn(false);
spyOn(AppEnv, 'close');
spyOn(AppEnv, 'isComposerWindow').andCallThrough();
runs(() => {
DraftStore._onSendDraft(this.draft.headerMessageId);
});
waitsFor(() => NylasEnv.isComposerWindow.calls.length > 0);
waitsFor(() => AppEnv.isComposerWindow.calls.length > 0);
runs(() => {
expect(NylasEnv.close).not.toHaveBeenCalled();
expect(AppEnv.close).not.toHaveBeenCalled();
});
});
it("resets the sending state if there's an error", () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(false);
spyOn(AppEnv, 'isMainWindow').andReturn(false);
DraftStore._draftsSending[this.draft.headerMessageId] = true;
Actions.draftDeliveryFailed({
errorMessage: 'boohoo',
@ -431,7 +431,7 @@ xdescribe('DraftStore', function draftStore() {
});
it("displays a popup in the main window if there's an error", () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
spyOn(FocusedContentStore, 'focused').andReturn({ id: 't1' });
spyOn(remote.dialog, 'showMessageBox');
spyOn(Actions, 'composePopoutDraft');
@ -451,7 +451,7 @@ xdescribe('DraftStore', function draftStore() {
});
it("re-opens the draft if you're not looking at the thread", () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
spyOn(FocusedContentStore, 'focused').andReturn({ id: 't1' });
spyOn(Actions, 'composePopoutDraft');
DraftStore._draftsSending[this.draft.headerMessageId] = true;
@ -468,7 +468,7 @@ xdescribe('DraftStore', function draftStore() {
});
it('re-opens the draft if there is no thread id', () => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
spyOn(Actions, 'composePopoutDraft');
DraftStore._draftsSending[this.draft.headerMessageId] = true;
spyOn(FocusedContentStore, 'focused').andReturn(null);
@ -486,7 +486,7 @@ xdescribe('DraftStore', function draftStore() {
describe('session teardown', () => {
beforeEach(() => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
this.draftTeardown = jasmine.createSpy('draft teardown');
this.session = {
headerMessageId: 'abc',
@ -516,7 +516,7 @@ xdescribe('DraftStore', function draftStore() {
describe('mailto handling', () => {
beforeEach(() => {
spyOn(NylasEnv, 'isMainWindow').andReturn(true);
spyOn(AppEnv, 'isMainWindow').andReturn(true);
});
describe('extensions', () => {

View file

@ -36,9 +36,9 @@ describe('FeatureUsageStore', function featureUsageStoreSpec() {
});
it('returns true if no quota is present for the feature', () => {
spyOn(NylasEnv, 'reportError');
spyOn(AppEnv, 'reportError');
expect(FeatureUsageStore._isUsable('unsupported')).toBe(true);
expect(NylasEnv.reportError).toHaveBeenCalled();
expect(AppEnv.reportError).toHaveBeenCalled();
});
});

View file

@ -35,67 +35,67 @@ describe "FocusedPerspectiveStore", ->
spyOn(FocusedPerspectiveStore, '_setPerspective')
it "uses default perspective when no perspective has been saved", ->
NylasEnv.savedState.sidebarAccountIds = undefined
NylasEnv.savedState.perspective = undefined
AppEnv.savedState.sidebarAccountIds = undefined
AppEnv.savedState.perspective = undefined
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(@default, @default.accountIds)
it "uses default if the saved perspective has account ids no longer present", ->
NylasEnv.savedState.sidebarAccountIds = [1, 2, 3]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1, 2, 3]
AppEnv.savedState.perspective =
accountIds: [1, 2, 3],
categories: => [{accountId: 1, id: 'A'}],
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(@default, @default.accountIds)
NylasEnv.savedState.sidebarAccountIds = [1, 2, 3]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1, 2, 3]
AppEnv.savedState.perspective =
accountIds: [3]
categories: => [{accountId: 3, id: 'A'}]
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(@default, @default.accountIds)
it "uses default if the saved perspective has category ids no longer present", ->
NylasEnv.savedState.sidebarAccountIds = [2]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [2]
AppEnv.savedState.perspective =
accountIds: [2]
categories: => [{accountId: 2, id: 'C'}]
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(@default, @default.accountIds)
it "does not honor sidebarAccountIds if it includes account ids no longer present", ->
NylasEnv.savedState.sidebarAccountIds = [1, 2, 3]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1, 2, 3]
AppEnv.savedState.perspective =
accountIds: [1]
categories: => [{accountId: 1, id: 'A'}]
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(NylasEnv.savedState.perspective, [1])
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(AppEnv.savedState.perspective, [1])
it "uses the saved perspective if it is still valid", ->
NylasEnv.savedState.sidebarAccountIds = [1, 2]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1, 2]
AppEnv.savedState.perspective =
accountIds: [1, 2]
categories: => [{accountId: 1, id: 'A'}]
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(NylasEnv.savedState.perspective, [1, 2])
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(AppEnv.savedState.perspective, [1, 2])
NylasEnv.savedState.sidebarAccountIds = [1, 2]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1, 2]
AppEnv.savedState.perspective =
accountIds: [1]
categories: => []
type: 'DraftsMailboxPerspective'
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(NylasEnv.savedState.perspective, [1, 2])
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(AppEnv.savedState.perspective, [1, 2])
NylasEnv.savedState.sidebarAccountIds = [1]
NylasEnv.savedState.perspective =
AppEnv.savedState.sidebarAccountIds = [1]
AppEnv.savedState.perspective =
accountIds: [1]
categories: => []
type: 'DraftsMailboxPerspective'
FocusedPerspectiveStore._initializeFromSavedState()
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(NylasEnv.savedState.perspective, [1])
expect(FocusedPerspectiveStore._setPerspective).toHaveBeenCalledWith(AppEnv.savedState.perspective, [1])
describe "_onCategoryStoreChanged", ->
it "should try to initialize if the curernt perspective hasn't been fully initialized", ->

View file

@ -27,16 +27,16 @@ describe('IdentityStore', function identityStoreSpec() {
spyOn(KeyManager, 'deletePassword');
spyOn(KeyManager, 'replacePassword');
spyOn(IdentityStore, 'trigger');
spyOn(NylasEnv.config, 'set');
spyOn(NylasEnv.config, 'unset');
spyOn(AppEnv.config, 'set');
spyOn(AppEnv.config, 'unset');
});
it('clears passwords if unsetting', async () => {
IdentityStore.saveIdentity(null);
expect(KeyManager.deletePassword).toHaveBeenCalled();
expect(KeyManager.replacePassword).not.toHaveBeenCalled();
expect(NylasEnv.config.set).toHaveBeenCalled();
const ident = NylasEnv.config.set.calls[0].args[1];
expect(AppEnv.config.set).toHaveBeenCalled();
const ident = AppEnv.config.set.calls[0].args[1];
expect(ident).toBe(null);
});
@ -76,7 +76,7 @@ describe('IdentityStore', function identityStoreSpec() {
beforeEach(() => {
IdentityStore._identity = this.identityJSON;
spyOn(IdentityStore, 'saveIdentity');
spyOn(NylasEnv, 'reportError');
spyOn(AppEnv, 'reportError');
spyOn(console, 'error');
});
@ -93,7 +93,7 @@ describe('IdentityStore', function identityStoreSpec() {
expect(IdentityStore.saveIdentity).toHaveBeenCalled();
const newIdent = IdentityStore.saveIdentity.calls[0].args[0];
expect(newIdent.featureUsage.feat.quota).toBe(5);
expect(NylasEnv.reportError).not.toHaveBeenCalled();
expect(AppEnv.reportError).not.toHaveBeenCalled();
});
it('errors if the json is invalid', async () => {
@ -101,7 +101,7 @@ describe('IdentityStore', function identityStoreSpec() {
return Promise.resolve({});
});
await IdentityStore.fetchIdentity();
expect(NylasEnv.reportError).toHaveBeenCalled();
expect(AppEnv.reportError).toHaveBeenCalled();
expect(IdentityStore.saveIdentity).not.toHaveBeenCalled();
});
@ -112,7 +112,7 @@ describe('IdentityStore', function identityStoreSpec() {
return Promise.resolve(resp);
});
await IdentityStore.fetchIdentity();
expect(NylasEnv.reportError).toHaveBeenCalled();
expect(AppEnv.reportError).toHaveBeenCalled();
expect(IdentityStore.saveIdentity).not.toHaveBeenCalled();
});
});

Some files were not shown because too many files have changed in this diff Show more