-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into delete-project-data
- Loading branch information
Showing
52 changed files
with
1,107 additions
and
670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,7 +192,7 @@ There are two types of file system build caching. These greatly improve the time | |
It is handy to have a user with admin rights in your dev cocalc server. With the database running you can make a `[email protected]` an admin as follows: | ||
|
||
```sh | ||
~/cocalc/src$ pnpm run c | ||
~/cocalc/src$ pnpm install -D express && pnpm run c | ||
... | ||
> db.make_user_admin({email_address:'[email protected]', cb:console.log}) | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,68 @@ | ||
import { Button } from "antd"; | ||
import { Icon } from "./icon"; | ||
import { CSSProperties } from "react"; | ||
import { CSSProperties, useState } from "react"; | ||
import ShowError from "@cocalc/frontend/components/error"; | ||
|
||
interface Props { | ||
refresh: () => void; | ||
refresh: Function; | ||
style?: CSSProperties; | ||
refreshing?; | ||
setRefreshing?; | ||
} | ||
|
||
export default function Refresh({ refresh, style }: Props) { | ||
export default function Refresh({ | ||
refresh, | ||
style, | ||
refreshing, | ||
setRefreshing, | ||
}: Props) { | ||
if (refreshing == null) { | ||
return <UnControlled refresh={refresh} style={style} />; | ||
} else { | ||
return ( | ||
<Controlled | ||
refresh={refresh} | ||
style={style} | ||
refreshing={refreshing} | ||
setRefreshing={setRefreshing} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
function UnControlled({ refresh, style }) { | ||
const [refreshing, setRefreshing] = useState<boolean>(false); | ||
return ( | ||
<Controlled | ||
refresh={refresh} | ||
style={style} | ||
refreshing={refreshing} | ||
setRefreshing={setRefreshing} | ||
/> | ||
); | ||
} | ||
|
||
function Controlled({ refresh, style, refreshing, setRefreshing }) { | ||
const [error, setError] = useState<string>(""); | ||
return ( | ||
<Button onClick={refresh} style={style}> | ||
<Icon name="refresh" /> Refresh | ||
</Button> | ||
<> | ||
<Button | ||
onClick={async () => { | ||
try { | ||
setError(""); | ||
setRefreshing?.(true); | ||
await refresh(); | ||
} catch (err) { | ||
setError(`${err}`); | ||
} finally { | ||
setRefreshing?.(false); | ||
} | ||
}} | ||
style={style} | ||
> | ||
<Icon name="refresh" spin={refreshing} /> Refresh | ||
</Button> | ||
<ShowError error={error} setError={setError} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.