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

Commit dd46508

Browse files
authored
Some bug fixes (#219)
* FF-475 fix crash when error response does not fit the interface * remove deleted items from selction * FF-438 remove delete button for root folder * fix some margins * fix snapshots
1 parent 64b8d6e commit dd46508

File tree

7 files changed

+44
-42
lines changed

7 files changed

+44
-42
lines changed

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,12 @@ exports[`Storyshots Filesystem default 1`] = `
369369
>
370370
<span />
371371
<span>
372-
<button
373-
className="fade btn btn-outline-secondary btn-sm"
374-
disabled={true}
375-
type="button"
376-
>
377-
Rename
378-
</button>
379372
<span
380373
className="fade"
381374
>
382-
<button
383-
className="mx-1 btn btn-outline-secondary btn-sm"
384-
disabled={true}
385-
onClick={[Function]}
386-
type="button"
387-
>
388-
Delete
389-
</button>
390375
<a
391376
aria-disabled={true}
392-
className="btn btn-outline-secondary btn-sm disabled"
377+
className="mx-1 btn btn-outline-secondary btn-sm disabled"
393378
href="http://localhost/data/download?ids="
394379
onClick={[Function]}
395380
onKeyDown={[Function]}
@@ -399,7 +384,7 @@ exports[`Storyshots Filesystem default 1`] = `
399384
</a>
400385
</span>
401386
<button
402-
className="btn btn-outline-secondary btn-sm"
387+
className="ml-1 btn btn-outline-secondary btn-sm"
403388
disabled={false}
404389
onClick={[Function]}
405390
type="button"

src/background/api/filesystem.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import {
1414
changeStatus,
1515
nextFsEntity
1616
} from "../redux/actions/apiActions";
17-
import { addToContents, removeFromContents } from "../redux/actions/filesystem";
17+
import {
18+
addToContents,
19+
removeFromContents,
20+
removeFromSelected
21+
} from "../redux/actions/filesystem";
1822
import {
1923
EditableFileWithPreflightInfo,
2024
PreflightEntity
@@ -118,9 +122,10 @@ export const deleteFsEntities = (files: FsEntity[]) => {
118122
fhHostname + "/delete/" + fsEntity.fileSystemId
119123
)
120124
.then((response: AxiosResponse<FsEntity[]>) => {
121-
response.data.forEach((e) =>
122-
store.dispatch(removeFromContents(e))
123-
);
125+
response.data.forEach((e) => {
126+
store.dispatch(removeFromContents(e));
127+
store.dispatch(removeFromSelected(e));
128+
});
124129
resolve(response);
125130
})
126131
.catch((error) => reject(error));

src/background/api/registration.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ export const registerNewUser = async (
4040
.catch((error: AxiosError) => {
4141
console.log(error.response);
4242
const response: IRegisterServerResponse = {
43-
httpStatus: error.response!.status,
44-
httpMessage: error.response!.statusText,
45-
outputMessage: error.response!.data.message
43+
httpStatus: error.response?.status ?? 500,
44+
httpMessage:
45+
error.response?.statusText ?? "Internal Server Error",
46+
outputMessage:
47+
error.response?.data.message ?? "Internal Server Error"
4648
};
4749
reject(response);
4850
});

src/components/pages/filesytem/SelectedFsEntities.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function SelectedFsEntities(props: Props): ReactElement {
2323
if (props.selectedFsEntities?.length < 1) return <span>{}</span>;
2424

2525
return (
26-
<div className={"pt-2"}>
26+
<div>
2727
<OverlayTrigger
2828
placement={"bottom"}
2929
overlay={

src/components/pages/filesytem/ToolbarActions.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { NewFolder } from "./upload/NewFolder";
99
import { Search } from "./search/Search";
1010

1111
const mapState = (state: SystemState) => ({
12-
selectedFsEntities: state.filesystem.selectedFsEntities
12+
selectedFsEntities: state.filesystem.selectedFsEntities,
13+
currentFsItemId: state.filesystem.currentFsItemId
1314
});
1415

1516
const connector = connect(mapState);
@@ -25,30 +26,34 @@ function ToolbarActions(props: Props): ReactElement | null {
2526

2627
return (
2728
<span>
29+
{/*
2830
<Fade in={props.selectedFsEntities.length === 1}>
29-
<Button
30-
size="sm"
31-
variant="outline-secondary"
32-
disabled={props.selectedFsEntities.length !== 1}
33-
>
34-
Rename
35-
</Button>
36-
</Fade>
37-
<Fade in={props.selectedFsEntities.length > 0}>
38-
<span>
3931
<Button
4032
size="sm"
4133
variant="outline-secondary"
42-
onClick={handleDeleteClicked}
43-
disabled={props.selectedFsEntities.length < 1}
44-
className="mx-1"
34+
disabled={props.selectedFsEntities.length !== 1}
4535
>
46-
Delete
36+
Rename
4737
</Button>
38+
</Fade> */}
39+
<Fade in={props.selectedFsEntities.length > 0}>
40+
<span>
41+
{props.currentFsItemId !== "-1" && (
42+
<Button
43+
size="sm"
44+
variant="outline-secondary"
45+
onClick={handleDeleteClicked}
46+
disabled={props.selectedFsEntities.length < 1}
47+
className="mx-1"
48+
>
49+
Delete
50+
</Button>
51+
)}
4852
<Button
4953
size="sm"
5054
variant="outline-secondary"
5155
disabled={props.selectedFsEntities.length < 1}
56+
className="mx-1"
5257
href={
5358
constants.url.FH_URL +
5459
"/download?ids=" +

src/components/pages/filesytem/search/Search.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ function Search(): ReactElement {
99

1010
return (
1111
<>
12-
<Button size="sm" variant="outline-secondary" onClick={handleShow}>
12+
<Button
13+
size="sm"
14+
variant="outline-secondary"
15+
className="ml-1"
16+
onClick={handleShow}
17+
>
1318
Search
1419
</Button>
1520
<Modal

src/components/pages/filesytem/upload/NewFolder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function NewFolder(): ReactElement {
2323
size="sm"
2424
variant="outline-secondary"
2525
onClick={handleShow}
26-
className="ml-1"
26+
className="mx-1"
2727
>
2828
New Folder
2929
</Button>

0 commit comments

Comments
 (0)