mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
d3dcf89e9f
Summary: This commit adds the ability to perform event search in the calendar window. To achieve this, SearchBar has been moved from the thread-search package to be a part of the nylas-component-kit, and reused by both thread-search and nylas-calendar When an event is selected from search results, the calendar view is moved to the selected event. Depends on D3396 to open the event popover. Test Plan: Manual Reviewers: halla, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D3424
68 lines
2 KiB
JavaScript
68 lines
2 KiB
JavaScript
import {exec} from 'child_process';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import {WorkspaceStore, ComponentRegistry} from 'nylas-exports';
|
|
import CalendarWrapper from './calendar-wrapper';
|
|
import QuickEventButton from './quick-event-button';
|
|
|
|
|
|
function resolveHelperPath(callback) {
|
|
const resourcesPath = NylasEnv.getLoadSettings().resourcePath;
|
|
let pathToCalendarApp = path.join(resourcesPath, '..', 'Nylas Calendar.app');
|
|
|
|
fs.exists(pathToCalendarApp, (exists) => {
|
|
if (exists) {
|
|
callback(pathToCalendarApp);
|
|
return;
|
|
}
|
|
|
|
pathToCalendarApp = path.join(resourcesPath, 'build', 'resources', 'mac', 'Nylas Calendar.app');
|
|
fs.exists(pathToCalendarApp, (fallbackExists) => {
|
|
if (fallbackExists) {
|
|
callback(pathToCalendarApp);
|
|
return;
|
|
}
|
|
callback(null);
|
|
});
|
|
});
|
|
}
|
|
|
|
export function activate() {
|
|
WorkspaceStore.defineSheet('Main', {root: true}, {list: ['Center']});
|
|
|
|
if (process.platform === 'darwin') {
|
|
resolveHelperPath((helperPath) => {
|
|
if (!helperPath) {
|
|
return;
|
|
}
|
|
|
|
exec(`chmod +x "${helperPath}/Contents/MacOS/Nylas Calendar"`, () => {
|
|
exec(`open "${helperPath}"`);
|
|
});
|
|
|
|
if (!NylasEnv.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);
|
|
exec(`killall Dock`);
|
|
});
|
|
}
|
|
});
|
|
|
|
NylasEnv.onBeforeUnload(() => {
|
|
exec('killall "Nylas Calendar"');
|
|
return true;
|
|
});
|
|
}
|
|
|
|
ComponentRegistry.register(CalendarWrapper, {
|
|
location: WorkspaceStore.Location.Center,
|
|
});
|
|
ComponentRegistry.register(QuickEventButton, {
|
|
location: WorkspaceStore.Location.Center.Toolbar,
|
|
});
|
|
}
|
|
|
|
export function deactivate() {
|
|
ComponentRegistry.unregister(CalendarWrapper);
|
|
ComponentRegistry.unregister(QuickEventButton);
|
|
}
|