This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Features - Support Copy & Pate - Add row - Auto reload after add & update row
- Loading branch information
Showing
9 changed files
with
178 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as React from 'react' | ||
import {StackableJsonTableComponent} from './StackableJsonTable' | ||
import {Popover} from '@blueprintjs/core' | ||
import {TableStateDescription} from './TableStateDescription' | ||
import {JsonComponent} from './Json' | ||
import {connect} from 'react-redux' | ||
import {actions, Actions, RootState} from '../redux' | ||
|
||
export class DynamoTableComponent extends React.Component<Props, State> { | ||
render() { | ||
const {table, records, onItemSelected, onRefresh} = this.props | ||
|
||
return ( | ||
<div> | ||
<label className="pt-label pt-inline"> | ||
Records | ||
{table && ( | ||
<Popover> | ||
<button className="pt-button pt-icon-add pt-intent-primary pt-inline pt-minimal"/> | ||
<JsonComponent | ||
title="Add record" | ||
src={table.KeySchema.reduce((p, c) => { | ||
p[c.AttributeName] = `input valid(type: string) ${c.AttributeName}` | ||
return p | ||
}, {})} | ||
onEdit={this.handleOnEdit} | ||
/> | ||
</Popover> | ||
)} | ||
<button | ||
onClick={onRefresh} | ||
className="pt-button pt-icon-refresh pt-intent-danger pt-inline pt-minimal" | ||
disabled={!records} | ||
/> | ||
</label> | ||
{records | ||
? records.length > 0 | ||
? <StackableJsonTableComponent collection={records} onItemSelected={onItemSelected}/> | ||
: <TableStateDescription description="Empty"/> | ||
: <TableStateDescription description="Select Table"/> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
handleOnEdit = async (prev, next) => { | ||
await this.props.createRecord(this.props.table.TableName, next) | ||
this.props.readRecords(this.props.table.TableName) | ||
} | ||
} | ||
|
||
const mapStateToProps = (state: RootState) => state | ||
const mapDispatchToProps = actions | ||
export const DynamoTable = connect<StateProps, DispatchProps, OwnProps>(mapStateToProps, mapDispatchToProps)(DynamoTableComponent) | ||
|
||
interface StateProps extends RootState { | ||
} | ||
interface DispatchProps extends Actions { | ||
} | ||
interface OwnProps { | ||
onItemSelected?(json): void | ||
onRefresh?(): void | ||
} | ||
interface Props extends StateProps, DispatchProps, OwnProps { | ||
} | ||
interface State { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react' | ||
import {Icon} from '@blueprintjs/core' | ||
|
||
export class LinksComponent extends React.Component<Props, State> { | ||
render() { | ||
return ( | ||
<div className="pt-ui-text" style={{marginBottom: '10px'}}> | ||
<a target="_blank" href="https://github.com/deptno/dynamon"> | ||
<Icon icon="git-repo"/> Github | ||
</a> | ||
<a target="_blank" href="https://github.com/deptno/dynamon/issues/new"> | ||
<Icon icon="issue-new"/> Report issue | ||
</a> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
interface Props { | ||
} | ||
interface State { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as React from 'react' | ||
|
||
export const TableStateDescription: React.SFC<Props> = props => | ||
<div className="pt-non-ideal-state" style={{marginTop: '45px'}}> | ||
<div className="pt-non-ideal-state-visual pt-non-ideal-state-icon"> | ||
<span className="pt-icon pt-icon-th"></span> | ||
</div> | ||
<h4 className="pt-non-ideal-state-title">{props.description}</h4> | ||
</div> | ||
|
||
interface Props { | ||
description: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.