Skip to content

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

Merged
merged 29 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3bf080b
add empty state
christiemolloy Jan 17, 2020
5565c6c
add data list
christiemolloy Jan 17, 2020
b068deb
update
christiemolloy Jan 20, 2020
9259cd6
add more pages in
christiemolloy Jan 21, 2020
4e6cc32
made updates
christiemolloy Jan 22, 2020
7be2f0f
more updates
christiemolloy Jan 23, 2020
fbfbe57
add drawer
christiemolloy Jan 24, 2020
aff72a4
fix drawer
christiemolloy Jan 24, 2020
e02bb16
add panel contents
christiemolloy Jan 24, 2020
3099834
add updates
christiemolloy Jan 27, 2020
6b14aa2
updates
christiemolloy Jan 28, 2020
dc89b0f
fix the drawer and toggle
christiemolloy Jan 28, 2020
41906f5
add
christiemolloy Jan 28, 2020
86cd6a0
move router around and add form
christiemolloy Jan 28, 2020
f8425ca
add create and import api pages
christiemolloy Jan 28, 2020
463c0e8
work on drawer and pages
christiemolloy Jan 29, 2020
505cab6
work on the keys
christiemolloy Jan 29, 2020
2bec60e
populate drawer content with name
christiemolloy Jan 30, 2020
0489428
push changes for content
christiemolloy Jan 30, 2020
100039a
make small fixes
christiemolloy Jan 31, 2020
ff11f77
fix typo
christiemolloy Jan 31, 2020
1680315
Dons review
christiemolloy Feb 3, 2020
eab56f6
fix merge conflict
christiemolloy Feb 3, 2020
2734698
disable because still getting issue with config
christiemolloy Feb 3, 2020
80980ba
install tslint
christiemolloy Feb 3, 2020
0d64384
fix more tslint and ts errors
christiemolloy Feb 3, 2020
878f097
make more fixes
christiemolloy Feb 4, 2020
4244c49
update
christiemolloy Feb 4, 2020
86a5528
fix merge conflict
christiemolloy Feb 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ yarn-error.log*
.idea
.cache
.rts2_cache*
lerna-debug.log
1,737 changes: 957 additions & 780 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"test": "echo \"TODO: Add tests\" && exit 0 "
},
"devDependencies": {
"lerna": "^3.15.0"
"lerna": "^3.20.2",
"typescript": "^3.7.5",
"typescript-tslint-plugin": "^0.5.5"
},
"name": "apicurio-studio-react-poc"
}
2 changes: 1 addition & 1 deletion packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@apicurio/models": "^1.0.0",
"@apicurio/services": "^1.0.0",
"@patternfly/react-core": "^3.38.1",
"@patternfly/react-core": "^3.129.3",
"@patternfly/react-icons": "^3.10.6",
"@types/react-router": "^5.0.3",
"@types/react-router-dom": "^4.3.4",
Expand Down
40 changes: 40 additions & 0 deletions packages/studio/src/api-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"apis": [
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created this issue #15

{
"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"
}
]
}
99 changes: 97 additions & 2 deletions packages/studio/src/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,102 @@
flex: 0 1 auto;
}

.pf-c-page {
width: 100%;
.app-page {
height: 100vh;
}

.app-page-section-border-bottom {
border-bottom: 1px solid var(--pf-global--BorderColor--100);
}

.app-page-section-breadcrumb {
padding-bottom: 0;
}

.app-data-list-cell.pf-m-icon > img {
max-width: unset;
}

.app-api-title {
color: var(--pf-global--primary-color--100);
}

.app-api-description {
padding-top: calc(var(--pf-global--spacer--xs)/2);
font-size: var(--pf-global--FontSize--sm);
}

.app-api-tag-group {
padding-top: var(--pf-global--spacer--md);
}

.app-api-tag-group > *:not(:last-child) {
margin-right: var(--pf-global--spacer--sm);
}

.app-tag {
padding-right: var(--pf-global--spacer--sm);
padding-left: var(--pf-global--spacer--sm);
background-color: var(--pf-global--BackgroundColor--300);
font-size: var(--pf-global--FontSize--xs);
border-radius: var(--pf-global--BorderRadius--lg);
}

.app-card-view-card-body {
font-size: var(--pf-global--FontSize--sm);
}

.app-card-view-card-header {
font-weight: var(--pf-global--FontWeight--normal) !important;
}

.pf-m-selected {
color: var(--pf-global--active-color--100) !important;
}

.app-drawer-content {
padding: var(--pf-global--spacer--lg); /* remove this when new drawer styles in pf are added */
}

.app-drawer-panel-content {
padding: 0 !important;
}

.app-drawer-panel-body .pf-c-drawer__panel-body {
padding: 0;
}

.app-button-group-sm > *:not(:last-child) {
margin-right: var(--pf-global--spacer--sm); /* remove this when action group is added or we use utility classes */
}

.app-button-group-md > *:not(:last-child) {
margin-right: var(--pf-global--spacer--md); /* remove this when action group is added or we use utility classes */
}

.app-toolbar-api-total {
font-size: var(--pf-global--FontSize--sm);
color: var(--pf-global--Color--100);
}

.app-create-api-form {
width: 50%;
}

.app-form-helper-text {
font-size: var(--pf-global--FontSize--sm);
color: var(--pf-global--Color--200);
}

.app-form-helper-text-asterisk {
color: var(--pf-global--danger-color--100);
}

.app-import-api-split-layout > .pf-l-split__item {
width: 50%;
margin-right: var(--pf-global--spacer--xl);
}

.app-empty-state > a > .pf-c-button.pf-m-primary, .app-empty-state .pf-c-empty-state__primary {
margin-top: var(--pf-c-empty-state--c-button--MarginTop);
}
72 changes: 20 additions & 52 deletions packages/studio/src/app/app.tsx
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;
37 changes: 37 additions & 0 deletions packages/studio/src/app/appCard.tsx
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>
);
}
25 changes: 25 additions & 0 deletions packages/studio/src/app/appCardView.tsx
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';
Copy link
Contributor

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 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;
55 changes: 55 additions & 0 deletions packages/studio/src/app/appDataList.tsx
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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
Loading