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

Refactor: Updated location of components. #26

Merged
merged 3 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"jest": "^24.1.0",
"keycloak-js": "9.0.0",
"mini-css-extract-plugin": "^0.4.5",
"nodemon": "2.0.2",
Copy link
Member

Choose a reason for hiding this comment

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

OK so I couldn't figure out why this was added.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lol I love the image. It was originally added because I was working on a fix for for rebuilding the model and services and thought about using nodemon. I'll remove it lol.

"optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "^1.15.2",
"prop-types": "^15.6.1",
Expand Down
30 changes: 0 additions & 30 deletions packages/studio/src/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
padding-bottom: 0;
}

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

.app-api-title {
color: var(--pf-global--primary-color--100);
Expand All @@ -46,38 +43,11 @@
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 */
}
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from "react";
import React from "react";
import { Page } from "@patternfly/react-core";
import AppHeader from "./appHeader";
import {BrowserRouter as Router, Route} from 'react-router-dom';
Expand Down
14 changes: 0 additions & 14 deletions packages/studio/src/app/appTag.tsx

This file was deleted.

7 changes: 7 additions & 0 deletions packages/studio/src/app/components/api/apiCard/apiCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.api-card-view-card-body {
font-size: var(--pf-global--FontSize--sm);
}

.api-card-view-card-header {
font-weight: var(--pf-global--FontWeight--normal) !important;
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
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'
import {ApiTag} from '../apiTag';
import ApicurioIcon from '../../../assets/apicurio-icon.png';
import './apiCard.css'

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

export const AppCard: React.FunctionComponent<AppCardProps> = ({ name, description, tags = []}: AppCardProps) => {
export const ApiCard: React.FunctionComponent<ApiCardProps> = ({ name, description, tags = []}: ApiCardProps) => {
return (
<Card>
<CardHead>
<img src={ApicurioIcon}/>
<CardActions/>
</CardHead>
<CardHeader className="app-card-view-card-header">
<CardHeader className="api-card-view-card-header">
{name}
</CardHeader>
<CardBody className="app-card-view-card-body">
<CardBody className="api-card-view-card-body">
{description}
</CardBody>
<CardFooter>
<div className="app-api-tag-group">
{tags.map((tag, index) =>
<AppTag key={index} text={tag}/>
<ApiTag key={index} text={tag}/>
)}
</div>
</CardFooter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Gallery } from '@patternfly/react-core';
import {AppCard} from './appCard';
import data from '../api-data.json';
import {ApiCard} from './apiCard';
import data from '../../../../api-data.json';

export const AppCardView: React.FunctionComponent<any> = (props) => {
export const ApiCardView: React.FunctionComponent<any> = (props) => {
const apiData = data.apis;
const cardList = apiData.map((api, index) =>
<AppCard
<ApiCard
key={index}
id={api.id}
name={api.name}
Expand All @@ -22,4 +22,4 @@ export const AppCardView: React.FunctionComponent<any> = (props) => {
);
}

export default AppCardView;
export default ApiCardView;
2 changes: 2 additions & 0 deletions packages/studio/src/app/components/api/apiCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './apiCard';
export * from './apiCardView';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {DataList} from '@patternfly/react-core';
import AppDataListItem from './appDataListItem';
import ApiDataListItem from './apiDataListItem';

interface AppDataListProps {
viewDetails: React.MouseEventHandler,
Expand Down Expand Up @@ -33,7 +33,7 @@ class AppDataList extends React.Component<AppDataListProps, AppDataListState> {
selectedDataListItemId={this.state.selectedDataListItemId}
onSelectDataListItem={this.onSelectDataListItem}
>
<AppDataListItem/>
<ApiDataListItem/>
</DataList>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.api-data-list-cell.pf-m-icon > img {
max-width: unset;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useEffect, useContext } from 'react';
import { Button, DataListItem, DataListItemCells, DataListItemRow, DataListCell, DataListCheck, DataListAction } from '@patternfly/react-core';
import {ApiTag} from '../apiTag';
import {ApiDropdownKebab} from '../apiDropDownKebab';
import ApicurioIcon from '../../../assets/apicurio-icon.png';
import './apiDataListItem.css';
import { useStoreContext } from '../../../../context/reducers';

export const ApiDataListItem: React.FunctionComponent<any> = () => {
const { apiData } = useStoreContext();

return (
<React.Fragment>
{apiData.map(apis =>
<DataListItem id={apis.id} key={apis.id} aria-labelledby={`data-list-item-${apis.id}`}>
<DataListItemRow>
<DataListCheck checked={false} aria-labelledby={`data-list-item-${apis.id}`} name={`data-list-item-check-${apis.id}`}/>
<DataListItemCells
dataListCells={[
<DataListCell isIcon={true} className="api-data-list-cell" key={`primary content ${apis.id}`}>
<img src={ApicurioIcon}/>
</DataListCell>,
<DataListCell key={`secondary content ${apis.id}`}>
<div className="app-api-title">
{apis.name}
</div>
<div className="app-api-description">
{apis.description}
</div>
<div className="app-api-tag-group">
{apis.tags.map((tag, index) =>
<ApiTag key={index} text={tag}/>
)}
</div>
</DataListCell>
]}
/>
<DataListAction aria-labelledby={`data-list-item-${apis.id}`} id={`data-list-item-${apis.id}`} aria-label="Actions">
<Button variant="link">View Details</Button>
<Button variant="secondary">Edit API</Button>
<ApiDropdownKebab/>
</DataListAction>
</DataListItemRow>
</DataListItem>
)}
</React.Fragment>
)
};

export default ApiDataListItem;
Empty file.
11 changes: 11 additions & 0 deletions packages/studio/src/app/components/api/apiDrawer/apiDrawer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.api-drawer-content {
padding: var(--pf-global--spacer--lg); /* remove this when new drawer styles in pf are added */
}

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

.ap--drawer-panel-body .pf-c-drawer__panel-body {
Copy link
Contributor

Choose a reason for hiding this comment

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

incorrect spelling this is why the padding is there

padding: 0;
}
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
import React from 'react';
import { Drawer, DrawerPanelContent, DrawerContent } from '@patternfly/react-core/dist/esm/experimental';
import AppDataList from './appDataList';
import {AppCardView} from './appCardView';
import AppDrawerPanelContent from './appDrawerPanelContent';
import './app.css';
import AppDataList from '../apiDataList/apiDataList';
import {ApiCardView} from '../..';
import ApiDrawerPanelContent from './apiDrawerPanelContent';
import './apiDrawer.css';

interface AppDrawerProps {
export interface ApiDrawerProps {
dashboardView: string
}

interface AppDrawerState {
interface ApiDrawerState {
readonly currentApiId: string,
readonly isExpanded: boolean,
}

class AppDrawer extends React.Component<AppDrawerProps, AppDrawerState> {
constructor(props: AppDrawerProps) {
export class ApiDrawer extends React.Component<ApiDrawerProps, ApiDrawerState> {
constructor(props: ApiDrawerProps) {
super(props);
this.state = {
currentApiId: "",
isExpanded: false
};
}

private openDrawer = () => {
const isExpanded = !this.state.isExpanded;
this.setState({
isExpanded
});
};

private findKey = (id: string) => {
const keyListItem = id;
this.setState({
currentApiId: keyListItem
})
}

render() {
render() {
const { isExpanded, currentApiId } = this.state;

return (
<React.Fragment>
<Drawer isExpanded={isExpanded} isInline>
<DrawerContent>
<div className="app-drawer-content">
<div className="api-drawer-content">
{
this.props.dashboardView === 'list' ? (
<AppDataList keyListItem={this.findKey} selectItem={this.openDrawer} viewDetails={this.openDrawer}/>
) : (
<AppCardView/>
<ApiCardView/>
)
}
</div>
</DrawerContent>
<DrawerPanelContent className="app-drawer-panel-body">
<AppDrawerPanelContent currentApiId={currentApiId}/>
<DrawerPanelContent className="api-drawer-panel-body">
<ApiDrawerPanelContent currentApiId={currentApiId}/>
</DrawerPanelContent>
</Drawer>
</React.Fragment>
);
}

private openDrawer = () => {
const isExpanded = !this.state.isExpanded;
this.setState({
isExpanded
});
};

private findKey = (id: string) => {
const keyListItem = id;
this.setState({
currentApiId: keyListItem
})
}
}

export default AppDrawer;
export default ApiDrawer;
Loading