Skip to content
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

Merged
merged 29 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 19 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
23 changes: 23 additions & 0 deletions lerna-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
0 silly argv { _: [ 'run' ],
Copy link
Member

Choose a reason for hiding this comment

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

I don't know much about lerna - but this sounds like a file that shouldn't be added to git.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@christiemolloy Can you remove this log file. Should update the .gitignore to not check in .log files as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed and updated gitignore

0 silly argv scope: '@apicurio/studio',
0 silly argv lernaVersion: '3.20.2',
0 silly argv '$0':
0 silly argv '/Users/cmolloy/Documents/repos/apicurio-studio-react-poc/node_modules/.bin/lerna',
0 silly argv script: 'start' }
1 notice cli v3.20.2
2 verbose rootPath /Users/cmolloy/Documents/repos/apicurio-studio-react-poc
3 notice filter including "@apicurio/studio"
4 info filter [ '@apicurio/studio' ]
5 info Executing command in 1 package: "yarn run start"
6 silly npmRunScript start [] @apicurio/studio
7 silly getExecOpts /Users/cmolloy/Documents/repos/apicurio-studio-react-poc/packages/studio undefined
8 error MaxBufferError: stderr maxBuffer exceeded
8 error at PassThrough.stream.on (/Users/cmolloy/Documents/repos/apicurio-studio-react-poc/node_modules/get-stream/index.js:41:19)
8 error at PassThrough.emit (events.js:187:15)
8 error at addChunk (_stream_readable.js:283:12)
8 error at readableAddChunk (_stream_readable.js:260:13)
8 error at PassThrough.Readable.push (_stream_readable.js:219:10)
8 error at PassThrough.Transform.push (_stream_transform.js:151:32)
8 error at PassThrough.afterTransform (_stream_transform.js:92:10)
8 error at PassThrough._transform (_stream_passthrough.js:42:3)
8 error at PassThrough.Transform._read (_stream_transform.js:190:10)
1,649 changes: 869 additions & 780 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"start:studio": "lerna run start --scope=@apicurio/studio"
},
"devDependencies": {
"lerna": "^3.15.0"
"lerna": "^3.20.2"
},
"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 @@ -60,7 +60,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
Collaborator

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.",
"type": "Open API 3.0.2",
"template": "Blank API",
"date": "January 29, 2020",
"author": "[email protected]"
},
{
"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.",
"type": "Open API 3.0.2",
"template": "Blank API",
"date": "January 29, 2020",
"author": "[email protected]"
},
{
"id": 2,
"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.",
"type": "Open API 3.0.2",
"template": "Blank API",
"date": "January 29, 2020",
"author": "[email protected]"
},
{
"id": 3,
"name": "Weather API",
"description": "A sample API that uses a pet store as an example to demonstrate features in the OpenAPI 3.0 specification.",
"type": "Open API 3.0.2",
"template": "Blank API",
"date": "January 29, 2020",
"author": "[email protected]"
}
]
}
100 changes: 100 additions & 0 deletions packages/studio/src/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,104 @@
.pf-c-page {
width: 100%;
height: 100vh;
}

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

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

.pf-c-drawer__panel {
height: 100vh;
}

.pf-c-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;
}

.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);
}

.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);
}

.pf-c-empty-state > a > .pf-c-button.pf-m-primary, .pf-c-empty-state .pf-c-empty-state__primary {
margin-top: var(--pf-c-empty-state--c-button--MarginTop);
}
57 changes: 14 additions & 43 deletions packages/studio/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,28 @@
import React, { Component, ReactNode } from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can change this to:

import React from "react";

import {
Page,
PageSectionVariants,
PageSection
} from "@patternfly/react-core";
import { Button, Level, LevelItem, Page, PageSectionVariants, PageSection, Title } from "@patternfly/react-core";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Button, level, levelitem, pagesectionvariant, pagesection, and title are no longer being used can you remove them.

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;
type AppProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we aren't passing in specific props you can delete this.

}

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>
);
export default class App extends Component<AppProps> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change this to a function component.

export const App: React.FunctionComponent = () => { ... } export default App;

constructor(props: AppProps) {
super(props);
}
render() {
return (
<Router>
<Page
isManagedSidebar={true}
header={<AppHeader />}
sidebar={
<AppSidebar
activeMenuGroup={activeMenuGroup}
activeMenuGroupItem={activeMenuGroupItem}
onSelect={this.onNavSelect}
/>
}
<Page isManagedSidebar={true} header={<AppHeader />}
>
{section}
<Route path='/' exact={true} component={Pages.Dashboard}/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should open a Jira issue to have Lucia design a route for page not found. We need an elegant way to handle 404.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<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>
);
}

private onNavSelect = ({ groupId, itemId }: any) => {
this.setState({
activeMenuGroup: groupId,
activeMenuGroupItem: itemId
});
};
}
50 changes: 50 additions & 0 deletions packages/studio/src/app/appCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { ReactNode } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change this too:

import React from 'react';

ReactNode isn't needed anymore.

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'

type AppCardProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Best practices for typescript now has changed to use interfaces instead of types here. Can you change this to an interface:
interface AppCardProps {

You should also disable the rule in tslint.json to start with I for interfaces. React community doesn't usually follow that anymore. To do this add the following rule to the tslint.json file:

"interface-name": false

apiName: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe all these props are required. We should change these to match the props in the model so it will map 1 to 1 when retrieve this from the server.

interface AppCardProps { name: string, description: string, tags?: string[] }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep updating these now that I know which models we're using!

apiDescription: string,
apiTag1: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be an array of tags. They shouldn't be required I believe.

tags?: string[];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, updated!

apiTag2: string
}

class AppCard extends React.Component<AppCardProps> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Convert this to a function component since state isn't being used.

export const AppCard: React.FunctionComponent<AppCardProps> = ({ name, description, tags = [] }: AppCardProps) => {

constructor(props: AppCardProps) {
super(props);
this.state = {
check: false
};
}
render() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should spread the props in the render function

{ name, description, tags = [] }: AppCardProps)

return (
<Card>
<CardHead>
<img src={ApicurioIcon}/>
<CardActions>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change <CardActions></CardActions> to <CardActions/> to fix linting error.

</CardActions>
</CardHead>
<CardHeader className="app-card-view-card-header">
{this.props.apiName}
Copy link
Collaborator

Choose a reason for hiding this comment

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

{name}

</CardHeader>
<CardBody className="app-card-view-card-body">
{this.props.apiDescription}
Copy link
Collaborator

Choose a reason for hiding this comment

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

{description}

</CardBody>
<CardFooter>
<div className="app-api-tag-group">
<AppTag
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use a map function here to create the AppTag.

<CardFooter> <div className="app-api-tag-group"> { tags.map((tag, index) =><AppTag key={index} text={tag}/>) } </div> </CardFooter>

text={this.props.apiTag1}
/>
<AppTag
text={this.props.apiTag2}
/>
</div>
</CardFooter>
</Card>
);
}
}

export default AppCard;
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, { ReactNode } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove { ReactNode }

import { Gallery, GalleryItem } from '@patternfly/react-core';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove GalleryItem

import AppCard from './appCard';
import data from '../api-data.json';
Copy link
Collaborator

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) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update to the following:

const cardList = apiData.map((api, index) => <AppCard key={index} name={api.name} description={api.description} tags = {['Tag 1', 'Another tag']} /> );

While this is good for now I think when we get the backend communication setup this will change to a prop where you pass in array of AppCards. While find out. :-)

<AppCard
apiName={api.name}
apiDescription={api.description}
apiTag1="Tag 1"
apiTag2="Another tag"
/>
);

return (
<Gallery gutter="md">
{cardList}
</Gallery>
);
}

export default AppCardView;
56 changes: 56 additions & 0 deletions packages/studio/src/app/appDataList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { ReactNode } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete {ReactNode}

import {DataList} from '@patternfly/react-core';
import AppDataListItem from './appDataListItem';
import data from '../api-data.json';

export interface AppDataListProps {
viewDetails: (ev: React.MouseEvent<HTMLButtonElement>) => void,
selectItem: (ev: React.MouseEvent<HTMLButtonElement>) => void
}

export 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
Collaborator

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
Collaborator

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.

console.log('is there a key here' + key);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the console.log.

}

render() {
const listItems = apiData.map((api, index) =>
<AppDataListItem
apiName={api.name}
Copy link
Collaborator

Choose a reason for hiding this comment

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

need to add key={index} to AppDataListItem

apiDescription={api.description}
apiTag1="Tag"
apiTag2="Another tag"
rowid={index}
id={api.id}
onClick={this.props.viewDetails}
/>
);
return (
<DataList
aria-label="selectable data list"
selectedDataListItemId={this.state.selectedDataListItemId}
onSelectDataListItem={this.onSelectDataListItem}
>
{listItems}
</DataList>
);
}
}

export default AppDataList;
Loading