Skip to content

Commit 283d8e1

Browse files
committed
feat: add new store
1 parent cead790 commit 283d8e1

16 files changed

Lines changed: 289 additions & 38 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "0.0.32",
3+
"version": "0.0.33",
44
"types": "src/index.ts",
55
"main": "built/index.js",
66
"scripts": {

src/commands/dev/dashboard/client/pages/main/main.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { RoutesComponent } from './routes/routes.component'
99
import { LayoutComponent } from './layout/layout.component'
1010
import { NotFoundComponent } from './not-found/not-found.component'
1111
import { ConfigComponent } from './config/config.component'
12+
import { StoresComponent } from './stores/stores.component'
1213

1314
@Connect
1415
export class MainComponent extends PureComponent<Props, State> {
@@ -27,6 +28,8 @@ export class MainComponent extends PureComponent<Props, State> {
2728
return <NotFoundComponent />
2829
case 'config':
2930
return <ConfigComponent />
31+
case 'stores':
32+
return <StoresComponent />
3033
default:
3134
return null
3235
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Connect } from "dob-react"
2+
import * as React from "react"
3+
import { Props, State } from './store.type'
4+
import * as S from './store.style'
5+
import { PureComponent } from '../../../utils/react-helper'
6+
7+
@Connect
8+
export class StoreComponent extends PureComponent<Props, State> {
9+
static defaultProps = new Props()
10+
state = new State()
11+
12+
render() {
13+
return (
14+
<S.Container>
15+
Stores TODO
16+
</S.Container>
17+
)
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import styled from 'styled-components'
2+
3+
export const Container = styled.div`
4+
5+
`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export class Props {
2+
3+
}
4+
5+
export class State {
6+
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Connect } from "dob-react"
2+
import * as React from "react"
3+
import { Props, State } from './stores.type'
4+
import * as S from './stores.style'
5+
import { PureComponent } from '../../../utils/react-helper'
6+
7+
@Connect
8+
export class StoresComponent extends PureComponent<Props, State> {
9+
static defaultProps = new Props()
10+
state = new State()
11+
12+
render() {
13+
return (
14+
<S.Container>
15+
Store TODO
16+
</S.Container>
17+
)
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import styled from 'styled-components'
2+
3+
export const Container = styled.div`
4+
5+
`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export class Props {
2+
3+
}
4+
5+
export class State {
6+
7+
}

src/commands/dev/dashboard/client/pages/menu/new-store/form.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from "react"
33
import { Props, State } from './new-store.type'
44
import * as S from '../menu.style'
55
import { PureComponent } from '../../../utils/react-helper'
6-
import { Form, Button, Input } from 'antd'
6+
import { Form, Button, Input, Switch } from 'antd'
77

88
const FormItem = Form.Item
99

@@ -45,20 +45,32 @@ class FormComponent extends PureComponent<Props, State> {
4545
<Form onSubmit={this.handleSubmit}>
4646
<FormItem
4747
{...formItemLayout}
48-
label="Path"
48+
label="Name"
4949
>
50-
{this.props.form.getFieldDecorator('path', {
51-
initialValue: 'about',
50+
{this.props.form.getFieldDecorator('name', {
51+
initialValue: 'application',
5252
rules: [{
53-
type: 'string', message: 'Path must be string!',
53+
type: 'string', message: 'Name must be string!',
5454
}, {
55-
required: true, message: 'Path is required!',
55+
required: true, message: 'Name is required!',
5656
}],
5757
})(
5858
<Input />
5959
)}
6060
</FormItem>
6161

62+
<FormItem
63+
{...formItemLayout}
64+
label="With demo"
65+
>
66+
{this.props.form.getFieldDecorator('withDemo', {
67+
initialValue: true,
68+
valuePropName: "checked"
69+
})(
70+
<Switch />
71+
)}
72+
</FormItem>
73+
6274
<FormItem {...tailFormItemLayout}>
6375
<Button
6476
type="primary"
@@ -72,7 +84,7 @@ class FormComponent extends PureComponent<Props, State> {
7284

7385
private handleSubmit = async (e: any) => {
7486
e.preventDefault();
75-
await this.props.ApplicationAction.addPage(this.props.form.getFieldsValue())
87+
await this.props.ApplicationAction.addStore(this.props.form.getFieldsValue())
7688
this.props.onSuccess()
7789
}
7890
}

src/commands/dev/dashboard/client/pages/struct/struct.component.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ export class StructComponent extends PureComponent<Props, State> {
106106
key: 'stores',
107107
title: `Stores (${this.props.ApplciationStore.status.info.stores.length})`,
108108
icon: <TreeIcon type="database" />,
109-
disabled: this.props.ApplciationStore.status.info.stores.length === 0
109+
disabled: this.props.ApplciationStore.status.info.stores.length === 0,
110+
children: this.props.ApplciationStore.status.info.stores.map(store => {
111+
return {
112+
key: 'store-' + store.filePath,
113+
title: store.name,
114+
icon: <TreeIcon type="database" />
115+
}
116+
})
110117
})
111118
}
112119

0 commit comments

Comments
 (0)