Settings: fix broken "Restart as administrator" button (#1733)

This commit is contained in:
Andrey Nekrasov 2020-03-27 17:38:58 +03:00 committed by GitHub
parent 5605256c75
commit 958198b65a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 30 deletions

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import {BaseSettingsControl} from './BaseSettingsControl'; import {BaseSettingsControl} from './BaseSettingsControl';
import {Label, Stack, PrimaryButton, Text } from 'office-ui-fabric-react'; import {Label, Link, Stack, PrimaryButton, Text } from 'office-ui-fabric-react';
export class CustomActionSettingsControl extends BaseSettingsControl { export class CustomActionSettingsControl extends BaseSettingsControl {
colorpickerref:any = null; colorpickerref:any = null;
@ -10,7 +10,6 @@ export class CustomActionSettingsControl extends BaseSettingsControl {
this.colorpickerref = null; this.colorpickerref = null;
this.state={ this.state={
property_values: props.setting, property_values: props.setting,
call_action_callback: props.action_callback,
name: props.action_name name: props.action_name
} }
} }
@ -34,24 +33,31 @@ export class CustomActionSettingsControl extends BaseSettingsControl {
<Label>{this.state.property_values.display_name}</Label> <Label>{this.state.property_values.display_name}</Label>
: null : null
} }
<Stack horizontal tokens={{childrenGap:5}}>
{ {
<Stack horizontal tokens={{childrenGap:5}}> this.state.property_values.value ?
{ <Text styles ={{
this.state.property_values.value ? root: {
<Text styles ={{ paddingBottom: '0.5em'
root: { }
paddingBottom: '0.5em' }}>{this.state.property_values.value}</Text>
} : <span/>
}}>{this.state.property_values.value}</Text>
: <span/>
}
{
this.state.property_values.help_link ?
this.state.property_values.help_link
: <span/>
}
</Stack>
} }
{
this.state.property_values.help_link_url && this.state.property_values.help_link_text ?
<Link
styles = {{
root: {
alignSelf:'center',
paddingBottom: '0.5em'
}
}}
href={ this.state.property_values.help_link_url }
target='_blank'
>{ this.state.property_values.help_link_text }</Link>
: <span/>
}
</Stack>
<PrimaryButton <PrimaryButton
styles={{ styles={{
root: { root: {
@ -59,7 +65,7 @@ export class CustomActionSettingsControl extends BaseSettingsControl {
} }
}} }}
text={this.state.property_values.button_text} text={this.state.property_values.button_text}
onClick={()=>this.state.call_action_callback(this.state.name, this.state.property_values)} onClick={()=>this.props.action_callback(this.state.name, this.state.property_values)}
/> />
</Stack> </Stack>
); );

View File

@ -150,16 +150,8 @@ export class GeneralSettings extends React.Component <any, any> {
display_name: '', display_name: '',
value: 'Running as user. Do you wish to run as administrator instead?', value: 'Running as user. Do you wish to run as administrator instead?',
button_text: 'Restart as administrator', button_text: 'Restart as administrator',
help_link: <Link help_link_url: "https://aka.ms/powertoysDetectedElevatedHelp",
styles = {{ help_link_text: "(Learn more about Admin mode)"
root: {
alignSelf:'center',
paddingBottom: '0.5em'
}
}}
href={"https://aka.ms/powertoysDetectedElevatedHelp"}
target='_blank'
>(Learn more about Admin mode)</Link>
}} }}
action_name={'restart_elevation'} action_name={'restart_elevation'}
action_callback={(action_name: any, value:any) => { action_callback={(action_name: any, value:any) => {

File diff suppressed because one or more lines are too long