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

Commit 0a1bd15

Browse files
committed
Changed some design in Registration, Made some bugfixes in filesystem
1 parent a73b5ff commit 0a1bd15

File tree

5 files changed

+30
-27
lines changed

5 files changed

+30
-27
lines changed

src/background/api/filesystemTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export interface User {
1919
}
2020

2121
export interface FsEntity {
22-
createdByUser: User;
22+
owner: User;
23+
lastUpdatedBy: User;
2324
fileSystemId: number;
2425
lastUpdated: number;
2526
name: string;

src/components/pages/User/Registration.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default function Registration(): ReactElement {
1313
const [alertVariant, setAlertColor] = useState<"primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark">("success");
1414
const [alertVisibility, setAlertVisibility] = useState<boolean>(false);
1515

16-
1716
const registrationContainer = document.getElementById("registrationContainer")
1817
const logoSubmit = document.getElementById("logoSubmit")
1918

@@ -44,7 +43,7 @@ export default function Registration(): ReactElement {
4443
} else if (newUser.password.match(/\d/) == null || newUser.password.match(/[a-z]/) == null || newUser.password.match(/[A-Z]/) == null || notMinStrLength(newUser.password, MIN_PASSWORD_LENGTH)) {
4544
handleAlertVisibility(DEFAULT_ALERT_DURATION, "danger", "Error: Please pay attention to the notes below the input fields.")
4645
} else {
47-
await registerNewUser(newUser.username, newUser.password, newUser.passwordConfirmation)
46+
registerNewUser(newUser.username, newUser.password, newUser.passwordConfirmation)
4847
.then(res => {
4948
handleAlertVisibility(DEFAULT_ALERT_DURATION, "success", "Worked: " + (res.outputMessage ? res.outputMessage : (res.httpStatus + " " + res.httpMessage)));
5049
toggleSubmitLogo();
@@ -67,16 +66,16 @@ export default function Registration(): ReactElement {
6766
}
6867

6968
return (
70-
<Container className="h-100" style={{position: "relative"}} id="registrationContainer">
69+
<Container id="registrationContainer">
7170
<Row>
72-
<Col md={{span: 6, offset: 3}}>
71+
<div className="px-3 w-100">
7372
<h1>Create new account</h1>
7473
<UserInformationInput triggerAlert={handleAlertVisibility} submitFunction={handleSubmit}/>
7574
<Alert variant={alertVariant} onClose={() => setAlertVisibility(false)} show={alertVisibility}
7675
dismissible>
7776
<p>{alertMessage}</p>
7877
</Alert>
79-
</Col>
78+
</div>
8079
</Row>
8180
<img className={"invisible m0 position-relative"} src={fileFighter} alt="logo"
8281
id="logoSubmit"/>

src/components/pages/User/UserInformationInput.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,31 @@ export default function UserInformationInput(props: UserInformationInputProps):
4949

5050
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
5151
event.preventDefault();
52-
let value: [string, boolean] | string = makePasswordInputFitRules(event.target.value);
53-
if (!value[1]) {
54-
value = password;
52+
let newValue : string;
53+
54+
let [stringValue, isOK]: [string, boolean] = makePasswordInputFitRules(event.target.value);
55+
if (!isOK) {
56+
newValue = password;
5557
} else {
56-
value = value[0]
58+
newValue = stringValue
5759
}
58-
setPasswordInformationLength(!notMinStrLength(value, MIN_PASSWORD_LENGTH));
59-
setPasswordInformationLowercase(value.match(/[a-z]/) !== null);
60-
setPasswordInformationUppercase(value.match(/[A-Z]/) !== null);
61-
setPasswordInformationNumber(value.match(/\d/) !== null);
62-
setPassword(value)
60+
setPasswordInformationLength(!notMinStrLength(newValue, MIN_PASSWORD_LENGTH));
61+
setPasswordInformationLowercase(newValue.match(/[a-z]/) !== null);
62+
setPasswordInformationUppercase(newValue.match(/[A-Z]/) !== null);
63+
setPasswordInformationNumber(newValue.match(/\d/) !== null);
64+
setPassword(newValue)
6365
}
6466

6567
const handlePasswordConfirmationChange = async (event: ChangeEvent<HTMLInputElement>) => {
6668
event.preventDefault();
67-
let value: [string, boolean] | string = makePasswordInputFitRules(event.target.value);
68-
if (!value[1]) {
69-
value = passwordConfirmation;
69+
let newValue : string;
70+
const [stringValue, isOK]: [string, boolean] = makePasswordInputFitRules(event.target.value);
71+
if (!isOK) {
72+
newValue = passwordConfirmation;
7073
} else {
71-
value = value[0]
74+
newValue = stringValue
7275
}
73-
setPasswordConfirmation(value);
76+
setPasswordConfirmation(newValue);
7477
}
7578

7679
const handleSubmit = async (event: FormEvent) => {

src/components/pages/filesytem/FileList.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ function FileList(props: Props): ReactElement {
109109
? a.fileSystemId - b.fileSystemId
110110
: a[property].toLowerCase().localeCompare(b[property].toLowerCase())
111111
);
112-
} else if (property === "createdByUser") {
112+
} else if (property === "lastUpdatedBy") {
113113
toSort.sort((a, b) =>
114-
a.createdByUser.username
114+
a.lastUpdatedBy.username
115115
.toLowerCase()
116-
.localeCompare(b.createdByUser.username.toLowerCase()) === 0
116+
.localeCompare(b.lastUpdatedBy.username.toLowerCase()) === 0
117117
? a.fileSystemId - b.fileSystemId
118-
: a.createdByUser.username
118+
: a.lastUpdatedBy.username
119119
.toLowerCase()
120-
.localeCompare(b.createdByUser.username.toLowerCase())
120+
.localeCompare(b.lastUpdatedBy.username.toLowerCase())
121121
);
122122
}
123123
setFilesAndFolders(sortIncreasing ? toSort.reverse() : toSort);
@@ -151,7 +151,7 @@ function FileList(props: Props): ReactElement {
151151
<Col xs={6} md={4} onClick={() => handleSortClick("name")}>
152152
{"Name"}
153153
</Col>
154-
<Col xs={6} md={3} onClick={() => handleSortClick("createdByUser")}>
154+
<Col xs={6} md={3} onClick={() => handleSortClick("lastUpdatedBy")}>
155155
{"Owner"}
156156
</Col>
157157
<Col xs={3} md={1} onClick={() => handleSortClick("lastUpdated")}>

src/components/pages/filesytem/FileListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function FileListItem(props: Props): ReactElement {
145145
</Link>
146146
</Col>
147147
<Col xs={6} md={3}>
148-
{props.fileListItem.createdByUser.username}
148+
{props.fileListItem.lastUpdatedBy.username}
149149
</Col>
150150
<Col xs={3} md={1}>
151151
{getDateAsStringFromTimestamp(props.fileListItem.lastUpdated)}

0 commit comments

Comments
 (0)