mirror of
https://github.com/mue/mue.git
synced 2026-07-24 01:07:23 +02:00
fix: close #245, port various fixes from 7.0
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
"version": "6.0.4",
|
"version": "6.0.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eartharoid/i18n": "^1.0.2",
|
"@eartharoid/i18n": "^1.0.2",
|
||||||
"@emotion/react": "^11.5.0",
|
"@emotion/react": "^11.8.1",
|
||||||
"@emotion/styled": "^11.3.0",
|
"@emotion/styled": "^11.8.1",
|
||||||
"@fontsource/lexend-deca": "4.4.5",
|
"@fontsource/lexend-deca": "4.4.5",
|
||||||
"@fontsource/montserrat": "4.4.5",
|
"@fontsource/montserrat": "4.4.5",
|
||||||
"@mui/icons-material": "5.4.2",
|
"@mui/icons-material": "5.4.2",
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default class Autocomplete extends PureComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnount() {
|
componentWillUnmount() {
|
||||||
EventBus.off('refresh');
|
EventBus.off('refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ export default class AdvancedSettings extends PureComponent {
|
|||||||
|
|
||||||
<h3>{getMessage('modals.main.settings.sections.advanced.customisation')}</h3>
|
<h3>{getMessage('modals.main.settings.sections.advanced.customisation')}</h3>
|
||||||
<Text title={getMessage('modals.main.settings.sections.advanced.tab_name')} name='tabName' default={getMessage('tabname')} category='other'/>
|
<Text title={getMessage('modals.main.settings.sections.advanced.tab_name')} name='tabName' default={getMessage('tabname')} category='other'/>
|
||||||
{window.location.href.startsWith('http://') || window.location.href.startsWith('https://') ?
|
|
||||||
<Text title={getMessage('modals.main.settings.sections.advanced.custom_js')} name='customjs' textarea={true} category='other' element='other'/>
|
|
||||||
: null}
|
|
||||||
<Text title={getMessage('modals.main.settings.sections.advanced.custom_css')} name='customcss' textarea={true} category='other'/>
|
<Text title={getMessage('modals.main.settings.sections.advanced.custom_css')} name='customcss' textarea={true} category='other'/>
|
||||||
|
|
||||||
<h3>{getMessage('modals.main.settings.sections.experimental.title')}</h3>
|
<h3>{getMessage('modals.main.settings.sections.experimental.title')}</h3>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default class OrderSettings extends PureComponent {
|
|||||||
items: JSON.parse(localStorage.getItem('order'))
|
items: JSON.parse(localStorage.getItem('order'))
|
||||||
});
|
});
|
||||||
|
|
||||||
toast(getMessage('toats.reset'));
|
toast(getMessage('toasts.reset'));
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled = (setting) => {
|
enabled = (setting) => {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import Header from '../Header';
|
|||||||
import Checkbox from '../Checkbox';
|
import Checkbox from '../Checkbox';
|
||||||
import Dropdown from '../Dropdown';
|
import Dropdown from '../Dropdown';
|
||||||
|
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
import EventBus from 'modules/helpers/eventbus';
|
||||||
|
|
||||||
export default class QuoteSettings extends PureComponent {
|
export default class QuoteSettings extends PureComponent {
|
||||||
getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export default class QuickLinks extends PureComponent {
|
|||||||
name: '',
|
name: '',
|
||||||
url: '',
|
url: '',
|
||||||
showAddLink: 'hidden',
|
showAddLink: 'hidden',
|
||||||
nameError: '',
|
|
||||||
urlError: ''
|
urlError: ''
|
||||||
};
|
};
|
||||||
this.quicklinksContainer = createRef();
|
this.quicklinksContainer = createRef();
|
||||||
@@ -43,10 +42,7 @@ export default class QuickLinks extends PureComponent {
|
|||||||
const data = JSON.parse(localStorage.getItem('quicklinks'));
|
const data = JSON.parse(localStorage.getItem('quicklinks'));
|
||||||
let url = this.state.url;
|
let url = this.state.url;
|
||||||
|
|
||||||
let nameError, urlError;
|
let urlError;
|
||||||
if (this.state.name.length <= 0) {
|
|
||||||
nameError = this.getMessage('widgets.quicklinks.name_error');
|
|
||||||
}
|
|
||||||
|
|
||||||
// regex: https://ihateregex.io/expr/url/
|
// regex: https://ihateregex.io/expr/url/
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
@@ -54,9 +50,8 @@ export default class QuickLinks extends PureComponent {
|
|||||||
urlError = this.getMessage('widgets.quicklinks.url_error');
|
urlError = this.getMessage('widgets.quicklinks.url_error');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameError || urlError) {
|
if (urlError) {
|
||||||
return this.setState({
|
return this.setState({
|
||||||
nameError,
|
|
||||||
urlError
|
urlError
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -66,7 +61,7 @@ export default class QuickLinks extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.push({
|
data.push({
|
||||||
name: this.state.name,
|
name: this.state.name || url,
|
||||||
url: url,
|
url: url,
|
||||||
icon: this.state.icon || '',
|
icon: this.state.icon || '',
|
||||||
key: Math.random().toString(36).substring(7) + 1
|
key: Math.random().toString(36).substring(7) + 1
|
||||||
@@ -191,7 +186,7 @@ export default class QuickLinks extends PureComponent {
|
|||||||
<div className='topbarquicklinks' onKeyDown={this.topbarEnter}>
|
<div className='topbarquicklinks' onKeyDown={this.topbarEnter}>
|
||||||
<h4>{this.getMessage('widgets.quicklinks.new')}</h4>
|
<h4>{this.getMessage('widgets.quicklinks.new')}</h4>
|
||||||
<TextareaAutosize rowsmax={1} placeholder={this.getMessage('widgets.quicklinks.name')} value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} />
|
<TextareaAutosize rowsmax={1} placeholder={this.getMessage('widgets.quicklinks.name')} value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} />
|
||||||
<p>{this.state.nameError}</p>
|
<p/>
|
||||||
<TextareaAutosize rowsmax={10} placeholder={this.getMessage('widgets.quicklinks.url')} value={this.state.url} onChange={(e) => this.setState({ url: e.target.value })} />
|
<TextareaAutosize rowsmax={10} placeholder={this.getMessage('widgets.quicklinks.url')} value={this.state.url} onChange={(e) => this.setState({ url: e.target.value })} />
|
||||||
<p>{this.state.urlError}</p>
|
<p>{this.state.urlError}</p>
|
||||||
<TextareaAutosize rowsmax={10} placeholder={this.getMessage('widgets.quicklinks.icon')} value={this.state.icon} onChange={(e) => this.setState({ icon: e.target.value })} />
|
<TextareaAutosize rowsmax={10} placeholder={this.getMessage('widgets.quicklinks.icon')} value={this.state.icon} onChange={(e) => this.setState({ icon: e.target.value })} />
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ export default class Clock extends PureComponent {
|
|||||||
switch (localStorage.getItem('timeType')) {
|
switch (localStorage.getItem('timeType')) {
|
||||||
case 'percentageComplete':
|
case 'percentageComplete':
|
||||||
this.setState({
|
this.setState({
|
||||||
time: (now.getHours() / 24).toFixed(2).replace('0.', '') + '%'
|
time: (now.getHours() / 24).toFixed(2).replace('0.', '') + '%',
|
||||||
|
ampm: ''
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'analogue':
|
case 'analogue':
|
||||||
|
|||||||
@@ -110,23 +110,11 @@ export function loadSettings(hotreload) {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything below this either doesn't support hot reload (custom js) or shouldn't run on a hot reload event
|
// everything below this shouldn't run on a hot reload event
|
||||||
if (hotreload === true) {
|
if (hotreload === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.location.href.startsWith('http://') || window.location.href.startsWith('https://')){
|
|
||||||
const js = localStorage.getItem('customjs');
|
|
||||||
if (js) {
|
|
||||||
try {
|
|
||||||
// eslint-disable-next-line no-eval
|
|
||||||
eval(js);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to run custom JS: ', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localStorage.getItem('experimental') === 'true') {
|
if (localStorage.getItem('experimental') === 'true') {
|
||||||
experimentalInit();
|
experimentalInit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import variables from 'modules/variables';
|
import variables from 'modules/variables';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
export function saveFile(data, filename = 'file') {
|
const getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
||||||
|
|
||||||
|
export function saveFile(data, filename = 'file', type = 'text/json') {
|
||||||
if (typeof data === 'object') {
|
if (typeof data === 'object') {
|
||||||
data = JSON.stringify(data, undefined, 4);
|
data = JSON.stringify(data, undefined, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
const blob = new Blob([data], { type: 'text/json' });
|
const blob = new Blob([data], { type });
|
||||||
|
|
||||||
const event = document.createEvent('MouseEvents');
|
const event = document.createEvent('MouseEvents');
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
|
|
||||||
a.href = window.URL.createObjectURL(blob);
|
a.href = window.URL.createObjectURL(blob);
|
||||||
a.download = filename;
|
a.download = filename;
|
||||||
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
|
a.dataset.downloadurl = [type, a.download, a.href].join(':');
|
||||||
|
|
||||||
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||||
a.dispatchEvent(event);
|
a.dispatchEvent(event);
|
||||||
@@ -29,7 +31,6 @@ export function exportSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function importSettings(e) {
|
export function importSettings(e) {
|
||||||
const getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
|
|
||||||
const content = JSON.parse(e.target.result);
|
const content = JSON.parse(e.target.result);
|
||||||
|
|
||||||
Object.keys(content).forEach((key) => {
|
Object.keys(content).forEach((key) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user