Skip to content

Commit 4e6defa

Browse files
lihebiforrestbao
andauthored
fix annoying horizontal scroll bar in repos in dabshboard (#131)
* fix annoying horizontal scroll bar in repos in dabshboard * minor UI changes * formatting; remove unused interface Co-authored-by: forrest <[email protected]>
1 parent 1d4438e commit 4e6defa

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

ui/src/pages/repos/CreateRepoForm.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ import { nolookalikes } from "nanoid-dictionary";
1717
import { customAlphabet } from "nanoid";
1818
const nanoid = customAlphabet(nolookalikes, 10);
1919

20-
interface form {
21-
button?: any;
22-
}
23-
24-
export default function CreateRepoForm(props: form = {}) {
20+
export default function CreateRepoForm(props) {
2521
const [isPrivate, setIsPrivate] = useState(true);
2622
const [error, setError] = useState("");
2723
const [createRepo] = useMutation(
@@ -51,12 +47,8 @@ export default function CreateRepoForm(props: form = {}) {
5147
};
5248
return (
5349
<div>
54-
<Button
55-
variant="contained"
56-
sx={props.button ? props.button : {}}
57-
onClick={handleClickOpen}
58-
>
59-
Create new repo
50+
<Button variant={props.variant} onClick={handleClickOpen}>
51+
Create a repo
6052
</Button>
6153
<Dialog open={open} onClose={handleClose} fullWidth={true} maxWidth="sm">
6254
<DialogTitle
@@ -65,7 +57,7 @@ export default function CreateRepoForm(props: form = {}) {
6557
fontWeight: 500,
6658
}}
6759
>
68-
New {isPrivate ? " Private " : " Public "} Repo
60+
Create a {isPrivate ? " Private " : " Public "} Repo
6961
</DialogTitle>
7062
<DialogContent>
7163
<Formik

ui/src/pages/repos/index.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ enum RepoTypes {
3131
repo = "myRepos",
3232
collab = "myCollabRepos",
3333
}
34-
enum RepoHint {
34+
enum RepoHintTemplate {
3535
myRepos = "Please create a new repo",
36-
myCollabRepos = "Shared repos is empty",
36+
myCollabRepos = "No shared repo yet. Invite your friend! ",
3737
}
3838
enum RepoTitleHint {
3939
myRepos = "Your repos",
@@ -188,6 +188,25 @@ function RepoLine({ repo, deletable, sharable }) {
188188
);
189189
}
190190

191+
function RepoHintText({ type = RepoTypes.repo }) {
192+
return (
193+
<Box
194+
sx={{
195+
padding: "20px",
196+
color: "#6B87A2",
197+
fontSize: "18px",
198+
fontWeight: 600,
199+
display: "flex",
200+
// width: "100%",
201+
justifyContent: "center",
202+
alignContent: "center",
203+
}}
204+
>
205+
{RepoHintTemplate[type]}
206+
</Box>
207+
);
208+
}
209+
191210
function Repos({ url = FETCH_REPOS, type = RepoTypes.repo }) {
192211
const { loading, error, data } = useQuery(url);
193212
if (loading) {
@@ -215,11 +234,11 @@ function Repos({ url = FETCH_REPOS, type = RepoTypes.repo }) {
215234
>
216235
{RepoTitleHint[type]} ({repos.length})
217236
</Box>
218-
{type === RepoTypes.repo && <CreateRepoForm />}
237+
{type === RepoTypes.repo && <CreateRepoForm variant="contained" />}
219238
</Box>
220239

221240
<TableContainer component={Paper}>
222-
<Table sx={{ minWidth: 650 }}>
241+
<Table>
223242
<TableHead>
224243
<TableRow>
225244
<TableCell align="left">Name</TableCell>
@@ -239,20 +258,8 @@ function Repos({ url = FETCH_REPOS, type = RepoTypes.repo }) {
239258
))}
240259
</TableBody>
241260
</Table>
242-
{repos.length === 0 ? (
243-
<Box
244-
sx={{
245-
padding: "20px",
246-
color: "#6B87A2",
247-
fontSize: "18px",
248-
fontWeight: 600,
249-
display: "flex",
250-
width: "100%",
251-
justifyContent: "center",
252-
}}
253-
>
254-
{RepoHint[type]}
255-
</Box>
261+
{repos.length === 0 ? ( // If no repos
262+
<RepoHintText type={type} />
256263
) : null}
257264
</TableContainer>
258265
</Box>

0 commit comments

Comments
 (0)