// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from "react"; import { Dialog, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles, DialogTitle, DialogContent, Tabs, Tab, DialogContentText } from '@material-ui/core'; import { WithDialogProps } from 'store/dialog/with-dialog'; import { withDialog } from "store/dialog/with-dialog"; import { compose } from 'redux'; import { AdvancedTabDialogData, ADVANCED_TAB_DIALOG } from "store/advanced-tab/advanced-tab"; import { DefaultCodeSnippet } from "components/default-code-snippet/default-code-snippet"; import { MetadataTab } from 'views-components/advanced-tab-dialog/metadataTab'; import { LinkResource } from "models/link"; import { ListResults } from "services/common-service/common-service"; type CssRules = 'content' | 'codeSnippet' | 'spacing'; const styles: StyleRulesCallback = theme => ({ content: { paddingTop: theme.spacing.unit * 3, minHeight: '400px', minWidth: '1232px' }, codeSnippet: { borderRadius: theme.spacing.unit * 0.5, border: '1px solid', borderColor: theme.palette.grey["400"], maxHeight: '400px' }, spacing: { paddingBottom: theme.spacing.unit * 2 }, }); export const AdvancedTabDialog = compose( withDialog(ADVANCED_TAB_DIALOG), withStyles(styles), )( class extends React.Component & WithStyles>{ state = { value: 0, }; componentDidMount() { this.setState({ value: 0 }); } handleChange = (event: React.MouseEvent, value: number) => { this.setState({ value }); } render() { const { classes, open, closeDialog } = this.props; const { value } = this.state; const { apiResponse, metadata, pythonHeader, pythonExample, cliGetHeader, cliGetExample, cliUpdateHeader, cliUpdateExample, curlHeader, curlExample, uuid, } = this.props.data; return this.setState({ value: 0 })} > API Details {value === 0 &&
{dialogContentExample(apiResponse, classes)}
} {value === 1 &&
{metadata !== '' && (metadata as ListResults).items.length > 0 ? ).items} uuid={uuid} /> : dialogContentHeader('(No metadata links found)')}
} {value === 2 && dialogContent(pythonHeader, pythonExample, classes)} {value === 3 &&
{dialogContent(cliGetHeader, cliGetExample, classes)} {dialogContent(cliUpdateHeader, cliUpdateExample, classes)}
} {value === 4 && dialogContent(curlHeader, curlExample, classes)}
; } } ); const dialogContent = (header: string, example: string, classes: any) =>
{dialogContentHeader(header)} {dialogContentExample(example, classes)}
; const dialogContentHeader = (header: string) => {header} ; const dialogContentExample = (example: JSX.Element | string, classes: any) => { // Pass string to lines param or JSX to child props const stringData = example && (example as string).length ? (example as string) : undefined; return {example as JSX.Element || null} ; }