mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 11:16:10 +08:00
Remove “Toggle Localizer Tools”, encourage folks to submit PRs instead
This commit is contained in:
parent
7a11432b18
commit
190fb561fd
6 changed files with 0 additions and 208 deletions
Binary file not shown.
Before Width: | Height: | Size: 488 B |
|
@ -1,188 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
localized,
|
|
||||||
MailspringAPIRequest,
|
|
||||||
WorkspaceStore,
|
|
||||||
ComponentRegistry,
|
|
||||||
} from 'mailspring-exports';
|
|
||||||
import { remote } from 'electron';
|
|
||||||
|
|
||||||
class SubmitLocalizationsBar extends React.Component {
|
|
||||||
static displayName = 'SubmitLocalizationsBar';
|
|
||||||
|
|
||||||
state = {
|
|
||||||
current: '',
|
|
||||||
suggestion: '',
|
|
||||||
selecting: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
document.removeEventListener('click', this.onSelectionBogusClick, true);
|
|
||||||
document.removeEventListener('mousedown', this.onSelectionMouseDown);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit = async () => {
|
|
||||||
const { current, suggestion } = this.state;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { status } = await MailspringAPIRequest.makeRequest({
|
|
||||||
server: 'identity',
|
|
||||||
method: 'POST',
|
|
||||||
body: { current, suggestion, language: window.navigator.language },
|
|
||||||
path: '/api/localization-suggestion',
|
|
||||||
json: true,
|
|
||||||
});
|
|
||||||
if (status === 'success') {
|
|
||||||
remote.dialog.showMessageBoxSync({
|
|
||||||
type: 'info',
|
|
||||||
buttons: [localized('OK')],
|
|
||||||
message: localized('Thank you!'),
|
|
||||||
title: localized('Thank you!'),
|
|
||||||
detail: localized(
|
|
||||||
`Your updated localization will be reviewed and included in a future version of Mailspring.`
|
|
||||||
),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
AppEnv.showErrorDialog(err.toString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onSelectionBogusClick = event => {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
document.removeEventListener('click', this.onSelectionBogusClick, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
onSelectionMouseDown = event => {
|
|
||||||
let text = null;
|
|
||||||
const element = document.elementFromPoint(event.clientX, event.clientY) as any;
|
|
||||||
|
|
||||||
if (element) {
|
|
||||||
if (element.nodeName === 'INPUT') {
|
|
||||||
if (element.value) {
|
|
||||||
text = element.value;
|
|
||||||
} else {
|
|
||||||
text = element.placeholder;
|
|
||||||
}
|
|
||||||
} else if (element.innerText.length > 0) {
|
|
||||||
text = element.innerText;
|
|
||||||
} else {
|
|
||||||
const parent = element.closest('[title]');
|
|
||||||
text = parent ? parent.title : '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
document.removeEventListener('mousedown', this.onSelectionMouseDown);
|
|
||||||
if (text && text.length) {
|
|
||||||
this.setState({ selecting: false, current: text, suggestion: text });
|
|
||||||
} else {
|
|
||||||
this.setState({ selecting: false });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onToggleSelectionMode = () => {
|
|
||||||
if (this.state.selecting) {
|
|
||||||
document.removeEventListener('mousedown', this.onSelectionMouseDown);
|
|
||||||
document.removeEventListener('click', this.onSelectionBogusClick, true);
|
|
||||||
this.setState({ selecting: false });
|
|
||||||
} else {
|
|
||||||
document.addEventListener('mousedown', this.onSelectionMouseDown);
|
|
||||||
document.addEventListener('click', this.onSelectionBogusClick, true);
|
|
||||||
this.setState({ selecting: true });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { selecting, current, suggestion } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ background: 'moccasin' }}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
height: 40,
|
|
||||||
padding: 10,
|
|
||||||
borderTop: `1px solid rgba(0,0,0,0.1)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span style={{ marginRight: 10, flex: 1, fontWeight: 500 }}>
|
|
||||||
{localized('Submit Improved Localizations')}
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
className="btn"
|
|
||||||
style={selecting ? { border: '1px solid black' } : {}}
|
|
||||||
onClick={this.onToggleSelectionMode}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="icon"
|
|
||||||
src={'mailspring://localizer-help/assets/choose-element.png'}
|
|
||||||
style={{ width: 13 }}
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
value={current}
|
|
||||||
placeholder={localized('Existing')}
|
|
||||||
onChange={e => this.setState({ current: e.target.value })}
|
|
||||||
/>
|
|
||||||
<span style={{ margin: 10 }}>=</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
value={suggestion}
|
|
||||||
placeholder={`${localized('Localized')} (${window.navigator.language})`}
|
|
||||||
onChange={e => this.setState({ suggestion: e.target.value })}
|
|
||||||
/>
|
|
||||||
<button onClick={this.onSubmit} className="btn" type="submit" style={{ marginLeft: 10 }}>
|
|
||||||
{localized('Submit')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
borderTop: `1px solid rgba(0,0,0,0.1)`,
|
|
||||||
fontSize: '0.9em',
|
|
||||||
padding: 10,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span style={{ marginRight: 10 }}>
|
|
||||||
{localized(
|
|
||||||
'Have a GitHub account? Want to contibute many translations? Contribute directly via a Pull Request!'
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<a href="https://github.com/Foundry376/Mailspring/blob/master/LOCALIZATION.md">
|
|
||||||
Learn More
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let visible = false;
|
|
||||||
|
|
||||||
export function activate() {
|
|
||||||
AppEnv.commands.add(document.body, 'window:toggle-localizer-tools', () => {
|
|
||||||
if (!visible) {
|
|
||||||
ComponentRegistry.register(SubmitLocalizationsBar, {
|
|
||||||
location: WorkspaceStore.Sheet.Global.Footer,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ComponentRegistry.unregister(SubmitLocalizationsBar);
|
|
||||||
}
|
|
||||||
|
|
||||||
visible = !visible;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deactivate() {
|
|
||||||
if (visible) {
|
|
||||||
ComponentRegistry.unregister(SubmitLocalizationsBar);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"name": "localizer-help",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"main": "./lib/main",
|
|
||||||
|
|
||||||
"isOptional": true,
|
|
||||||
"isHiddenOnPluginsPage": true,
|
|
||||||
|
|
||||||
"title": "Localizer Helper",
|
|
||||||
"description": "Allows localizers to click UI elements and suggest localizations inline.",
|
|
||||||
"icon": "./icon.png",
|
|
||||||
|
|
||||||
"license": "GPL-3.0",
|
|
||||||
"engines": {
|
|
||||||
"mailspring": "*"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -212,7 +212,6 @@ module.exports = {
|
||||||
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: localized('Reload'), command: 'window:reload' },
|
{ label: localized('Reload'), command: 'window:reload' },
|
||||||
{ label: localized('Toggle Localizer Tools'), command: 'window:toggle-localizer-tools' },
|
|
||||||
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
||||||
{
|
{
|
||||||
label: localized('Toggle Component Regions'),
|
label: localized('Toggle Component Regions'),
|
||||||
|
|
|
@ -181,7 +181,6 @@ module.exports = {
|
||||||
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: localized('Reload'), command: 'window:reload' },
|
{ label: localized('Reload'), command: 'window:reload' },
|
||||||
{ label: localized('Toggle Localizer Tools'), command: 'window:toggle-localizer-tools' },
|
|
||||||
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
||||||
{
|
{
|
||||||
label: localized('Toggle Component Regions'),
|
label: localized('Toggle Component Regions'),
|
||||||
|
|
|
@ -158,7 +158,6 @@ module.exports = {
|
||||||
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
{ label: localized('Install a Plugin') + '...', command: 'window:install-package' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: localized('Reload'), command: 'window:reload' },
|
{ label: localized('Reload'), command: 'window:reload' },
|
||||||
{ label: localized('Toggle Localizer Tools'), command: 'window:toggle-localizer-tools' },
|
|
||||||
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
{ label: localized('Toggle Developer Tools'), command: 'window:toggle-dev-tools' },
|
||||||
{
|
{
|
||||||
label: localized('Toggle Component Regions'),
|
label: localized('Toggle Component Regions'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue