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

Commit 1348304

Browse files
authored
add Name of file to preview Link (#187)
* add Name of file to preview Link * add story for new fodler * update snapshots * undo package-lock change * rename story * try to fix storybook: storybookjs/storybook#15067
1 parent 0d70b7b commit 1348304

File tree

5 files changed

+129
-15
lines changed

5 files changed

+129
-15
lines changed

.storybook/main.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
module.exports = {
2-
"stories": [
3-
"../src/**/*.stories.mdx",
4-
"../src/**/*.stories.@(js|jsx|ts|tsx)"
5-
],
6-
"addons": [
7-
"@storybook/addon-links",
8-
"@storybook/addon-essentials",
9-
"@storybook/preset-create-react-app"
10-
]
11-
}
2+
stories: [
3+
"../src/**/*.stories.mdx",
4+
"../src/**/*.stories.@(js|jsx|ts|tsx)"
5+
],
6+
addons: [
7+
"@storybook/addon-links",
8+
"@storybook/addon-essentials",
9+
"@storybook/preset-create-react-app"
10+
],
11+
typescript: {
12+
reactDocgen: "none"
13+
}
14+
};

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,86 @@ exports[`Storyshots Filesystem FilesystemContextMenu 1`] = `
5252
</div>
5353
`;
5454

55+
exports[`Storyshots Filesystem NewFolderModal 1`] = `
56+
<form
57+
className=""
58+
onSubmit={[Function]}
59+
>
60+
<div
61+
className="modal-header"
62+
>
63+
<div
64+
className="modal-title h4"
65+
>
66+
Create new Directory
67+
</div>
68+
<button
69+
className="close"
70+
onClick={[Function]}
71+
type="button"
72+
>
73+
<span
74+
aria-hidden="true"
75+
>
76+
×
77+
</span>
78+
<span
79+
className="sr-only"
80+
>
81+
Close
82+
</span>
83+
</button>
84+
</div>
85+
<div
86+
className="modal-body"
87+
>
88+
<div
89+
className="form-group"
90+
>
91+
<label
92+
className="form-label"
93+
htmlFor="formFolderName"
94+
>
95+
Folder name
96+
</label>
97+
<input
98+
className="form-control"
99+
id="formFolderName"
100+
onChange={[Function]}
101+
placeholder="e.g. My Cat Pictures"
102+
type="text"
103+
value=""
104+
/>
105+
</div>
106+
107+
</div>
108+
<div
109+
className="modal-footer"
110+
>
111+
<div
112+
className="w-100 justify-content-between row"
113+
>
114+
<button
115+
className="btn btn-secondary"
116+
disabled={false}
117+
onClick={[Function]}
118+
type="button"
119+
>
120+
Abort
121+
</button>
122+
<button
123+
className="btn btn-primary"
124+
disabled={false}
125+
onClick={[Function]}
126+
type="button"
127+
>
128+
Create Folder
129+
</button>
130+
</div>
131+
</div>
132+
</form>
133+
`;
134+
55135
exports[`Storyshots Filesystem SearchModal 1`] = `
56136
Array [
57137
<div

src/components/pages/filesytem/FileListItem.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ function FileListItem(props: Props): ReactElement {
9191
to={
9292
isFolder
9393
? `/file${props.fileListItem.path ?? ""}`
94-
: "/data/preview/" + props.fileListItem.fileSystemId
94+
: "/data/preview/" +
95+
props.fileListItem.fileSystemId +
96+
"/" +
97+
props.fileListItem.name
9598
}
9699
>
97100
{props.fileListItem.name}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { storiesOf } from "@storybook/react";
2+
import { Provider } from "react-redux";
3+
import store from "../../../../background/redux/store";
4+
import { BrowserRouter } from "react-router-dom";
5+
import React from "react";
6+
import { NewFolderModalContent } from "./NewFolderModalContent";
7+
import { filesystemPath, hostname } from "../../../../background/api/api";
8+
import MockAdapter from "axios-mock-adapter";
9+
import axios from "axios";
10+
import folderContentMock from "../__tests__/folderContentMock.json";
11+
12+
storiesOf("Filesystem", module).add("NewFolderModal", () => {
13+
const API_REQUEST = hostname + filesystemPath + "2/folder/create";
14+
15+
const mock = new MockAdapter(axios);
16+
mock.onPost(API_REQUEST).reply(200, folderContentMock[0]);
17+
18+
return (
19+
<Provider store={store}>
20+
<BrowserRouter>
21+
<NewFolderModalContent
22+
handleClose={() => {}}
23+
currentFsItemId={"2"}
24+
/>
25+
</BrowserRouter>
26+
</Provider>
27+
);
28+
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ function NewFolderModalContent({ handleClose, currentFsItemId }: Props) {
3434
setError("");
3535
handleClose();
3636
})
37-
.catch((error) =>
37+
.catch((error) => {
3838
setError(
39-
error.response?.data.message ?? "Something went wrong :("
40-
)
41-
);
39+
error.response?.data?.message ?? "Something went wrong :("
40+
);
41+
});
4242
}
4343

4444
return (

0 commit comments

Comments
 (0)