-
Notifications
You must be signed in to change notification settings - Fork 9
Add components #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add components #12
Changes from all commits
3bf080b
5565c6c
b068deb
9259cd6
4e6cc32
7be2f0f
fbfbe57
aff72a4
e02bb16
3099834
6b14aa2
dc89b0f
41906f5
86cd6a0
f8425ca
463c0e8
505cab6
2bec60e
0489428
100039a
ff11f77
1680315
eab56f6
2734698
80980ba
0d64384
878f097
4244c49
86a5528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ yarn-error.log* | |
.idea | ||
.cache | ||
.rts2_cache* | ||
lerna-debug.log |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"apis": [ | ||
{ | ||
"id": "0", | ||
"name": "Pet Store API", | ||
"description": "A sample API that uses a pet store as an example to demonstrate features in the OpenAPI 3.0 specification.", | ||
"createdOn": "January 29, 2020", | ||
"createdBy": "[email protected]", | ||
"tags": ["Pet store tag", "Another tag", "Tag one"], | ||
"type": "Open API 3.0.2" | ||
}, | ||
{ | ||
"id": "1", | ||
"name": "Sports Store API", | ||
"description": "A sample API that uses a pet store as an example to demonstrate features in the OpenAPI 3.0 specification.", | ||
"createdOn": "January 30, 2020", | ||
"createdBy": "[email protected]", | ||
"tags": ["Sports store tag", "Another tag", "Tag two"], | ||
"type": "Open API 3.0.2" | ||
}, | ||
{ | ||
"id": "2", | ||
"name": "Weather API", | ||
"description": "A sample API that uses a pet store as an example to demonstrate features in the OpenAPI 3.0 specification.", | ||
"createdOn": "January 18, 2020", | ||
"createdBy": "[email protected]", | ||
"tags": ["Weather store tag", "Another tag", "Tag three"], | ||
"type": "Open API 3.0.2" | ||
}, | ||
{ | ||
"id": "3", | ||
"name": "Clothes Store API", | ||
"description": "A sample API that uses a pet store as an example to demonstrate features in the OpenAPI 3.0 specification.", | ||
"createdOn": "January 24, 2020", | ||
"createdBy": "[email protected]", | ||
"tags": ["Clothes store tag", "Another tag", "Tag four"], | ||
"type": "Open API 3.0.2" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,25 @@ | ||
import React, { Component, ReactNode } from "react"; | ||
import { | ||
Page, | ||
PageSectionVariants, | ||
PageSection | ||
} from "@patternfly/react-core"; | ||
import React from "react"; | ||
import { Page } from "@patternfly/react-core"; | ||
import AppHeader from "./appHeader"; | ||
import AppSidebar from "./appSidebar"; | ||
import {BrowserRouter as Router, Route} from 'react-router-dom'; | ||
import * as Pages from './pages'; | ||
export default class App extends Component { | ||
public state = { | ||
activeMenuGroup: "", | ||
activeMenuGroupItem: "" | ||
}; | ||
import './app.css'; | ||
|
||
public render() { | ||
const { activeMenuGroup, activeMenuGroupItem } = this.state; | ||
|
||
const section = ( | ||
<PageSection variant={PageSectionVariants.light}> | ||
<Route path='/' exact={true} component={Pages.Dashboard}/> | ||
<Route path='/dashboard' exact={true} component={Pages.Dashboard}/> | ||
<Route path='/apis' exact={true} component={Pages.ViewApis}/> | ||
<Route path='/apis/create' exact={true} component={Pages.CreateAPI}/> | ||
<Route path='/apis/import' exact={true} component={Pages.ImportAPI}/> | ||
<Route path='/settings/profile' exact={true} component={Pages.UserProfile}/> | ||
<Route path='/settings/accounts' exact={true} component={Pages.LinkedAccounts}/> | ||
<Route path='/settings/validation' exact={true} component={Pages.Validations}/> | ||
</PageSection> | ||
); | ||
return ( | ||
<Router> | ||
<Page | ||
isManagedSidebar={true} | ||
header={<AppHeader />} | ||
sidebar={ | ||
<AppSidebar | ||
activeMenuGroup={activeMenuGroup} | ||
activeMenuGroupItem={activeMenuGroupItem} | ||
onSelect={this.onNavSelect} | ||
/> | ||
} | ||
> | ||
{section} | ||
</Page> | ||
</Router> | ||
); | ||
} | ||
|
||
private onNavSelect = ({ groupId, itemId }: any) => { | ||
this.setState({ | ||
activeMenuGroup: groupId, | ||
activeMenuGroupItem: itemId | ||
}); | ||
}; | ||
export const App: React.FunctionComponent = () => { | ||
return ( | ||
<Router> | ||
<Page | ||
isManagedSidebar={true} | ||
header={<AppHeader />} | ||
className="app-page" | ||
> | ||
<Route path='/' exact={true} component={Pages.Dashboard}/> | ||
<Route path='/dashboard' exact={true} component={Pages.Dashboard}/> | ||
<Route path='/create-api' exact={true} component={Pages.CreateApi}/> | ||
<Route path='/import-api' exact={true} component={Pages.ImportApi}/> | ||
</Page> | ||
</Router> | ||
); | ||
} | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { Card, CardHead, CardHeader, CardBody, CardFooter, CardActions } from '@patternfly/react-core'; | ||
import {AppTag} from './appTag'; | ||
import ApicurioIcon from './assets/apicurio-icon.png'; | ||
import './app.css' | ||
|
||
interface AppCardProps { | ||
id: string, | ||
name: string, | ||
description: string, | ||
tags: string[], | ||
type?: string | ||
} | ||
|
||
export const AppCard: React.FunctionComponent<AppCardProps> = ({ name, description, tags = []}: AppCardProps) => { | ||
return ( | ||
<Card> | ||
<CardHead> | ||
<img src={ApicurioIcon}/> | ||
<CardActions/> | ||
</CardHead> | ||
<CardHeader className="app-card-view-card-header"> | ||
{name} | ||
</CardHeader> | ||
<CardBody className="app-card-view-card-body"> | ||
{description} | ||
</CardBody> | ||
<CardFooter> | ||
<div className="app-api-tag-group"> | ||
{tags.map((tag, index) => | ||
<AppTag key={index} text={tag}/> | ||
)} | ||
</div> | ||
</CardFooter> | ||
</Card> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { Gallery } from '@patternfly/react-core'; | ||
import {AppCard} from './appCard'; | ||
import data from '../api-data.json'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a bug to move this to a package called mock under packages. We can update our code so we only pull in the mock package as a dependency for development. You can assign it to this sprint in Jira. |
||
|
||
export const AppCardView: React.FunctionComponent<any> = (props) => { | ||
const apiData = data.apis; | ||
const cardList = apiData.map((api, index) => | ||
<AppCard | ||
key={index} | ||
id={api.id} | ||
name={api.name} | ||
description={api.description} | ||
tags={api.tags} | ||
/> | ||
); | ||
|
||
return ( | ||
<Gallery gutter="md"> | ||
{cardList} | ||
</Gallery> | ||
); | ||
} | ||
|
||
export default AppCardView; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import {DataList} from '@patternfly/react-core'; | ||
import AppDataListItem from './appDataListItem'; | ||
import data from '../api-data.json'; | ||
|
||
interface AppDataListProps { | ||
viewDetails: React.MouseEventHandler, | ||
selectItem: FunctionStringCallback, | ||
keyListItem: FunctionStringCallback | ||
} | ||
|
||
interface AppDataListState { | ||
selectedDataListItemId: string | ||
} | ||
|
||
const apiData = data.apis; | ||
|
||
class AppDataList extends React.Component<AppDataListProps, AppDataListState> { | ||
constructor(props: AppDataListProps) { | ||
super(props); | ||
this.state = { | ||
selectedDataListItemId: '' | ||
}; | ||
} | ||
|
||
onSelectDataListItem = (id: string) => { | ||
this.setState({ selectedDataListItemId: id }); | ||
this.props.selectItem(id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id is not assignable to React.MouseEvent. It's a type mismatch since it's a string. |
||
this.props.keyListItem(id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keyListItem is missing from AppDataListProps. |
||
} | ||
|
||
render() { | ||
const listItems = apiData.map((api, index) => | ||
<AppDataListItem | ||
key={index} | ||
id={api.id} | ||
name={api.name} | ||
description={api.description} | ||
tags={api.tags} | ||
onClick={this.props.viewDetails} | ||
/> | ||
); | ||
return ( | ||
<DataList | ||
aria-label="selectable data list" | ||
selectedDataListItemId={this.state.selectedDataListItemId} | ||
onSelectDataListItem={this.onSelectDataListItem} | ||
> | ||
{listItems} | ||
</DataList> | ||
); | ||
} | ||
} | ||
|
||
export default AppDataList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a bug to move this out of studio into a package called mock under packages. We can then include it in as a package under devDependencies. This way we won't add unnecessary mock data files to the studio package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this issue #15