Skip to content

Commit e84179a

Browse files
ValentinHCompuIves
authored andcommitted
Disable fork button while forking (#1667)
* Disable fork button while forking Fixes #844. This is a first fix. I'd like to work on a better feedback, maybe a circular loader inside the button. What do you think? * Change the text to "Forking" while forking * Also disabled the "Fork Sandbox" button in Workspace More * Forking... * Forking... 2
1 parent aacb2be commit e84179a

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

packages/app/src/app/pages/Sandbox/Editor/Header/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ type ButtonProps = {
4646
secondary?: boolean;
4747
};
4848

49+
type ForkButtonProps = ButtonProps & {
50+
isForking: boolean;
51+
};
52+
4953
const LikeButton = ({
5054
store,
5155
signals,
@@ -64,18 +68,24 @@ const LikeButton = ({
6468
/>
6569
);
6670

67-
const ForkButton = ({ signals, secondary, style }: ButtonProps) => (
71+
const ForkButton = ({
72+
signals,
73+
secondary,
74+
isForking,
75+
style,
76+
}: ForkButtonProps) => (
6877
<Button
6978
onClick={() => {
7079
signals.editor.forkSandboxClicked();
7180
}}
7281
style={style}
7382
secondary={secondary}
83+
disabled={isForking}
7484
small
7585
>
7686
<>
7787
<Fork style={{ marginRight: '.5rem' }} />
78-
Fork
88+
{isForking ? 'Forking...' : 'Fork'}
7989
</>
8090
</Button>
8191
);
@@ -210,6 +220,7 @@ const Header = ({ store, signals, zenMode }: Props) => {
210220
/>
211221
<ForkButton
212222
secondary={sandbox.owned}
223+
isForking={store.editor.isForkingSandbox}
213224
style={{ fontSize: '.75rem' }}
214225
signals={signals}
215226
store={store}

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/More/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,21 @@ class More extends React.PureComponent<Props> {
2727

2828
render() {
2929
const { owned } = this.props.store.editor.currentSandbox;
30+
const { isForkingSandbox } = this.props.store.editor;
3031
const message = !owned ? NOT_OWNED_MESSAGE : NOT_SIGNED_IN_MESSAGE;
3132

3233
return (
3334
<div>
3435
<Description>{message}</Description>
3536
<Margin margin={1}>
3637
{!owned ? (
37-
<Button small block onClick={this.forkSandbox}>
38-
Fork Sandbox
38+
<Button
39+
small
40+
block
41+
disabled={isForkingSandbox}
42+
onClick={this.forkSandbox}
43+
>
44+
{isForkingSandbox ? 'Forking Sandbox...' : 'Fork Sandbox'}
3945
</Button>
4046
) : (
4147
<SignInButton block />

0 commit comments

Comments
 (0)