Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphiql): solve vertical scrolling issue #1188

Merged
merged 1 commit into from
Nov 18, 2019
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
93 changes: 54 additions & 39 deletions postgraphiql/src/components/PostGraphiQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,13 @@ class PostGraphiQL extends React.PureComponent {
return <GraphiQL {...sharedProps} />;
} else {
return (
<div className="postgraphiql-container graphiql-container">
<div
className={`postgraphiql-container graphiql-container ${
this.state.explain && this.state.explainResult && this.state.explainResult.length
? 'explain-mode'
: ''
}`}
>
<GraphiQLExplorer
schema={schema}
query={this.state.query}
Expand Down Expand Up @@ -704,16 +710,23 @@ class PostGraphiQL extends React.PureComponent {
<GraphiQL.Footer>
<div className="postgraphile-footer">
{this.state.explainResult && this.state.explainResult.length ? (
<div>
<h4>Explain: analysis of executed queries</h4>
<div className="postgraphile-plan-footer">
{this.state.explainResult.map(res => (
<div>
<pre>
<code>{formatSQL(res.query)}</code>
</pre>
<pre>
<h4>
Result from SQL{' '}
<a href="https://www.postgresql.org/docs/current/sql-explain.html">
EXPLAIN
</a>{' '}
on executed query:
</h4>
<pre className="explain-plan">
<code>{res.plan}</code>
</pre>
<h4>Executed SQL query:</h4>
<pre className="explain-sql">
<code>{formatSQL(res.query)}</code>
</pre>
</div>
))}
<p>
Expand All @@ -723,38 +736,40 @@ class PostGraphiQL extends React.PureComponent {
<hr />
</div>
) : null}
PostGraphile:{' '}
<a
title="Open PostGraphile documentation"
href="https://graphile.org/postgraphile/introduction/"
target="new"
>
Documentation
</a>{' '}
|{' '}
<a
title="Open PostGraphile documentation"
href="https://graphile.org/postgraphile/examples/"
target="new"
>
Examples
</a>{' '}
|{' '}
<a
title="PostGraphile is supported by the community, please sponsor ongoing development"
href="https://graphile.org/sponsor/"
target="new"
>
Sponsor
</a>{' '}
|{' '}
<a
title="Get support from the team behind PostGraphile"
href="https://graphile.org/support/"
target="new"
>
Support
</a>
<div className="postgraphile-regular-footer">
PostGraphile:{' '}
<a
title="Open PostGraphile documentation"
href="https://graphile.org/postgraphile/introduction/"
target="new"
>
Documentation
</a>{' '}
|{' '}
<a
title="Open PostGraphile documentation"
href="https://graphile.org/postgraphile/examples/"
target="new"
>
Examples
</a>{' '}
|{' '}
<a
title="PostGraphile is supported by the community, please sponsor ongoing development"
href="https://graphile.org/sponsor/"
target="new"
>
Sponsor
</a>{' '}
|{' '}
<a
title="Get support from the team behind PostGraphile"
href="https://graphile.org/support/"
target="new"
>
Support
</a>
</div>
</div>
</GraphiQL.Footer>
</GraphiQL>
Expand Down
35 changes: 31 additions & 4 deletions postgraphiql/src/components/postgraphiql.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,36 @@
margin: 0;
}

.resultWrap .footer {
max-height: 50%;
.resultWrap .result-window {
flex: 1 1 100%;
}

.explain-mode .resultWrap .footer {
flex: 1 1 100%;
position: relative;
}

.explain-mode .postgraphile-footer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
overflow-x: hidden;
}

.postgraphile-footer {
line-height: 30px;
overflow: hidden;
display: block;
align-items: center;
padding: 0 0 0 1rem;
white-space: nowrap;
text-overflow: ellipsis;
max-height: 100%;
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: space-between;
}
.postgraphile-footer a {
text-decoration: none;
Expand All @@ -61,6 +78,16 @@
line-height: 1.1em;
background-color: rgba(0, 0, 0, 0.1);
}

.explain-plan,
.explain-sql {
max-height: 8.8em; /* line-height is 1.1em */
overflow: auto;
}
.explain-plan {
max-height: 13.2em; /* line-height is 1.1em */
}

.resultWrap {
width: 5rem;
}
Expand Down