-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
823 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React, { Component } from 'react'; | ||
import { | ||
ipcRenderer, | ||
} from 'electron'; | ||
|
||
import Spinner from '@atlaskit/spinner'; | ||
import { | ||
AppWrapper, | ||
FullPageSpinner, | ||
} from 'styles'; | ||
|
||
|
||
class IssueForm extends Component<{}, any> { | ||
constructor(props: {}) { | ||
super(props); | ||
this.state = { | ||
show: true, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
ipcRenderer.on('url', this.onLoadUrl); | ||
ipcRenderer.on('page-fully-loaded', () => { | ||
setTimeout(() => { | ||
this.setState({ | ||
show: false, | ||
}); | ||
document.getElementById('root').style.display = 'none'; | ||
}, 500); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
ipcRenderer.removeListener('url', this.onLoadUrl); | ||
} | ||
|
||
onLoadUrl = ( | ||
ev, | ||
{ | ||
url, | ||
projectId, | ||
issueId, | ||
}, | ||
) => { | ||
const webview = document.createElement('webview'); | ||
webview.setAttribute('preload', './preload.js'); | ||
webview.style.height = '100%'; | ||
webview.addEventListener('did-finish-load', () => { | ||
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === true) { | ||
webview.openDevTools(); | ||
} | ||
webview.executeJavaScript(` | ||
document.getElementById('page').style.display = 'none'; | ||
var issueForm = JIRA.Forms | ||
${issueId ? | ||
`.createEditIssueForm({ issueId: ${issueId} })` : | ||
`.createCreateIssueForm({ pid: ${projectId} })` | ||
} | ||
.bind('sessionComplete', function(ev, issues) { | ||
${issueId ? | ||
`ipcRenderer.send("issue-refetch", "${issueId}");` : | ||
'ipcRenderer.send("issue-created", issues);' | ||
} | ||
ipcRenderer.send('close-page'); | ||
}) | ||
.asDialog({ | ||
windowTitle: ${issueId ? '"Edit issue"' : '"Create Issue"'} | ||
}); | ||
issueForm.show(); | ||
var timerId = setInterval(function() { | ||
if (issueForm.$buttonContainer) { | ||
var cancel = issueForm.$buttonContainer[0].getElementsByClassName('cancel'); | ||
cancel[0].addEventListener('click', function (event) { | ||
ipcRenderer.send('close-page'); | ||
}); | ||
clearInterval(timerId); | ||
document.getElementById('qf-field-picker-trigger').remove(); | ||
var forRemove = document.getElementsByClassName('aui-blanket'); | ||
forRemove[0].remove(); | ||
var formBody = issueForm.$form.children()[0]; | ||
var jiraDialog = issueForm.$popup[0]; | ||
formBody.style.maxHeight = (parseInt(formBody.style.maxHeight.replace('px', ''), 10) + 120).toString() + 'px'; | ||
jiraDialog.style.marginTop = (parseInt(jiraDialog.style.marginTop.replace('px', ''), 10) - 65).toString() + 'px'; | ||
ipcRenderer.send('page-fully-loaded'); | ||
} | ||
}, 500); | ||
`); | ||
}); | ||
webview.src = url; | ||
document.getElementById('forWebview').appendChild(webview); | ||
} | ||
|
||
render() { | ||
if (this.state.show) { | ||
return ( | ||
<AppWrapper id="app"> | ||
<FullPageSpinner> | ||
<Spinner size="xlarge" /> | ||
</FullPageSpinner> | ||
</AppWrapper> | ||
); | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
export default IssueForm; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<style type="text/css"> | ||
body { | ||
font-family: Open Sans; | ||
margin: 0px; | ||
padding: 0px; | ||
background-color: white; | ||
height: 100%; | ||
} | ||
|
||
html, body, #app, #root, #forWebview { | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
</style> | ||
<script> | ||
(() => { | ||
if (!process.env.HOT) { | ||
const link = document.createElement('link'); | ||
link.rel = 'stylesheet'; | ||
link.href = './dist/style.css'; | ||
// HACK: Writing the script path should be done with webpack | ||
document.getElementsByTagName('head')[0].appendChild(link); | ||
} | ||
})(); | ||
</script> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<div id="forWebview"></div> | ||
<script> | ||
{ | ||
// Dynamically include DLL if in development | ||
if (process.env.NODE_ENV === 'development') { | ||
const dllScript = document.createElement('script'); | ||
dllScript.src = '../dll/vendor.dll.js'; | ||
document.body.appendChild(dllScript); | ||
} | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
const commonsScript = document.createElement('script'); | ||
commonsScript.src = './dist/commons.js'; | ||
document.body.appendChild(commonsScript); | ||
} | ||
|
||
// Dynamically insert the renderer process | ||
const script = document.createElement('script'); | ||
const port = process.env.PORT || 1212; | ||
|
||
script.src = (process.env.HOT) | ||
? 'http://localhost:' + port + '/dist/issueForm-bundle.js' | ||
: './dist/issueForm-bundle.js'; | ||
|
||
// @HACK: Writing the script path should be done | ||
// with HtmlWebpackPlugin | ||
document.body.appendChild(script); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { | ||
render, | ||
} from 'react-dom'; | ||
|
||
import IssueForm from './containers/Popups/IssueForm/IssueForm'; | ||
|
||
render( | ||
<IssueForm />, | ||
document.getElementById('root') || document.createElement('div'), | ||
); |
Oops, something went wrong.