-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consent & GetUserFriendlyMessage (#406)
* add consent prompts, toast notifications, get user friendly message, app permissions view, include bootstrap, handle OnAppPermissionChanged, refactor tts controller so HMI can easily queue tts * improve applist header icons * GUFM response.result.messages param may be omitted * replace consumer friendly message variables with proper values * minor styling improvements * remove menu icon from app permissions list * address review comments: data consent before permissions, chain views, activate app once * remove activate app when permissions consent * consumer friendly message tts api parameter is called ttsString * rename AppPermissionList to PermissionAppList to make it more clear that is the list of apps * get revoked app name before waiting for GUFM response (while its still in app list) * reply to TTS Speak correctly even when internal TTS is being used * fixup! rename AppPermissionList to PermissionAppList to make it more clear that is the list of apps fix links to renamed page * handle ActivateApp request parameter level * address review comment: fix warning * address review comment: add comment explaining filePlaylist type REPLY * nullcheck editing permissions app * fix AppPermissionsRevoked tts * handle app unregister while editing permissions * fix AppPermissions prop name typo
- Loading branch information
Showing
23 changed files
with
712 additions
and
154 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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
|
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,66 @@ | ||
.permissionsPopup { | ||
@include display(flex); | ||
@include flex-direction(row); | ||
@include justify-content(space-between); | ||
border: 1px solid #ccc; | ||
overflow: auto; | ||
-webkit-overflow-scrolling: 'touch'; | ||
border-radius: 4px; | ||
outline: none; | ||
width: 90%; | ||
height: 30%; | ||
} | ||
|
||
.permissionsPopup-top { | ||
@include display(flex); | ||
@include justify-content(space-between); | ||
@include flex-direction(column); | ||
padding: 10px; | ||
height: auto; | ||
overflow-y: scroll; | ||
flex-grow: 4; | ||
|
||
h3 { | ||
word-wrap: normal; | ||
} | ||
} | ||
|
||
.permissionsPopup-buttons { | ||
@include display(flex); | ||
@include justify-content(space-around); | ||
@include flex-direction(column); | ||
@include flex-wrap(wrap); | ||
@include align-items(stretch); | ||
padding: 2%; | ||
min-width: 20%; | ||
} | ||
|
||
.permissionsPopup-button { | ||
flex: 1; | ||
max-height: 50px; | ||
height: 40px; | ||
text-align: center; | ||
border-radius: 8px; | ||
border-width: 0.154px; | ||
border-style: solid; | ||
padding: 2%; | ||
width: auto; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
|
||
.permissionsToggle { | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-left: 20px; | ||
margin-right: 20px; | ||
|
||
input { | ||
height: 40px; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,105 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux' | ||
import { withRouter } from 'react-router-dom'; | ||
|
||
import AppHeader from './containers/Header'; | ||
import sdlController from './Controllers/SDLController'; | ||
import { Link } from 'react-router-dom'; | ||
import store from './store'; | ||
import { closePermissionsView, clearAppAwaitingPermissions } from './actions' | ||
|
||
const mapStateToProps = (state) => { | ||
var theme = state.theme | ||
var editingAppID = state.system.editingPermissionsAppId; | ||
var allowedFunctions = state.system.allowedFunctions; | ||
var pendingActivation = state.system.permissionsAppAwaitingActivation; | ||
|
||
return { | ||
theme: theme, | ||
editingAppID: editingAppID, | ||
allowedFunctions: allowedFunctions, | ||
activeLayout: state.ui[editingAppID]?.displayLayout, | ||
appOptions: state.appList, | ||
pendingActivation: pendingActivation | ||
}; | ||
} | ||
|
||
class Permissions extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.toggleFunction = this.toggleFunction.bind(this); | ||
this.savePermissions = this.savePermissions.bind(this); | ||
|
||
this.state = { | ||
allowedFunctions: props.allowedFunctions, | ||
appWasDisconnected: false | ||
} | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (false === this.state.appWasDisconnected && undefined === nextProps.editingAppID) { | ||
this.setState({ appWasDisconnected: true }); | ||
this.props.history.push("/permissionapplist"); | ||
} | ||
} | ||
|
||
toggleFunction(name) { | ||
var functions = [ ...this.state.allowedFunctions ] | ||
for (var f of functions) { | ||
if (f.name === name) { | ||
f.allowed = !f.allowed; | ||
this.setState({ allowedFunctions: functions }); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
savePermissions() { | ||
var allowedFunctions = this.state.allowedFunctions.map((f) => ({ | ||
id: f.id, name: f.name, allowed: f.allowed | ||
})); | ||
sdlController.onAppPermissionConsent(this.props.editingAppID, allowedFunctions); | ||
|
||
if (this.props.pendingActivation === this.props.editingAppID) { | ||
store.dispatch(clearAppAwaitingPermissions()); | ||
} | ||
} | ||
|
||
componentWillUnmount() { | ||
store.dispatch(closePermissionsView()); | ||
} | ||
|
||
render() { | ||
var options =this.state.allowedFunctions.map((f) => ( | ||
<div className="vscrollmenu-item th-b-color th-bb-color-secondary" key={f.id} | ||
onClick={(e) => this.toggleFunction(f.name)} style={{ height: 'auto' }}> | ||
<div className={"vscrollmenu-item__primary th-f-color"}> | ||
<div class="form-check form-switch permissionsToggle"> | ||
<input class="form-check-input" type="checkbox" checked={f.allowed} style={{ width: '5em' }} /> | ||
</div> | ||
<div className={"vscrollmenu-item__name th-f-color"} style={{ marginRight: '2%' }}> | ||
<p class="t-large t-light th-f-color">{f.title || f.name}</p> | ||
<p className="t-small t-light th-f-color-secondary">{f.body}</p> | ||
</div> | ||
</div> | ||
</div> | ||
)); | ||
|
||
return ( | ||
<div> | ||
<AppHeader backLink={'/permissionapplist'} menuName="Back" | ||
icon='custom' | ||
jsxIcon={<div><Link to={this.props.pendingActivation === this.props.editingAppID?this.props.activeLayout:'/'} | ||
className="t-small t-medium th-f-color t-ls1" | ||
onClick={() => { this.savePermissions(); }}>SAVE</Link></div>} /> | ||
<div className="vscrollmenu"> | ||
{ options } | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
const PermissionsView = connect(mapStateToProps)(Permissions); | ||
export default withRouter(PermissionsView); |
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
Oops, something went wrong.