Skip to content

Commit

Permalink
refactor: use same styles for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Aug 22, 2024
1 parent 81f81f1 commit c840b95
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 46 deletions.
51 changes: 28 additions & 23 deletions src/components/Item/ItemMessage/MissingPluginMessage.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
import i18n from '@dhis2/d2-i18n'
import { Center } from '@dhis2/ui'
import { Cover, IconWarning24, colors } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { isPrintMode } from '../../../modules/dashboardModes.js'
import classes from './styles/ItemMessage.module.css'

const MissingPluginMessage = ({ dashboardMode, pluginName }) => {
return (
<Center>
<p className={classes.errorMessage}>
{i18n.t('The plugin for rendering this item is not available')}
</p>
{!isPrintMode(dashboardMode) ? (
<p className={classes.appLink}>
<a
onClick={(e) => e.stopPropagation()}
target="_blank"
rel="noopener noreferrer"
href="/dhis-web-app-management/index.html#/app-hub"
>
{i18n.t(
'Install the {{pluginName}} plugin from the App Hub',
{
pluginName,
}
)}
</a>
</p>
) : null}
</Center>
<Cover>
<div className={classes.messageContent}>
<IconWarning24 color={colors.grey500} />
<span>
{i18n.t(
'The plugin for rendering this item is not available'
)}
</span>
{!isPrintMode(dashboardMode) ? (
<span className={classes.appLink}>
<a
onClick={(e) => e.stopPropagation()}
target="_blank"
rel="noopener noreferrer"
href="/dhis-web-app-management/index.html#/app-hub"
>
{i18n.t(
'Install the {{pluginName}} plugin from the App Hub',
{
pluginName,
}
)}
</a>
</span>
) : null}
</div>
</Cover>
)
}

Expand Down
14 changes: 7 additions & 7 deletions src/components/Item/ItemMessage/VisualizationErrorMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { colors } from '@dhis2/ui'
import { Cover, colors } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { isPrintMode } from '../../../modules/dashboardModes.js'
Expand Down Expand Up @@ -34,13 +34,13 @@ const VisualizationErrorMessage = ({
)}`

return (
<div className={classes.center}>
<Cover>
{getErrorIcon()}
<p className={classes.errorMessage}>
<span>
{i18n.t('There was an error loading data for this item')}
</p>
</span>
{!isPrintMode(dashboardMode) ? (
<p className={classes.appLink}>
<span className={classes.appLink}>
<a
onClick={(e) => e.stopPropagation()}
target="_blank"
Expand All @@ -51,9 +51,9 @@ const VisualizationErrorMessage = ({
appName: getAppName(itemType),
})}
</a>
</p>
</span>
) : null}
</div>
</Cover>
)
}

Expand Down
31 changes: 15 additions & 16 deletions src/components/Item/ItemMessage/styles/ItemMessage.module.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
.center {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
}

.errorMessage {
margin-top: var(--spacers-dp48);
margin-bottom: var(--spacers-dp8);
font-size: 16px;
font-weight: 600;
}

.appLink {
font-size: 16px;
margin-top: var(--spacers-dp8);
}

.appLink a {
color: var(--colors-grey700);
}

.messageContent {
display: flex;
flex-direction: column;
gap: var(--spacers-dp8);
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
background-color: rgba(255, 255, 255, 0.92);
font-size: 13px;
font-stretch: normal;
color: var(--colors-grey900);
text-align: center;
}

0 comments on commit c840b95

Please sign in to comment.