|
| 1 | +/*----------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Red Hat, Inc. All rights reserved. |
| 3 | + * Licensed under the MIT License. See LICENSE file in the project root for license information. |
| 4 | + *-----------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import * as React from 'react'; |
| 7 | +import { makeStyles } from '@material-ui/core/styles'; |
| 8 | +import { |
| 9 | + Button, |
| 10 | + Card, |
| 11 | + CardContent, |
| 12 | + CardActions, |
| 13 | + List, |
| 14 | + ListItem, |
| 15 | + ListItemText, |
| 16 | + Tooltip, |
| 17 | + Typography} from '@material-ui/core'; |
| 18 | + |
| 19 | +import AddClusterView from './crc'; |
| 20 | +import clusterStyle from './types.style'; |
| 21 | +import './images/logo.png'; |
| 22 | + |
| 23 | +const useStyles = makeStyles(clusterStyle); |
| 24 | + |
| 25 | +const clusterTypes = [ |
| 26 | + { |
| 27 | + heading: 'Deploy it locally on your laptop', |
| 28 | + description: 'Install on Laptop: Red Hat CodeReady Containers.', |
| 29 | + smallInfo: 'Create a minimal OpenShift 4 cluster on your desktop/laptop for local development and testing.', |
| 30 | + imageUrl: ['https://www.openshift.com/hubfs/images/icons/Icon-Red_Hat-Hardware-Laptop-A-Black-RGB.svg'], |
| 31 | + urlAlt: 'crc', |
| 32 | + redirectLink: '', |
| 33 | + buttonText: 'Create/Refresh cluster', |
| 34 | + tooltip: 'You can create OpenShift 4 cluster using this wizard.' |
| 35 | + }, |
| 36 | + { |
| 37 | + heading: 'Launch Developer Sandbox', |
| 38 | + description: 'Free access to the Developer Sandbox for Red Hat OpenShift', |
| 39 | + smallInfo: 'The sandbox provides you with a private OpenShift environment in a shared, multi-tenant OpenShift cluster that is pre-configured with a set of developer tools.', |
| 40 | + imageUrl: ['https://assets.openshift.com/hubfs/images/logos/osh/Logo-Red_Hat-OpenShift-A-Standard-RGB.svg'], |
| 41 | + urlAlt: 'dev sandbox', |
| 42 | + redirectLink: 'https://developers.redhat.com/developer-sandbox', |
| 43 | + buttonText: 'Start your OpenShift experience', |
| 44 | + tooltip: 'Launch your Developer Sandbox for Red Hat OpenShift' |
| 45 | + }, |
| 46 | + { |
| 47 | + heading: 'Deploy it in your public cloud', |
| 48 | + description: 'Create an OpenShift cluster using managed services OR Run OpenShift clusters on your own by installing from another cloud provider.', |
| 49 | + smallInfo: 'This includes Azure Red Hat Openshift, Red Hat OpenShift on IBM Cloud, Red Hat OpenShift Service on AWS, Google Cloud, AWS (x86_64), Azure.', |
| 50 | + imageUrl: ['https://www.openshift.com/hubfs/images/logos/logo_aws.svg', 'https://www.openshift.com/hubfs/images/logos/logo-try-cloud.svg', 'https://www.openshift.com/hubfs/images/logos/logo_google_cloud.svg'], |
| 51 | + urlAlt: 'public cloud', |
| 52 | + redirectLink: 'https://console.redhat.com/openshift/create', |
| 53 | + buttonText: 'Try it in your cloud', |
| 54 | + tooltip: 'For complete installation, follow the official documentation.' |
| 55 | + } |
| 56 | +]; |
| 57 | + |
| 58 | +const vscodeApi = window.vscodeApi; |
| 59 | + |
| 60 | +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type |
| 61 | +export default function Editor() { |
| 62 | + const classes = useStyles(); |
| 63 | + const [showWizard, setShowWizard] = React.useState(false); |
| 64 | + |
| 65 | + const handleView = (index) => { |
| 66 | + if (index === 0) { |
| 67 | + setShowWizard(!showWizard); |
| 68 | + vscodeApi.postMessage({ |
| 69 | + action: 'openCrcAddClusterPage', |
| 70 | + }); |
| 71 | + } else if (index === 1) { |
| 72 | + vscodeApi.postMessage({ |
| 73 | + action: 'openLaunchSandboxPage', |
| 74 | + params: { |
| 75 | + url: clusterTypes[index].redirectLink |
| 76 | + } |
| 77 | + }); |
| 78 | + } else if (index === 2) { |
| 79 | + vscodeApi.postMessage({ |
| 80 | + action: 'openCreateClusterPage', |
| 81 | + params: { |
| 82 | + url: clusterTypes[index].redirectLink |
| 83 | + } |
| 84 | + }); |
| 85 | + } |
| 86 | + }; |
| 87 | + |
| 88 | + const InfrastructureLayout = ({clusterTypes}) => ( |
| 89 | + <> |
| 90 | + {clusterTypes.map((list, index) => ( |
| 91 | + <Card className={classes.cardTransform} key={index}> |
| 92 | + <div className={classes.cardHeader}> |
| 93 | + <Typography variant="caption" display="block" style={{fontSize: '1.25em', color: 'white'}}> |
| 94 | + {list.heading} |
| 95 | + </Typography> |
| 96 | + </div> |
| 97 | + <CardContent style= {{ height: 240 }}> |
| 98 | + <Typography style={{ padding: '10px', height: '50px' }}> |
| 99 | + {list.imageUrl.map((url: string, index: string | number) => ( |
| 100 | + <img src={url} key={index} className={classes.image} style={{ marginLeft: '.625rem', marginRight: '.625rem' }}></img> |
| 101 | + ))} |
| 102 | + </Typography> |
| 103 | + <List> |
| 104 | + <ListItem> |
| 105 | + <ListItemText |
| 106 | + primary={list.description} |
| 107 | + secondary={list.smallInfo} /> |
| 108 | + </ListItem> |
| 109 | + </List> |
| 110 | + </CardContent> |
| 111 | + <CardActions className={classes.cardButton}> |
| 112 | + <Tooltip title={list.tooltip} placement="top"> |
| 113 | + <div> |
| 114 | + <a onClick={() => handleView(index)} style={{ textDecoration: 'none'}} href={clusterTypes[index].redirectLink || '#' }> |
| 115 | + <Button |
| 116 | + variant="contained" |
| 117 | + color="default" |
| 118 | + component="span" |
| 119 | + className={classes.button} |
| 120 | + > |
| 121 | + {list.buttonText} |
| 122 | + </Button> |
| 123 | + </a> |
| 124 | + </div> |
| 125 | + </Tooltip> |
| 126 | + </CardActions> |
| 127 | + </Card> |
| 128 | + ))} |
| 129 | + </> |
| 130 | + ); |
| 131 | + |
| 132 | + return ( |
| 133 | + <div className={classes.App}> |
| 134 | + <div className={classes.iconContainer}> |
| 135 | + <img className={classes.image} src='assets/logo.png' alt="redhat-openshift"></img> |
| 136 | + </div> |
| 137 | + {showWizard && (<div className={classes.rowBody}> |
| 138 | + <Card className={classes.cardContent}> |
| 139 | + <Typography variant="body2" component="p" style={{ padding: 20 }}> |
| 140 | + Red Hat CodeReady Containers brings a minimal OpenShift 4 cluster to your local computer.<br></br>You can use this wizard to create OpenShift cluster locally. Cluster take approximately 15 minutes to provision. |
| 141 | + </Typography> |
| 142 | + <AddClusterView vscode={vscodeApi}/> |
| 143 | + </Card> |
| 144 | + </div>)} |
| 145 | + {!showWizard && ( |
| 146 | + <div className={classes.cardContainer}> |
| 147 | + <InfrastructureLayout clusterTypes={clusterTypes}></InfrastructureLayout> |
| 148 | + </div>)} |
| 149 | + </div> |
| 150 | + ); |
| 151 | +} |
0 commit comments