Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/graphql-playground-react/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface Props {
endpoint: string
subscriptionEndpoint?: string
projectId?: string
shareEnabled?: boolean
adminAuthToken?: string
onSuccess?: (graphQLParams: any, response: any) => void
isEndpoint?: boolean
Expand Down Expand Up @@ -123,6 +124,10 @@ export interface CursorPosition {
export { GraphQLEditor }

export class Playground extends React.PureComponent<Props & ReduxProps, State> {
static defaultProps = {
shareEnabled: true,
}

apolloLinks: { [sessionId: string]: any } = {}
observers: { [sessionId: string]: any } = {}
graphiqlComponents: any[] = []
Expand Down Expand Up @@ -277,7 +282,10 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
) : this.props.isFile && this.props.file ? (
<FileEditor />
) : (
<GraphQLEditor schema={this.state.schema} />
<GraphQLEditor
shareEnabled={this.props.shareEnabled}
schema={this.state.schema}
/>
)}
</GraphiqlWrapper>
</GraphiqlsContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { ResponseRecord } from '../../state/sessions/reducers'

export interface Props {
onRef?: any
shareEnabled?: boolean
schema?: GraphQLSchema
}

Expand Down Expand Up @@ -248,7 +249,7 @@ class GraphQLEditor extends React.PureComponent<
}
`}</style>
<div className="editorWrap">
<TopBar />
<TopBar shareEnabled={this.props.shareEnabled} />
<div
ref={this.setEditorBarComponent}
className="editorBar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { openHistory } from '../../../state/general/actions'

export interface Props {
endpoint: string
shareEnabled?: boolean
fixedEndpoint?: boolean
isReloadingSchema: boolean
endpointUnreachable: boolean
Expand Down Expand Up @@ -75,9 +76,11 @@ class TopBar extends React.Component<Props, {}> {
)}
</UrlBarWrapper>
<Button onClick={this.copyCurlToClipboard}>Copy CURL</Button>
<Share>
<Button>Share Playground</Button>
</Share>
{this.props.shareEnabled && (
<Share>
<Button>Share Playground</Button>
</Share>
)}
</TopBarWrapper>
)
}
Expand Down