Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit fe704f7

Browse files
author
Noah Lee
authored
Move the view into the dir (#397)
1 parent a1925f8 commit fe704f7

File tree

5 files changed

+94
-60
lines changed

5 files changed

+94
-60
lines changed

Diff for: ui/src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import Home from "./views/home"
99
import Repo from "./views/Repo"
1010
import Deployment from "./views/Deployment"
11-
import Settings from "./views/Settings"
11+
import Settings from "./views/settings"
1212
import Members from "./views/members"
1313

1414
function App(): JSX.Element {

Diff for: ui/src/views/Settings.tsx

-59
This file was deleted.

Diff for: ui/src/views/settings/SlackDescriptions.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { shallowEqual } from "react-redux"
2+
import { Button, Descriptions } from "antd"
3+
4+
import { useAppSelector } from "../../redux/hooks"
5+
6+
export default function SlackDescriptions(): JSX.Element {
7+
const { user } = useAppSelector(state => state.settings, shallowEqual)
8+
9+
const connected = (user?.chatUser)? true : false
10+
11+
return (
12+
<Descriptions title="Slack">
13+
<Descriptions.Item>
14+
{(connected)?
15+
<Button href="/slack/signout" type="primary" danger>DISCONNECTED</Button>:
16+
<Button href="/slack/" type="primary">CONNECT</Button>}
17+
</Descriptions.Item>
18+
</Descriptions>
19+
)
20+
}

Diff for: ui/src/views/settings/UserDescriptions.tsx

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { shallowEqual } from "react-redux"
2+
import { Tag, Descriptions, Input } from "antd"
3+
4+
import { useAppSelector } from "../../redux/hooks"
5+
6+
export default function UserDescriptions(): JSX.Element {
7+
const { user } = useAppSelector(state => state.settings, shallowEqual)
8+
9+
return (
10+
<Descriptions
11+
title="User Info"
12+
column={2}
13+
layout="vertical"
14+
style={{marginTop: "40px"}}
15+
>
16+
<Descriptions.Item label="Login">
17+
{user?.login}
18+
</Descriptions.Item>
19+
<Descriptions.Item label="Role">
20+
{(user?.admin)?
21+
<Tag color="purple">Admin</Tag>
22+
:
23+
<Tag color="purple">Member</Tag>}
24+
</Descriptions.Item>
25+
<Descriptions.Item label="Token">
26+
<Input.Password
27+
value={user?.hash}
28+
style={{width: 200, padding:0 }}
29+
readOnly
30+
bordered={false}
31+
/>
32+
</Descriptions.Item>
33+
</Descriptions>
34+
)
35+
}

Diff for: ui/src/views/settings/index.tsx

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { useEffect } from "react"
2+
import { shallowEqual } from "react-redux"
3+
import { Helmet } from "react-helmet"
4+
5+
import { useAppSelector, useAppDispatch } from "../../redux/hooks"
6+
import { fetchMe, checkSlack } from "../../redux/settings"
7+
8+
import Main from "../main"
9+
import UserDescription from "./UserDescriptions"
10+
import SlackDescriptions from "./SlackDescriptions"
11+
12+
export default function Settings(): JSX.Element {
13+
const { isSlackEnabled } = useAppSelector(state => state.settings, shallowEqual)
14+
const dispatch = useAppDispatch()
15+
16+
useEffect(() => {
17+
dispatch(fetchMe())
18+
dispatch(checkSlack())
19+
}, [dispatch])
20+
21+
return (
22+
<Main>
23+
<Helmet>
24+
<title>Settings</title>
25+
</Helmet>
26+
<h1>Settings</h1>
27+
<div>
28+
<UserDescription />
29+
</div>
30+
{(isSlackEnabled)?
31+
<div style={{marginTop: "40px", marginBottom: "20px"}}>
32+
<SlackDescriptions />
33+
</div>
34+
:
35+
<></>}
36+
</Main>
37+
)
38+
}

0 commit comments

Comments
 (0)