Skip to content

Commit 96adf43

Browse files
committed
fix #7857 -- make that you must start a project to see its files clearer
- this is not the more ambitious "right" fix discussed on this issue, but should help a lot anyways
1 parent f141120 commit 96adf43

File tree

2 files changed

+61
-34
lines changed

2 files changed

+61
-34
lines changed

src/packages/frontend/project/explorer/explorer.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,7 @@ const Explorer0 = rclass(
482482
className="smc-vfill"
483483
>
484484
<FileListing
485-
isRunning={
486-
this.props.project_map?.getIn([
487-
this.props.project_id,
488-
"state",
489-
"state",
490-
]) == "running"
491-
}
485+
isRunning={project_is_running}
492486
name={this.props.name}
493487
active_file_sort={this.props.active_file_sort}
494488
listing={listing}
@@ -732,12 +726,10 @@ const Explorer0 = rclass(
732726
project_is_running = true;
733727
// next, we check if this is a common user (not public)
734728
} else if (my_group !== "public") {
735-
if (this.props.project_map != undefined) {
736-
project_state = this.props.project_map.getIn([
737-
this.props.project_id,
738-
"state",
739-
]) as any;
740-
}
729+
project_state = this.props.project_map?.getIn([
730+
this.props.project_id,
731+
"state",
732+
]) as any;
741733
project_is_running = project_state?.get("state") == "running";
742734
} else {
743735
project_is_running = false;

src/packages/frontend/project/explorer/file-listing/file-listing.tsx

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as immutable from "immutable";
99
import React, { useEffect, useRef, useState } from "react";
1010
import { useInterval } from "react-interval-hook";
1111
import { Virtuoso, VirtuosoHandle } from "react-virtuoso";
12-
12+
import { Alert, Spin } from "antd";
1313
import {
1414
AppRedux,
1515
Rendered,
@@ -65,26 +65,26 @@ export function watchFiles({ actions, current_path }): void {
6565
}
6666
}
6767

68-
export const FileListing: React.FC<Props> = (props: Props) => {
69-
const {
70-
actions,
71-
redux,
72-
name,
73-
active_file_sort,
74-
listing,
75-
file_map,
76-
checked_files,
77-
current_path,
78-
create_folder,
79-
create_file,
80-
selected_file_index,
81-
project_id,
82-
shift_is_down,
83-
sort_by,
84-
configuration_main,
85-
file_search = "",
86-
isRunning,
87-
} = props;
68+
export const FileListing: React.FC<Props> = ({
69+
actions,
70+
redux,
71+
name,
72+
active_file_sort,
73+
listing,
74+
file_map,
75+
checked_files,
76+
current_path,
77+
create_folder,
78+
create_file,
79+
selected_file_index,
80+
project_id,
81+
shift_is_down,
82+
sort_by,
83+
configuration_main,
84+
file_search = "",
85+
isRunning,
86+
}: Props) => {
87+
const [starting, setStarting] = useState<boolean>(false);
8888

8989
const prev_current_path = usePrevious(current_path);
9090

@@ -229,6 +229,41 @@ export const FileListing: React.FC<Props> = (props: Props) => {
229229
}
230230
}
231231

232+
if (!isRunning && listing.length == 0) {
233+
return (
234+
<Alert
235+
style={{
236+
textAlign: "center",
237+
margin: "15px auto",
238+
maxWidth: "400px",
239+
}}
240+
showIcon
241+
type="warning"
242+
message={
243+
<div style={{ padding: "30px", fontSize: "14pt" }}>
244+
<a
245+
onClick={async () => {
246+
if (starting) return;
247+
try {
248+
setStarting(true);
249+
await actions.fetch_directory_listing_directly(
250+
current_path,
251+
true,
252+
);
253+
} finally {
254+
setStarting(false);
255+
}
256+
}}
257+
>
258+
Start this project to see your files.
259+
{starting && <Spin />}
260+
</a>
261+
</div>
262+
}
263+
/>
264+
);
265+
}
266+
232267
return (
233268
<>
234269
{!isRunning && listing.length > 0 && (

0 commit comments

Comments
 (0)