Skip to content
Snippets Groups Projects
Unverified Commit 8a9d4510 authored by Evelyn Eastmond's avatar Evelyn Eastmond Committed by GitHub
Browse files

Merge pull request #3851 from evhan55/localization/alerts

Alerts CSS width changes and hardware alerts localization
parents cf190f7a b64b57ba
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
border-radius: $space; border-radius: $space;
padding: $space; padding: $space;
margin-bottom: 7px; margin-bottom: 7px;
min-height: 1.5rem;
} }
.alert.warn { .alert.warn {
...@@ -26,7 +27,8 @@ ...@@ -26,7 +27,8 @@
} }
.alert-icon { .alert-icon {
margin: $space; margin-left: .25rem;
margin-right: .25rem;
vertical-align: middle; vertical-align: middle;
} }
...@@ -38,6 +40,8 @@ ...@@ -38,6 +40,8 @@
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
padding-left: .5rem;
padding-right: .5rem;
} }
.alert-close-button { .alert-close-button {
...@@ -52,17 +56,18 @@ ...@@ -52,17 +56,18 @@
} }
.connection-button { .connection-button {
min-height: 2rem;
padding: 0.55rem 0.9rem; padding: 0.55rem 0.9rem;
border-radius: 0.35rem; border-radius: 0.35rem;
background: #FF8C1A; background: #FF8C1A;
color: white; color: white;
font-weight: 700; font-weight: 700;
font-size: 0.77rem; font-size: 0.77rem;
margin: 0.25rem;
border: none; border: none;
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
align-self: center;
margin-right: 13px; margin-right: 13px;
outline-style:none; outline-style:none;
} }
...@@ -18,10 +18,10 @@ const closeButtonColors = { ...@@ -18,10 +18,10 @@ const closeButtonColors = {
const AlertComponent = ({ const AlertComponent = ({
content, content,
closeButton, closeButton,
extensionName,
iconSpinner, iconSpinner,
iconURL, iconURL,
level, level,
message,
onCloseAlert, onCloseAlert,
onReconnect, onReconnect,
showReconnect showReconnect
...@@ -29,21 +29,29 @@ const AlertComponent = ({ ...@@ -29,21 +29,29 @@ const AlertComponent = ({
<Box <Box
className={classNames(styles.alert, styles[level])} className={classNames(styles.alert, styles[level])}
> >
{/* TODO: implement Rtl handling */}
{iconSpinner && (
<Spinner className={styles.alertSpinner} />
)}
{iconURL && (
<img
className={styles.alertIcon}
src={iconURL}
/>
)}
<div className={styles.alertMessage}> <div className={styles.alertMessage}>
{/* TODO: implement Rtl handling */} {extensionName ? (
<div className={styles.alertIcon}> <FormattedMessage
{iconSpinner && ( defaultMessage="Scratch lost connection to {extensionName}"
<Spinner /> description="Message indicating that an extension peripheral has been disconnected"
)} id="gui.alerts.lostPeripheralConnection"
{iconURL && ( values={{
<img src={iconURL} /> extensionName: (
)} `${extensionName}`
</div> )
<div> }}
{message} />
&nbsp; ) : content}
{content}
</div>
</div> </div>
{showReconnect && ( {showReconnect && (
<button <button
...@@ -74,11 +82,11 @@ const AlertComponent = ({ ...@@ -74,11 +82,11 @@ const AlertComponent = ({
AlertComponent.propTypes = { AlertComponent.propTypes = {
closeButton: PropTypes.bool, closeButton: PropTypes.bool,
content: PropTypes.element, content: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
extensionName: PropTypes.string,
iconSpinner: PropTypes.bool, iconSpinner: PropTypes.bool,
iconURL: PropTypes.string, iconURL: PropTypes.string,
level: PropTypes.string, level: PropTypes.string,
message: PropTypes.string,
onCloseAlert: PropTypes.func.isRequired, onCloseAlert: PropTypes.func.isRequired,
onReconnect: PropTypes.func, onReconnect: PropTypes.func,
showReconnect: PropTypes.bool showReconnect: PropTypes.bool
......
...@@ -18,6 +18,7 @@ const AlertsComponent = ({ ...@@ -18,6 +18,7 @@ const AlertsComponent = ({
closeButton={a.closeButton} closeButton={a.closeButton}
content={a.content} content={a.content}
extensionId={a.extensionId} extensionId={a.extensionId}
extensionName={a.extensionName}
iconSpinner={a.iconSpinner} iconSpinner={a.iconSpinner}
iconURL={a.iconURL} iconURL={a.iconURL}
index={index} index={index}
......
...@@ -303,7 +303,8 @@ $fade-out-distance: 15px; ...@@ -303,7 +303,8 @@ $fade-out-distance: 15px;
/* Alerts */ /* Alerts */
.alerts-container { .alerts-container {
width: 520px; width: 448px;
min-width: 448px;
z-index: $z-index-alerts; z-index: $z-index-alerts;
left: 0; left: 0;
right: 0; right: 0;
......
...@@ -26,6 +26,7 @@ class Alert extends React.Component { ...@@ -26,6 +26,7 @@ class Alert extends React.Component {
const { const {
closeButton, closeButton,
content, content,
extensionName,
index, // eslint-disable-line no-unused-vars index, // eslint-disable-line no-unused-vars
level, level,
iconSpinner, iconSpinner,
...@@ -37,6 +38,7 @@ class Alert extends React.Component { ...@@ -37,6 +38,7 @@ class Alert extends React.Component {
<AlertComponent <AlertComponent
closeButton={closeButton} closeButton={closeButton}
content={content} content={content}
extensionName={extensionName}
iconSpinner={iconSpinner} iconSpinner={iconSpinner}
iconURL={iconURL} iconURL={iconURL}
level={level} level={level}
...@@ -62,6 +64,7 @@ Alert.propTypes = { ...@@ -62,6 +64,7 @@ Alert.propTypes = {
closeButton: PropTypes.bool, closeButton: PropTypes.bool,
content: PropTypes.element, content: PropTypes.element,
extensionId: PropTypes.string, extensionId: PropTypes.string,
extensionName: PropTypes.string,
iconSpinner: PropTypes.bool, iconSpinner: PropTypes.bool,
iconURL: PropTypes.string, iconURL: PropTypes.string,
index: PropTypes.number, index: PropTypes.number,
......
...@@ -56,32 +56,28 @@ const reducer = function (state, action) { ...@@ -56,32 +56,28 @@ const reducer = function (state, action) {
return state; // if alert not found, show nothing return state; // if alert not found, show nothing
} }
case SHOW_EXTENSION_ALERT: { case SHOW_EXTENSION_ALERT: {
const newList = state.alertsList.slice();
const newAlert = {
alertType: AlertTypes.EXTENSION,
message: action.data.message,
level: AlertLevels.WARN
};
const extensionId = action.data.extensionId; const extensionId = action.data.extensionId;
newAlert.showReconnect = false; if (extensionId) {
newAlert.extensionId = extensionId;
if (extensionId) { // if it's an extension
const extension = extensionData.find(ext => ext.extensionId === extensionId); const extension = extensionData.find(ext => ext.extensionId === extensionId);
if (extension) { if (extension) {
newAlert.showReconnect = true; const newList = state.alertsList.slice();
if (extension.name) { const newAlert = {
newAlert.content = extension.name; alertType: AlertTypes.EXTENSION,
} closeButton: true,
if (extension.smallPeripheralImage) { extensionId: extensionId,
newAlert.iconURL = extension.smallPeripheralImage; extensionName: extension.name,
} iconURL: extension.smallPeripheralImage,
newAlert.closeButton = true; level: AlertLevels.WARN,
showReconnect: true
};
newList.push(newAlert);
return Object.assign({}, state, {
alertsList: newList
});
} }
} }
newList.push(newAlert); return state; // if alert not found, show nothing
return Object.assign({}, state, {
alertsList: newList
});
} }
case CLOSE_ALERT: { case CLOSE_ALERT: {
const newList = state.alertsList.slice(); const newList = state.alertsList.slice();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment