@talend/react-components
Version:
Set of react components.
89 lines • 2.42 kB
JavaScript
import classNames from 'classnames';
import PropTypes from 'prop-types';
import Skeleton from '../Skeleton';
import { getI18nInstance } from '../translate';
import theme from './AboutDialog.module.scss';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const i18n = getI18nInstance();
export const getColumnHeaders = () => ({
name: {
key: 'name',
label: i18n.t('tui-components:SERVICE', {
defaultValue: 'Service'
})
},
build: {
key: 'build',
label: i18n.t('tui-components:BUILD_ID', {
defaultValue: 'Build ID'
})
},
version: {
key: 'version',
label: i18n.t('tui-components:VERSION', {
defaultValue: 'Version'
})
}
});
export function Text({
text = '',
loading,
size = Skeleton.SIZES.medium
}) {
return loading ? /*#__PURE__*/_jsx(Skeleton, {
type: Skeleton.TYPES.text,
size: size
}) : text;
}
export function AboutDialogTable({
definition = Object.values(getColumnHeaders()),
services = [],
loading = false
}) {
if (!services || !services.length) {
return null;
}
return /*#__PURE__*/_jsxs("table", {
className: classNames(theme['about-versions'], 'about-versions', 'table table-striped'),
children: [/*#__PURE__*/_jsx("thead", {
children: /*#__PURE__*/_jsx("tr", {
children: definition.map(attribute => /*#__PURE__*/_jsx("th", {
children: attribute.label
}, attribute.key))
})
}), /*#__PURE__*/_jsx("tbody", {
children: (loading ? [{
name: 'loading-first'
}, {
name: 'loading-second'
}, {
name: 'loading-third'
}] : services).map(service => /*#__PURE__*/_jsx("tr", {
children: definition.map(attribute => /*#__PURE__*/_jsx("td", {
children: /*#__PURE__*/_jsx(Text, {
loading: loading,
text: service[attribute.key]
})
}, attribute.key))
}, service.name))
})]
});
}
Text.propTypes = {
text: PropTypes.string,
loading: PropTypes.bool,
size: PropTypes.string
};
AboutDialogTable.propTypes = {
services: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
version: PropTypes.string,
build: PropTypes.string
})),
definition: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string,
label: PropTypes.string
})),
loading: PropTypes.bool
};
//# sourceMappingURL=AboutDialogTable.component.js.map