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

Commit f6b0285

Browse files
Gimleuxqvalentin
andauthored
Feature/files context menu (#161)
* Extracted FileIcon * Corrected Typo in FileEntities * Corrected Typo in FileEntities * Add FileListContextMenu Basic * WIP Context menu * Positioning Context Menu * changed context menu items * Added icons * Added commits * removed context menu on right click * refactoring * extracted sorting method * remove else * removed else in arrays.ts * removed else in serviceWorker * remove else in sortFilesAndFolders * added drop down menu * rename fileList Header * WIP Context Menu Content * Basic Menu done * Implemented Download to Dropdown Menu * fixed bug in filesystem toolbar which allowed to click buttons when they are faded out * Added Binary Icon * Refactored FileIcons * Code Style * updated snapshot tests * install husky * resolved issue with missing dropdown indicator * add query parameters to form by input tags * add query parameter forwarding to nginx Co-authored-by: qvalentin <[email protected]>
1 parent 2d431ea commit f6b0285

26 files changed

+714
-30916
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"useTabs": false,
33
"printWidth": 80,
4-
"tabWidth": 2,
4+
"tabWidth": 4,
55
"singleQuote": false,
66

77
"trailingComma": "none",

package-lock.json

Lines changed: 23 additions & 30295 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/__snapshots__/storybook.test.ts.snap

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ exports[`Storyshots Error404 default 1`] = `
1717
</div>
1818
`;
1919

20+
exports[`Storyshots Filesystem Context Menu default 1`] = `
21+
<div
22+
className="fileListItemDropdownButton dropdown"
23+
id="fileListItemDropdownButton-0"
24+
>
25+
<button
26+
aria-expanded={false}
27+
aria-haspopup={true}
28+
className="no-after dropdown-toggle btn btn-primary"
29+
disabled={false}
30+
id="fileListItemDropdownButton-0-button"
31+
onClick={[Function]}
32+
type="button"
33+
>
34+
●●●
35+
</button>
36+
</div>
37+
`;
38+
2039
exports[`Storyshots Filesystem UploadDecisionsModal 1`] = `
2140
Array [
2241
<div
@@ -164,7 +183,7 @@ exports[`Storyshots Filesystem default 1`] = `
164183
<span>
165184
<button
166185
className="fade btn btn-primary"
167-
disabled={false}
186+
disabled={true}
168187
type="button"
169188
>
170189
Rename
@@ -174,20 +193,26 @@ exports[`Storyshots Filesystem default 1`] = `
174193
>
175194
<button
176195
className="btn btn-primary"
177-
disabled={false}
196+
disabled={true}
178197
onClick={[Function]}
179198
type="button"
180199
>
181200
Delete
182201
</button>
183202
<form
184-
action="http://localhost/data/download?="
203+
action="http://localhost/data/download"
185204
className="d-inline"
186205
method="get"
187206
>
207+
<input
208+
className="d-none"
209+
name="ids"
210+
type="text"
211+
value={Array []}
212+
/>
188213
<button
189214
className="btn btn-primary"
190-
disabled={false}
215+
disabled={true}
191216
type="submit"
192217
>
193218
Download
@@ -253,7 +278,7 @@ exports[`Storyshots Filesystem default 1`] = `
253278
<div
254279
className="col-md-1 col-2"
255280
>
256-
Share
281+
Interact
257282
</div>
258283
<div
259284
className="col-md-4 col-6"

src/elements/svg/SymbolFile.tsx renamed to src/assets/images/icons/reactSvgIcons/SymbolFile.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ export function FileEarmarkPDFIcon(props: React.SVGProps<SVGSVGElement>) {
184184
);
185185
}
186186

187+
export function FileEarmarkBinaryIcon(props: React.SVGProps<SVGSVGElement>) {
188+
return (
189+
<svg
190+
fill="currentColor"
191+
viewBox="0 0 16 16"
192+
height="1em"
193+
width="1em"
194+
{...props}
195+
>
196+
<path d="M4 0h5.5v1H4a1 1 0 00-1 1v12a1 1 0 001 1h8a1 1 0 001-1V4.5h1V14a2 2 0 01-2 2H4a2 2 0 01-2-2V2a2 2 0 012-2z" />
197+
<path d="M9.5 3V0L14 4.5h-3A1.5 1.5 0 019.5 3zM5.526 14.09c.976 0 1.524-.79 1.524-2.205 0-1.412-.548-2.203-1.524-2.203-.978 0-1.526.79-1.526 2.203 0 1.415.548 2.206 1.526 2.206zm-.832-2.205c0-1.05.29-1.612.832-1.612.358 0 .607.247.733.721L4.7 12.137a6.749 6.749 0 01-.006-.252zm.832 1.614c-.36 0-.606-.246-.732-.718l1.556-1.145c.003.079.005.164.005.249 0 1.052-.29 1.614-.829 1.614zm5.329.501v-.595H9.73V9.772h-.69l-1.19.786v.688l1.136-.747h.05v2.906h-1.18V14h3z" />
198+
</svg>
199+
);
200+
}
201+
202+
187203

188204
//--------------------------------------------------------------------\\
189205
//--------------------------------------------------------------------\\
-106 KB
Binary file not shown.

src/assets/images/solidarity/Black_Lives_Matter_logo.svg

Lines changed: 0 additions & 151 deletions
This file was deleted.
-61.7 KB
Binary file not shown.
-13.6 KB
Binary file not shown.

src/background/api/auth.ts

Lines changed: 86 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
import Axios, { AxiosResponse } from "axios";
1+
import Axios, {AxiosResponse} from "axios";
22

3-
import { hostname, userPath } from "./api";
3+
import {hostname, userPath} from "./api";
44

5-
import { UserState } from "../redux/actions/userTypes";
5+
import {UserState} from "../redux/actions/userTypes";
66
import store from "../redux/store";
7-
import {
8-
addAccessToken,
9-
addRefreshToken,
10-
checkedCookies,
11-
removeTokens
12-
} from "../redux/actions/tokens";
13-
import { AccessToken, CookieStatus } from "../redux/actions/tokenTypes";
14-
import { deleteCookie, getCookie, setCookie } from "../methods/cookies";
7+
import {addAccessToken, addRefreshToken, checkedCookies, removeTokens} from "../redux/actions/tokens";
8+
import {AccessToken, CookieStatus} from "../redux/actions/tokenTypes";
9+
import {deleteCookie, getCookie, setCookie} from "../methods/cookies";
1510
import {updateUser} from "../redux/actions/user";
1611
import {hashPassword} from "../methods/passwords";
1712

@@ -20,109 +15,110 @@ import {hashPassword} from "../methods/passwords";
2015
const cookieName: string = "refreshToken";
2116

2217
export interface BackendLoginData {
23-
tokenValue: string;
24-
user: UserState;
18+
tokenValue: string;
19+
user: UserState;
2520
}
2621

2722
export interface BackendAuthData {
28-
tokenValue: string;
29-
userId: number;
30-
validUntil: number;
23+
tokenValue: string;
24+
userId: number;
25+
validUntil: number;
3126
}
3227

3328
export const checkForCookie = () => {
34-
let refreshTokenCookieValue = getCookie(cookieName);
35-
if (refreshTokenCookieValue) {
29+
let refreshTokenCookieValue = getCookie(cookieName);
30+
if (!refreshTokenCookieValue) {
31+
return store.dispatch(checkedCookies(CookieStatus.FINISHED));
32+
}
33+
3634
store.dispatch(addRefreshToken(refreshTokenCookieValue));
3735
store.dispatch(checkedCookies(CookieStatus.LOADING));
3836
getAccessTokenWithRefreshToken();
39-
} else {
40-
store.dispatch(checkedCookies(CookieStatus.FINISHED));
41-
}
37+
4238
};
4339

44-
export const loginWithUsernameAndPassword = async (
45-
userName: string,
46-
password: string,
47-
stayLoggedIn: boolean
40+
export const loginWithUsernameAndPassword = async (
41+
userName: string,
42+
password: string,
43+
stayLoggedIn: boolean
4844
): Promise<BackendLoginData> => {
49-
console.log("[Auth] loginWithUsernameAndPassword", userName);
50-
let hashed = await hashPassword(password);
51-
return new Promise<BackendLoginData>((resolve, reject) => {
52-
let config = {
53-
headers: {
54-
Authorization: `Basic ${btoa(userName + ":" + hashed)}`
55-
}
56-
};
57-
58-
return Axios.get<BackendLoginData>(hostname + userPath + "/login", config)
59-
.then((data: AxiosResponse<BackendLoginData>) => {
60-
console.log(data.data);
61-
store.dispatch(addRefreshToken(data.data.tokenValue));
62-
store.dispatch(updateUser(data.data.user as UserState));
63-
64-
if (stayLoggedIn) {
65-
setCookie(cookieName, data.data.tokenValue, 60);
66-
}
67-
68-
getAccessTokenWithRefreshToken();
69-
})
70-
.catch((error) => {
71-
reject(error);
72-
});
73-
});
45+
console.log("[Auth] loginWithUsernameAndPassword", userName);
46+
let hashed = await hashPassword(password);
47+
return new Promise<BackendLoginData>((resolve, reject) => {
48+
let config = {
49+
headers: {
50+
Authorization: `Basic ${btoa(userName + ":" + hashed)}`
51+
}
52+
};
53+
54+
return Axios.get<BackendLoginData>(hostname + userPath + "/login", config)
55+
.then((data: AxiosResponse<BackendLoginData>) => {
56+
console.log(data.data);
57+
store.dispatch(addRefreshToken(data.data.tokenValue));
58+
store.dispatch(updateUser(data.data.user as UserState));
59+
60+
if (stayLoggedIn) {
61+
setCookie(cookieName, data.data.tokenValue, 60);
62+
}
63+
64+
getAccessTokenWithRefreshToken();
65+
})
66+
.catch((error) => {
67+
reject(error);
68+
});
69+
});
7470
};
7571

7672
export const getAccessTokenWithRefreshToken = () => {
77-
console.log("getAccessTokenWithRefreshToken");
73+
console.log("getAccessTokenWithRefreshToken");
7874

79-
let refreshToken: string | null = store.getState().tokens.refreshToken;
75+
let refreshToken: string | null = store.getState().tokens.refreshToken;
8076

81-
let config = {
82-
headers: {
83-
Authorization: `Bearer ${refreshToken}`
84-
}
85-
};
86-
87-
Axios.get<BackendAuthData>(hostname + userPath + "/auth", config)
88-
.then((data: AxiosResponse<BackendAuthData>) => {
89-
store.dispatch(checkedCookies(CookieStatus.FINISHED));
90-
setAuthHeaderToAxios(data.data.tokenValue);
91-
92-
store.dispatch(
93-
addAccessToken({
94-
token: data.data.tokenValue,
95-
timestamp: data.data.validUntil
96-
} as AccessToken)
97-
);
98-
if (!store.getState().user.username) {
99-
getOwnUserData(data.data.userId);
100-
}
101-
})
102-
.catch((error) => {
103-
store.dispatch(removeTokens());
104-
store.dispatch(checkedCookies(CookieStatus.FINISHED));
105-
106-
console.log(error);
107-
//you probably want to notify the user, maybe with a toast or similar
108-
});
77+
let config = {
78+
headers: {
79+
Authorization: `Bearer ${refreshToken}`
80+
}
81+
};
82+
83+
Axios.get<BackendAuthData>(hostname + userPath + "/auth", config)
84+
.then((data: AxiosResponse<BackendAuthData>) => {
85+
store.dispatch(checkedCookies(CookieStatus.FINISHED));
86+
setAuthHeaderToAxios(data.data.tokenValue);
87+
88+
store.dispatch(
89+
addAccessToken({
90+
token: data.data.tokenValue,
91+
timestamp: data.data.validUntil
92+
} as AccessToken)
93+
);
94+
if (!store.getState().user.username) {
95+
getOwnUserData(data.data.userId);
96+
}
97+
})
98+
.catch((error) => {
99+
store.dispatch(removeTokens());
100+
store.dispatch(checkedCookies(CookieStatus.FINISHED));
101+
102+
console.log(error);
103+
//you probably want to notify the user, maybe with a toast or similar
104+
});
109105
};
110106

111107
const getOwnUserData = (userId: number) => {
112-
Axios.get<UserState>(`${hostname}${userPath}/${userId}/info`)
113-
.then((response: AxiosResponse<UserState>) => {
114-
store.dispatch(updateUser(response.data));
115-
})
116-
.catch((error) => {
117-
console.log(error);
118-
});
108+
Axios.get<UserState>(`${hostname}${userPath}/${userId}/info`)
109+
.then((response: AxiosResponse<UserState>) => {
110+
store.dispatch(updateUser(response.data));
111+
})
112+
.catch((error) => {
113+
console.log(error);
114+
});
119115
};
120116

121117
export const logout = () => {
122-
store.dispatch(removeTokens());
123-
deleteCookie(cookieName);
118+
store.dispatch(removeTokens());
119+
deleteCookie(cookieName);
124120
};
125121

126122
function setAuthHeaderToAxios(accessToken: string) {
127-
Axios.defaults.headers.common["Authorization"] = `Bearer ${accessToken}`;
123+
Axios.defaults.headers.common["Authorization"] = `Bearer ${accessToken}`;
128124
}

src/background/api/filesystemTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ export interface FsEntity {
2727
shared: boolean;
2828
size: number;
2929
type: string;
30+
mimeType:string;
3031
}

0 commit comments

Comments
 (0)