Skip to content

Commit e0be1e6

Browse files
committed
Fix #98, Fix #94, Fix #103
1 parent 4f80a77 commit e0be1e6

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

packages/graphql-playground/src/components/Playground.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export interface State {
9090
shareAllTabs: boolean
9191
shareHttpHeaders: boolean
9292
shareHistory: boolean
93+
changed: boolean
9394
}
9495

9596
export interface CursorPosition {
@@ -195,6 +196,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
195196
shareAllTabs: true,
196197
shareHttpHeaders: true,
197198
shareHistory: true,
199+
changed: false,
198200
}
199201

200202
if (typeof window === 'object') {
@@ -580,6 +582,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
580582
allTabs={this.state.shareAllTabs}
581583
httpHeaders={this.state.shareHttpHeaders}
582584
shareUrl={this.props.shareUrl}
585+
reshare={this.state.changed}
583586
/>
584587
<GraphDocs schema={this.state.schemaCache} />
585588
{this.state.historyOpen &&
@@ -652,6 +655,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
652655
...state,
653656
sessions: state.sessions.concat(session),
654657
selectedSessionIndex: newIndexZero ? 0 : state.sessions.length,
658+
changed: true,
655659
}
656660
})
657661
}
@@ -833,6 +837,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
833837
...state.sessions.slice(i + 1, state.sessions.length),
834838
],
835839
selectedSessionIndex: nextSelectedSession,
840+
changed: true,
836841
}
837842
})
838843

@@ -1045,6 +1050,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
10451050
return {
10461051
...state,
10471052
sessions: Immutable.setIn(state.sessions, [i, key], value),
1053+
changed: true,
10481054
}
10491055
},
10501056
() => {
@@ -1235,11 +1241,11 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
12351241
}
12361242

12371243
private share = () => {
1238-
// noop
12391244
this.saveSessions()
12401245
this.saveHistory()
12411246
this.storage.saveProject()
12421247
this.props.share(this.storage.project)
1248+
this.setState({ changed: false })
12431249
}
12441250
}
12451251

packages/graphql-playground/src/components/Share.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Props {
1818
onToggleHistory: () => void
1919
onShare: () => void
2020
shareUrl?: string
21-
// reshare: boolean
21+
reshare: boolean
2222
}
2323

2424
interface State {
@@ -156,26 +156,26 @@ export default class Share extends React.Component<Props, State> {
156156
</span>
157157
<ToggleButton checked={history} onChange={onToggleHistory} />
158158
</div>
159-
{!shareUrl
160-
? <div className="row">
161-
<div />
162-
<Button hideArrow={true} onClick={onShare}>
163-
Share
164-
</Button>
159+
{shareUrl &&
160+
<div className="row">
161+
<input value={shareUrl} disabled={true} />
162+
<div className="copy">
163+
<Copy text={shareUrl}>
164+
<Icon
165+
src={require('graphcool-styles/icons/fill/copy.svg')}
166+
color={$v.darkBlue30}
167+
width={25}
168+
height={25}
169+
/>
170+
</Copy>
165171
</div>
166-
: <div className="row">
167-
<input value={shareUrl} disabled={true} />
168-
<div className="copy">
169-
<Copy text={shareUrl}>
170-
<Icon
171-
src={require('graphcool-styles/icons/fill/copy.svg')}
172-
color={$v.darkBlue30}
173-
width={25}
174-
height={25}
175-
/>
176-
</Copy>
177-
</div>
178-
</div>}
172+
</div>}
173+
<div className="row">
174+
<div />
175+
<Button hideArrow={true} onClick={onShare}>
176+
{reshare || shareUrl ? 'Reshare' : 'Share'}
177+
</Button>
178+
</div>
179179
</div>
180180
</Tooltip>
181181
</div>

0 commit comments

Comments
 (0)