Skip to content

Commit

Permalink
Add path and commit summary to diff (#919)
Browse files Browse the repository at this point in the history
Change-Id: diff-path-summary
  • Loading branch information
christian-schilling authored Aug 30, 2022
1 parent c249e59 commit f09e50a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
33 changes: 20 additions & 13 deletions josh-ui/src/DiffViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type DiffViewerProps = {
type State = {
content_a?: string
content_b?: string
summary: string
client: GraphQLClient
}

Expand All @@ -37,6 +38,7 @@ export class DiffViewer extends React.Component<DiffViewerProps, State> {
state = {
content_a: undefined,
content_b: undefined,
summary: "",
client: new GraphQLClient(`${getServer()}/~/graphql/${this.props.repo}`, {
mode: 'cors',
errorPolicy: 'all'
Expand Down Expand Up @@ -64,26 +66,31 @@ export class DiffViewer extends React.Component<DiffViewerProps, State> {

this.setState({
content_a: content_a,
content_b: content_b
content_b: content_b,
summary: data.summary,
})
})
}

render() {
if (this.state.content_a !== undefined
&& this.state.content_b !== undefined) {
return <DiffEditor
modified={this.state.content_b}
original={this.state.content_a}
language={mapLanguage(this.props.path)}
height='80vh'
theme='vs-dark'
options={{
readOnly: true,
domReadOnly: true,
cursorBlinking: 'solid',
}}
/>
return <div>
<div>{this.state.summary}</div>
<div>{this.props.path}</div>
<DiffEditor
modified={this.state.content_b}
original={this.state.content_a}
language={mapLanguage(this.props.path)}
height='80vh'
theme='vs-dark'
options={{
readOnly: true,
domReadOnly: true,
cursorBlinking: 'solid',
}}
/>
</div>
} else
{
return <div>Loading...</div>
Expand Down
1 change: 1 addition & 0 deletions josh-ui/src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ query($rev: String!, $filter: String!, $path: String!) {
export const QUERY_FILE_DIFF = gql`
query($rev: String!, $filter: String!, $path: String!) {
rev(at:$rev, filter:$filter) {
summary
history(limit: 2) {
file(path:$path) {
text
Expand Down

0 comments on commit f09e50a

Please sign in to comment.