-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly display localized instance description
- Loading branch information
Showing
4 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/components/Instances/InstanceDetail/InstanceInfoTable.js
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,62 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { Table } from 'react-bootstrap'; | ||
|
||
import Box from '../../widgets/Box'; | ||
import Markdown from '../../widgets/Markdown'; | ||
import { getLocalizedDescription } from '../../../helpers/localizedData'; | ||
|
||
const getDescription = (localizedTexts, locale) => { | ||
const description = getLocalizedDescription({ localizedTexts }, locale); | ||
return description ? ( | ||
<Markdown source={description} /> | ||
) : ( | ||
<p className="small text-muted text-center well well-sm"> | ||
<FormattedMessage | ||
id="app.instanceDetail.noDescription" | ||
defaultMessage="The instance has no description in any language." | ||
/> | ||
</p> | ||
); | ||
}; | ||
|
||
const InstanceInfoTable = ({ | ||
instance: { | ||
id, | ||
hasValidLicence, | ||
isOpen, | ||
isAllowed, | ||
rootGroup: { localizedTexts }, | ||
}, | ||
locale, | ||
}) => ( | ||
<div> | ||
<Box | ||
title={<FormattedMessage id="app.instanceDetail.description" defaultMessage="Instance Description" />} | ||
description={getDescription(localizedTexts, locale)} | ||
type="primary" | ||
collapsable | ||
noPadding | ||
unlimitedHeight> | ||
<Table> | ||
<tbody /> | ||
</Table> | ||
</Box> | ||
</div> | ||
); | ||
|
||
InstanceInfoTable.propTypes = { | ||
instance: PropTypes.shape({ | ||
id: PropTypes.string.isRequired, | ||
hasValidLicence: PropTypes.bool.isRequired, | ||
isOpen: PropTypes.bool.isRequired, | ||
isAllowed: PropTypes.bool.isRequired, | ||
rootGroup: PropTypes.shape({ | ||
localizedTexts: PropTypes.object.isRequired, | ||
}), | ||
}), | ||
locale: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default InstanceInfoTable; |
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 @@ | ||
export { default as InstanceInfoTable } from './InstanceInfoTable'; |
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