packages/core: removed some unused javascript things
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
import moment from 'moment';
|
||||
|
||||
/**
|
||||
* Validates that a date is a valid ISO string.
|
||||
*
|
||||
* @param date A date string
|
||||
* @returns {bool} Whether the date is valid or not.
|
||||
*/
|
||||
export function isValidDate(date) {
|
||||
return moment(date).isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a date is a valid ISO string and a specific format.
|
||||
*
|
||||
* @param date A date string
|
||||
* @param format A format string or an array of format strings to validate against.
|
||||
* @returns {bool} Whether the date is valid or not according to the format.
|
||||
*/
|
||||
export function isValidDateAndFormat(date, format) {
|
||||
return moment(date, format, true).isValid();
|
||||
}
|
||||
|
||||
export function relativeTime(timestamp) {
|
||||
return moment(timestamp).fromNow();
|
||||
}
|
||||
|
||||
// Select a large random integer at startup, to prevent the greetings to change every time the user
|
||||
// navigates.
|
||||
const greetingRandomSeed = Math.floor(Math.random() * 1000000);
|
||||
@@ -1,21 +0,0 @@
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
// Shared MUI styles for a grid-based Card layout
|
||||
export const CardLayoutStyles = theme => ({
|
||||
container: {
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(auto-fill, 296px)',
|
||||
gridGap: theme.spacing(3),
|
||||
marginBottom: theme.spacing(6),
|
||||
},
|
||||
card: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
cardActions: {
|
||||
flexGrow: '1',
|
||||
alignItems: 'flex-end',
|
||||
},
|
||||
});
|
||||
|
||||
export const useCardLayoutStyles = makeStyles(CardLayoutStyles);
|
||||
@@ -1,67 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import TemplateCardMedia from './TemplateCardMedia';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardActions,
|
||||
CardContent,
|
||||
Chip,
|
||||
Typography,
|
||||
withStyles,
|
||||
} from '@material-ui/core';
|
||||
import { Link } from '@material-ui/core';
|
||||
import { CardLayoutStyles } from './CardLayoutStyles';
|
||||
|
||||
const styles = theme => ({
|
||||
...CardLayoutStyles(theme),
|
||||
chip: {
|
||||
backgroundColor: theme.palette.gold,
|
||||
marginRight: 6,
|
||||
},
|
||||
});
|
||||
|
||||
export class TemplateCard extends Component {
|
||||
static propTypes = {
|
||||
isGoldenPath: PropTypes.bool,
|
||||
item: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isGoldenPath: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { item, isGoldenPath, classes } = this.props;
|
||||
const isExperimental = item.lifecycle === 'experimental';
|
||||
// if (!item.owner) {
|
||||
// // If an item has no owner, it has most likely been unregistered from sysmodel. Should not crash the whole page.
|
||||
// return null;
|
||||
// }
|
||||
return (
|
||||
<Card key={item.id} className={classes.card}>
|
||||
<TemplateCardMedia name={item.name} />
|
||||
{item.description && (
|
||||
<CardContent>
|
||||
{isGoldenPath && (
|
||||
<Chip
|
||||
label="Golden Path"
|
||||
color="secondary"
|
||||
classes={{ root: classes.chip }}
|
||||
/>
|
||||
)}
|
||||
{isExperimental && <Chip label="Experimental" />}
|
||||
<Typography component="div">{item.description}</Typography>
|
||||
</CardContent>
|
||||
)}
|
||||
<CardActions className={classes.cardActions}>
|
||||
<Link href={item.link || `/create/${item.id}`}>
|
||||
<Button color="primary">{item.callToAction || 'Choose'}</Button>
|
||||
</Link>
|
||||
</CardActions>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(TemplateCard);
|
||||
@@ -1,41 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Typography, withStyles } from '@material-ui/core';
|
||||
|
||||
const styles = theme => ({
|
||||
media: {
|
||||
color: theme.palette.bursts.fontColor,
|
||||
backgroundColor: theme.palette.bursts.backgroundColor.default,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
padding: theme.spacing(2),
|
||||
minHeight: 120,
|
||||
position: 'relative',
|
||||
isolation: 'isolate',
|
||||
},
|
||||
title: {
|
||||
paddingTop: theme.spacing(1),
|
||||
paddingBottom: theme.spacing(1),
|
||||
lineHeight: 1,
|
||||
},
|
||||
slackChannel: {
|
||||
color: theme.palette.bursts.slackChannelText,
|
||||
},
|
||||
});
|
||||
|
||||
export class TemplateCardMedia extends Component {
|
||||
render() {
|
||||
const { classes, name, ownerName } = this.props;
|
||||
|
||||
return (
|
||||
<div className={classes.media}>
|
||||
<Typography color="inherit">{ownerName}</Typography>
|
||||
<Typography color="inherit" className={classes.title} variant="h6">
|
||||
{name}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(TemplateCardMedia);
|
||||
@@ -1,42 +0,0 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withStyles } from '@material-ui/core';
|
||||
import TemplateCard from './TemplateCard';
|
||||
import { CardLayoutStyles } from './CardLayoutStyles';
|
||||
|
||||
export class TemplateList extends Component {
|
||||
static GOLDEN_PATH_TEMPLATE_IDS = [
|
||||
'simple-apollo-standalone',
|
||||
'scio-cookie',
|
||||
'react-skeleton',
|
||||
'science-box-cookie',
|
||||
];
|
||||
|
||||
static propTypes = {
|
||||
items: PropTypes.array.isRequired,
|
||||
};
|
||||
|
||||
static isGoldenPathItem(item) {
|
||||
return TemplateList.GOLDEN_PATH_TEMPLATE_IDS.includes(item.id);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { items, classes } = this.props;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className={classes.container}>
|
||||
{items.map(item => (
|
||||
<TemplateCard
|
||||
key={item.id}
|
||||
item={item}
|
||||
isGoldenPath={TemplateList.isGoldenPathItem(item)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(CardLayoutStyles)(TemplateList);
|
||||
@@ -20,4 +20,3 @@ export { default as CircleProgress } from './components/CircleProgress';
|
||||
export { default as Progress } from './components/Progress';
|
||||
export { default as SupportButton } from './components/SupportButton';
|
||||
export { default as SortableTable } from './components/SortableTable';
|
||||
export { default as TemplateList } from './components/TemplateList/TemplateList';
|
||||
|
||||
Reference in New Issue
Block a user