mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Cleanup settings-web (#280)
This commit is contained in:
committed by
Bartosz Sosnowski
parent
5f5402aa0a
commit
ffa1b1e6a3
@@ -1,25 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<script>
|
|
||||||
window.output_from_webview = function(arg) {
|
|
||||||
if (typeof (window.external) !== 'undefined' && ('notify' in window.external)) {
|
|
||||||
window.external.notify(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function receive_from_settings_app(arg) {
|
|
||||||
window.react_app_component.receive_config_msg(JSON.parse(arg));
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
function exit_settings_app() {
|
|
||||||
window.react_app_component.receive_exit_request();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<title>PowerToys Settings</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script src="dist/bundle.js" charset="UTF-8"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -2,21 +2,21 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
window.output_from_webview = function(arg) {
|
window.output_from_webview = function(arg) {
|
||||||
if (typeof (window.external) !== 'undefined' && ('notify' in window.external)) {
|
if (typeof (window.external) !== 'undefined' && ('notify' in window.external)) {
|
||||||
window.external.notify(arg);
|
window.external.notify(arg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function receive_from_settings_app(arg) {
|
}
|
||||||
window.react_app_component.receive_config_msg(JSON.parse(arg));
|
function receive_from_settings_app(arg) {
|
||||||
return "";
|
window.react_app_component.receive_config_msg(JSON.parse(arg));
|
||||||
}
|
return '';
|
||||||
function exit_settings_app() {
|
}
|
||||||
window.react_app_component.receive_exit_request();
|
function exit_settings_app() {
|
||||||
return "";
|
window.react_app_component.receive_exit_request();
|
||||||
}
|
return '';
|
||||||
</script>
|
}
|
||||||
<title>PowerToys Settings</title>
|
</script>
|
||||||
|
<title>PowerToys Settings</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -10,4 +10,3 @@ export class BaseSettingsControl extends React.Component <any, any> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export class BoolToggleSettingsControl extends BaseSettingsControl {
|
|||||||
this.setState({ property_values: props.setting })
|
this.setState({ property_values: props.setting })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public get_value() : any {
|
public get_value() : any {
|
||||||
return {value: this.toggleref.checked};
|
return {value: this.toggleref.checked};
|
||||||
}
|
}
|
||||||
@@ -26,9 +25,9 @@ export class BoolToggleSettingsControl extends BaseSettingsControl {
|
|||||||
return (
|
return (
|
||||||
<Toggle
|
<Toggle
|
||||||
onChange={
|
onChange={
|
||||||
(_event,_check) => {
|
(_event,_check) => {
|
||||||
this.setState( (prev_state:any) => ({
|
this.setState( (prev_state:any) => ({
|
||||||
property_values: {
|
property_values: {
|
||||||
...(prev_state.property_values),
|
...(prev_state.property_values),
|
||||||
value: _check
|
value: _check
|
||||||
}
|
}
|
||||||
@@ -45,5 +44,4 @@ export class BoolToggleSettingsControl extends BaseSettingsControl {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,5 +41,4 @@ export class ColorPickerSettingsControl extends BaseSettingsControl {
|
|||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ export class CustomSettingsScreen extends React.Component <any, any> {
|
|||||||
powertoy: props.powertoy,
|
powertoy: props.powertoy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shouldComponentUpdate(nextProps:any, nextState:any)
|
|
||||||
{
|
shouldComponentUpdate(nextProps:any, nextState:any) {
|
||||||
// This component and its children manage their state.
|
// This component and its children manage their state.
|
||||||
// React only to state changes when forceUpdate is called by the App component.
|
// React only to state changes when forceUpdate is called by the App component.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props: any) {
|
componentWillReceiveProps(props: any) {
|
||||||
this.setState({ powertoy: props.powertoy })
|
this.setState({ powertoy: props.powertoy })
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,7 @@ export class CustomSettingsScreen extends React.Component <any, any> {
|
|||||||
(power_toys_properties[b].order || 0)
|
(power_toys_properties[b].order || 0)
|
||||||
)
|
)
|
||||||
}).
|
}).
|
||||||
map( (key) => {
|
map((key) => {
|
||||||
switch(power_toys_properties[key].editor_type) {
|
switch(power_toys_properties[key].editor_type) {
|
||||||
case 'bool_toggle':
|
case 'bool_toggle':
|
||||||
return <BoolToggleSettingsControl
|
return <BoolToggleSettingsControl
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ export class GeneralSettings extends React.Component <any, any> {
|
|||||||
settings: props.settings,
|
settings: props.settings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shouldComponentUpdate(nextProps:any, nextState:any)
|
|
||||||
{
|
shouldComponentUpdate(nextProps:any, nextState:any) {
|
||||||
// This component and its children manage their state.
|
// This component and its children manage their state.
|
||||||
// React only to state changes when forceUpdate is called by the App component.
|
// React only to state changes when forceUpdate is called by the App component.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props: any) {
|
componentWillReceiveProps(props: any) {
|
||||||
this.setState({ settings: props.settings })
|
this.setState({ settings: props.settings })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class IntSpinnerSettingsControl extends BaseSettingsControl {
|
|||||||
value=String(this.spinbuttonref.props.max);
|
value=String(this.spinbuttonref.props.max);
|
||||||
}
|
}
|
||||||
this.setState( (prev_state:any) => ({
|
this.setState( (prev_state:any) => ({
|
||||||
property_values: {
|
property_values: {
|
||||||
...(prev_state.property_values),
|
...(prev_state.property_values),
|
||||||
value: parseInt(value)
|
value: parseInt(value)
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ export class IntSpinnerSettingsControl extends BaseSettingsControl {
|
|||||||
value = String(+value + this.spinbuttonref.props.step) ;
|
value = String(+value + this.spinbuttonref.props.step) ;
|
||||||
}
|
}
|
||||||
this.setState( (prev_state:any) => ({
|
this.setState( (prev_state:any) => ({
|
||||||
property_values: {
|
property_values: {
|
||||||
...(prev_state.property_values),
|
...(prev_state.property_values),
|
||||||
value: parseInt(value)
|
value: parseInt(value)
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ export class IntSpinnerSettingsControl extends BaseSettingsControl {
|
|||||||
value = String(+value - this.spinbuttonref.props.step) ;
|
value = String(+value - this.spinbuttonref.props.step) ;
|
||||||
}
|
}
|
||||||
this.setState( (prev_state:any) => ({
|
this.setState( (prev_state:any) => ({
|
||||||
property_values: {
|
property_values: {
|
||||||
...(prev_state.property_values),
|
...(prev_state.property_values),
|
||||||
value: parseInt(value)
|
value: parseInt(value)
|
||||||
}
|
}
|
||||||
@@ -95,5 +95,4 @@ export class IntSpinnerSettingsControl extends BaseSettingsControl {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class StringTextSettingsControl extends BaseSettingsControl {
|
|||||||
property_values: props.setting
|
property_values: props.setting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props: any) {
|
componentWillReceiveProps(props: any) {
|
||||||
// Fully controlled component.
|
// Fully controlled component.
|
||||||
// Reacting to a property change so that the control is redrawn properly.
|
// Reacting to a property change so that the control is redrawn properly.
|
||||||
@@ -48,4 +48,4 @@ export class StringTextSettingsControl extends BaseSettingsControl {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,13 @@ mergeStyles({
|
|||||||
|
|
||||||
const root = document.getElementById('app');
|
const root = document.getElementById('app');
|
||||||
if (root && root.hasChildNodes()) {
|
if (root && root.hasChildNodes()) {
|
||||||
ReactDOM.hydrate(<App
|
ReactDOM.hydrate(<App
|
||||||
ref={(app_component) => {(window as any).react_app_component=app_component;}} // in order to call the app from outside react.
|
ref={(app_component) => {(window as any).react_app_component=app_component;}} // in order to call the app from outside react.
|
||||||
/>,
|
/>,
|
||||||
root);
|
root);
|
||||||
} else {
|
} else {
|
||||||
ReactDOM.render(<App
|
ReactDOM.render(<App
|
||||||
ref={(app_component) => {(window as any).react_app_component=app_component;}} // in order to call the app from outside react.
|
ref={(app_component) => {(window as any).react_app_component=app_component;}} // in order to call the app from outside react.
|
||||||
/>,
|
/>,
|
||||||
root);
|
root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user