Skip to content

Commit e7adb35

Browse files
sepehr500timsuchanek
authored andcommitted
Add ability to remove share button (#642)
1 parent c93fb04 commit e7adb35

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface Props {
5959
endpoint: string
6060
subscriptionEndpoint?: string
6161
projectId?: string
62+
shareEnabled?: boolean
6263
adminAuthToken?: string
6364
onSuccess?: (graphQLParams: any, response: any) => void
6465
isEndpoint?: boolean
@@ -122,6 +123,10 @@ export interface CursorPosition {
122123
export { GraphQLEditor }
123124

124125
export class Playground extends React.PureComponent<Props & ReduxProps, State> {
126+
static defaultProps = {
127+
shareEnabled: true,
128+
}
129+
125130
apolloLinks: { [sessionId: string]: any } = {}
126131
observers: { [sessionId: string]: any } = {}
127132
graphiqlComponents: any[] = []
@@ -271,7 +276,10 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
271276
) : this.props.isFile && this.props.file ? (
272277
<FileEditor />
273278
) : (
274-
<GraphQLEditor schema={this.state.schema} />
279+
<GraphQLEditor
280+
shareEnabled={this.props.shareEnabled}
281+
schema={this.state.schema}
282+
/>
275283
)}
276284
</GraphiqlWrapper>
277285
</GraphiqlsContainer>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { ResponseRecord } from '../../state/sessions/reducers'
6767

6868
export interface Props {
6969
onRef?: any
70+
shareEnabled?: boolean
7071
schema?: GraphQLSchema
7172
}
7273

@@ -248,7 +249,7 @@ class GraphQLEditor extends React.PureComponent<
248249
}
249250
`}</style>
250251
<div className="editorWrap">
251-
<TopBar />
252+
<TopBar shareEnabled={this.props.shareEnabled} />
252253
<div
253254
ref={this.setEditorBarComponent}
254255
className="editorBar"

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { openHistory } from '../../../state/general/actions'
2828

2929
export interface Props {
3030
endpoint: string
31+
shareEnabled?: boolean
3132
fixedEndpoint?: boolean
3233
isReloadingSchema: boolean
3334
endpointUnreachable: boolean
@@ -75,9 +76,11 @@ class TopBar extends React.Component<Props, {}> {
7576
)}
7677
</UrlBarWrapper>
7778
<Button onClick={this.copyCurlToClipboard}>Copy CURL</Button>
78-
<Share>
79-
<Button>Share Playground</Button>
80-
</Share>
79+
{this.props.shareEnabled && (
80+
<Share>
81+
<Button>Share Playground</Button>
82+
</Share>
83+
)}
8184
</TopBarWrapper>
8285
)
8386
}

0 commit comments

Comments
 (0)