-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use IPC to invoke task scheduling from renderer
- Loading branch information
Showing
6 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Electron Main", | ||
"program": "${workspaceFolder}/main/index.js", | ||
"request": "launch", | ||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"type": "pwa-node" | ||
}, | ||
{ | ||
"name": "Debug Jest Tests", | ||
"type": "node", | ||
"request": "launch", | ||
"runtimeArgs": [ | ||
"--inspect-brk", | ||
"${workspaceRoot}/node_modules/.bin/jest", | ||
"--runInBand", | ||
"--detectOpenHandles" | ||
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"port": 9229 | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { dialog } = require('electron') | ||
|
||
const scheduleAutorun = async ({ | ||
targetWindow, | ||
dialogTitle = 'Do you want OONI Probe to run automatically every day?', | ||
dialogMessage = 'OONI Probe can run tests everyday and ...', | ||
btnYes = 'Yes', | ||
btnNo = 'No' | ||
}) => { | ||
const { response } = await dialog.showMessageBox(targetWindow, { | ||
type: 'question', | ||
title: dialogTitle, | ||
message: dialogMessage, | ||
buttons: [btnNo, btnYes] | ||
}) | ||
if (response === 1) { | ||
const autorunTask = require('./task') | ||
autorunTask.create() | ||
} | ||
} | ||
|
||
module.exports = scheduleAutorun |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useCallback } from 'react' | ||
import { ipcRenderer } from 'electron' | ||
import { useIntl } from 'react-intl' | ||
import { Box, Button } from 'ooni-components' | ||
|
||
const SetupAutorun = () => { | ||
const intl = useIntl() | ||
const onClick = useCallback(() => { | ||
ipcRenderer.send('autorun.schedule', { | ||
dialogTitle: intl.formatMessage({ id: 'Settings.Autorun.Title' }), | ||
dialogMessage: intl.formatMessage({ id: 'Settings.Autorun.Message' }), | ||
btnYes: intl.formatMessage({ id: 'Settings.Autorun.Button.Yes' }), | ||
btnNo: intl.formatMessage({ id: 'Settings.Autorun.Button.No' }), | ||
}) | ||
}) | ||
return ( | ||
<Box> | ||
<Button onClick={onClick}> | ||
{intl.formatMessage({ id: 'Settings.Autorun.Button.Label' })} | ||
</Button> | ||
</Box> | ||
) | ||
} | ||
|
||
export default SetupAutorun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters