Skip to content

Commit

Permalink
fix: dashboard regression: console warnings and refetchQueries (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihebi committed Aug 3, 2023
1 parent 42dac7b commit 407b171
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 51 deletions.
2 changes: 1 addition & 1 deletion ui/src/lib/fetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function doRemoteLoadRepo(client: ApolloClient<any>, id: string) {
fetchPolicy: "no-cache",
});
// refetch queries
await client.refetchQueries({ include: ["GetRepos", "GetCollabRepos"] });
await client.refetchQueries({ include: ["GetDashboardRepos"] });
// We need to do a deep copy here, because apollo client returned immutable objects.
let pods = res.data.repo.pods.map((pod) => ({ ...pod }));
let edges = res.data.repo.edges;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/lib/store/repoMetaSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const createRepoMetaSlice: StateCreator<
id: repoId,
name: repoName,
},
refetchQueries: ["GetRepos", "GetCollabRepos"],
refetchQueries: ["GetDashboardRepos"],
});
set((state) =>
produce(state, (state) => {
Expand Down
96 changes: 47 additions & 49 deletions ui/src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,32 +165,32 @@ const KillRuntimeButton = ({ repo }) => {
<Box>
{/* last active: {getUpTime(info.lastActive)} */}
<Tooltip title={getUpTime(info.lastActive)} placement="top">
{/* <Box> */}
<Tooltip title="Kill runtime">
<IconButton
disabled={killing}
size="small"
sx={{
"&:hover": {
color: theme.palette.error.main,
},
}}
onClick={async () => {
killRuntime({
variables: {
sessionId: `${me.id}_${repo.id}`,
<Box>
<Tooltip title="Kill runtime">
<IconButton
disabled={killing}
size="small"
sx={{
"&:hover": {
color: theme.palette.error.main,
},
});
}}
>
{killing ? (
<CircularProgress size="14px" />
) : (
<StopCircleIcon fontSize="inherit" />
)}
</IconButton>
</Tooltip>
{/* </Box> */}
}}
onClick={async () => {
killRuntime({
variables: {
sessionId: `${me.id}_${repo.id}`,
},
});
}}
>
{killing ? (
<CircularProgress size="14px" />
) : (
<StopCircleIcon fontSize="inherit" />
)}
</IconButton>
</Tooltip>
</Box>
</Tooltip>
</Box>
);
Expand Down Expand Up @@ -276,29 +276,27 @@ const RepoCard = ({ repo }) => {
return (
<Card sx={{ minWidth: 275, maxWidth: 275 }}>
<CardContent>
<Typography variant="body1" gutterBottom>
<Stack direction="row" display="flex">
<Link
component={ReactLink}
to={`/repo/${repo.id}`}
sx={{
alignItems: "center",
}}
>
<Stack direction="row" display="inline-flex">
<DescriptionOutlinedIcon
sx={{
marginRight: "5px",
}}
/>
<Box component="span">{repo.name || "Untitled"}</Box>
</Stack>
</Link>
<Box ml="auto">
<StarButton repo={repo} />
</Box>
</Stack>
</Typography>
<Stack direction="row" display="flex">
<Link
component={ReactLink}
to={`/repo/${repo.id}`}
sx={{
alignItems: "center",
}}
>
<Stack direction="row" display="inline-flex">
<DescriptionOutlinedIcon
sx={{
marginRight: "5px",
}}
/>
<Box component="span">{repo.name || "Untitled"}</Box>
</Stack>
</Link>
<Box ml="auto">
<StarButton repo={repo} />
</Box>
</Stack>
<Typography variant="subtitle2" color="gray">
<Stack direction="row">
Viewed{" "}
Expand Down Expand Up @@ -410,7 +408,7 @@ const RepoLists = () => {
)}
<Box display="flex" flexWrap="wrap">
{repos.map((repo) => (
<Box sx={{ m: 1 }}>
<Box sx={{ m: 1 }} key={repo.id}>
<RepoCard repo={repo} />
</Box>
))}
Expand Down

0 comments on commit 407b171

Please sign in to comment.