1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { Dialog, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles, DialogTitle, DialogContent, Tabs, Tab, DialogContentText } from '@material-ui/core';
7 import { WithDialogProps } from '~/store/dialog/with-dialog';
8 import { withDialog } from "~/store/dialog/with-dialog";
9 import { compose } from 'redux';
10 import { ADVANCED_TAB_DIALOG } from "~/store/advanced-tab/advanced-tab";
11 import { DefaultCodeSnippet } from "~/components/default-code-snippet/default-code-snippet";
12 import { MetadataTab } from '~/views-components/advanced-tab-dialog/metadataTab';
14 type CssRules = 'content' | 'codeSnippet' | 'spacing';
16 const styles: StyleRulesCallback<CssRules> = theme => ({
18 paddingTop: theme.spacing.unit * 3,
23 borderRadius: theme.spacing.unit * 0.5,
25 borderColor: theme.palette.grey["400"],
29 paddingBottom: theme.spacing.unit * 2
33 export const AdvancedTabDialog = compose(
34 withDialog(ADVANCED_TAB_DIALOG),
37 class extends React.Component<WithDialogProps<any> & WithStyles<CssRules>>{
43 this.setState({ value: 0 });
46 handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
47 this.setState({ value });
50 const { classes, open, closeDialog } = this.props;
51 const { value } = this.state;
70 onExit={() => this.setState({ value: 0 })} >
71 <DialogTitle>Advanced</DialogTitle>
72 <Tabs value={value} onChange={this.handleChange} fullWidth>
73 <Tab label="API RESPONSE" />
74 <Tab label="METADATA" />
75 <Tab label="PYTHON EXAMPLE" />
76 <Tab label="CLI EXAMPLE" />
77 <Tab label="CURL EXAMPLE" />
79 <DialogContent className={classes.content}>
80 {value === 0 && <div>{dialogContentExample(apiResponse, classes)}</div>}
81 {value === 1 && <div>{metadata !== '' && metadata.items.length > 0 ? <MetadataTab items={metadata.items} uuid={uuid} user={user} /> : dialogContentHeader('(No metadata links found)')}</div>}
82 {value === 2 && dialogContent(pythonHeader, pythonExample, classes)}
84 {dialogContent(cliGetHeader, cliGetExample, classes)}
85 {dialogContent(cliUpdateHeader, cliUpdateExample, classes)}
87 {value === 4 && dialogContent(curlHeader, curlExample, classes)}
90 <Button variant='text' color='primary' onClick={closeDialog}>
99 const dialogContent = (header: string, example: string, classes: any) =>
100 <div className={classes.spacing}>
101 {dialogContentHeader(header)}
102 {dialogContentExample(example, classes)}
105 const dialogContentHeader = (header: string) =>
108 </DialogContentText>;
110 const dialogContentExample = (example: string, classes: any) =>
113 className={classes.codeSnippet}
114 lines={[example]} />;