Skip to content

Commit

Permalink
Add ability to remove share button (graphql#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr500 authored and timsuchanek committed Apr 13, 2018
1 parent ab0fdda commit 1777aaa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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 @@ -122,6 +123,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 @@ -271,7 +276,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

0 comments on commit 1777aaa

Please sign in to comment.