summaryrefslogtreecommitdiff
path: root/kodereviewer
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer')
-rw-r--r--kodereviewer/network_manager.py19
-rw-r--r--kodereviewer/qml/CommentPage.qml87
-rw-r--r--kodereviewer/qml/Editor.qml2
-rw-r--r--kodereviewer/qml/FilesChangedPage.qml75
-rw-r--r--kodereviewer/qml/Main.qml89
-rw-r--r--kodereviewer/qml/PullRequestDescriptionPage.qml41
-rw-r--r--kodereviewer/qml/PullRequestPage.qml64
-rw-r--r--kodereviewer/qml/ReviewList.qml2
-rw-r--r--kodereviewer/qml/ReviewListPage.qml40
9 files changed, 347 insertions, 72 deletions
diff --git a/kodereviewer/network_manager.py b/kodereviewer/network_manager.py
index 089e69e..cbe5160 100644
--- a/kodereviewer/network_manager.py
+++ b/kodereviewer/network_manager.py
@@ -83,7 +83,14 @@ class NetworkManager(QObject):
pull_request_number = int(match.groups()[0])
pull_request = self._project.find_pull_request(pull_request_number)
if pull_request is not None:
- pull_request.load_comments(response_body)
+
+ # List
+ if reply.operation() == QNetworkAccessManager.Operation.GetOperation:
+ pull_request.load_comments(response_body)
+ elif reply.operation() == QNetworkAccessManager.Operation.PostOperation:
+ logger.info(response_body)
+ else:
+ logger.info("Pero la puta")
elif (match := FILE_LIST_URL.search(reply.url().toString())):
pull_request_number = int(match.groups()[0])
pull_request: Optional[PullRequest] = self._project.find_pull_request(pull_request_number)
@@ -109,6 +116,16 @@ class NetworkManager(QObject):
self._request_factory.createRequest(f'/issues/{number}/comments')
)
+ @Slot(int, str)
+ def createComment(self, number: int, comment: str) -> None:
+ request = self._request_factory.createRequest(
+ f'/issues/{number}/comments'
+ )
+ data = {
+ 'body': comment
+ }
+ self._manager.post(request, json.dumps(data).encode())
+
@Slot(int)
def getFiles(self, pull_request_number) -> None:
self._manager.get(
diff --git a/kodereviewer/qml/CommentPage.qml b/kodereviewer/qml/CommentPage.qml
new file mode 100644
index 0000000..bcf6cb5
--- /dev/null
+++ b/kodereviewer/qml/CommentPage.qml
@@ -0,0 +1,87 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as QQC2
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+import org.kde.kirigamiaddons.components as KirigamiComponents
+import org.deprecated.kodereviewer 1.0
+
+
+Kirigami.ScrollablePage {
+ id: root
+
+ property var pullRequest
+ property NetworkManager connection
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+
+ title: pullRequest ? pullRequest.title : ""
+
+ Timer {
+ // Ten minutes?
+ id: getCommentsTimer
+ interval: 1000 * 60 * 10
+ running: false
+ repeat: true
+ triggeredOnStart: true
+ onTriggered: {
+ console.log("Getting comments from timer")
+ root.connection.getPullRequestComments(root.pullRequest.number)
+ }
+ }
+
+ Loader {
+ id: commentModelLoader
+ active: !!root.pullRequest
+ sourceComponent: CommentModel {
+ id: commentModel
+ pullRequest: root.pullRequest
+
+ onPullRequestChanged: getCommentsTimer.restart()
+ }
+ onActiveChanged: console.log("active? " + active + " pull request: " + root.pullRequest)
+ }
+
+ Kirigami.CardsListView {
+ id: commentsListView
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ visible: !!root.pullRequest
+ model: commentModelLoader.item
+ delegate: CommentDelegate {}
+ footerPositioning: ListView.InlineFooter
+ footer: Item {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: footerLayout.implicitHeight
+ RowLayout {
+ id: footerLayout
+ anchors.fill: parent
+ anchors.topMargin: Kirigami.Units.largeSpacing * 2
+ MarkdownTextArea {
+ id: newCommentTextArea
+ Layout.fillWidth: true
+ }
+ QQC2.Button {
+ icon.name: "document-send-symbolic"
+ enabled: newCommentTextArea.text != ''
+
+ onClicked: {
+ if (newCommentTextArea.text == '') {
+ return
+ }
+
+ root.connection.createComment(root.pullRequest.number, newCommentTextArea.text)
+ newCommentTextArea.text == ''
+ getCommentsTimer.restart()
+ }
+ }
+ }
+
+ }
+ }
+}
diff --git a/kodereviewer/qml/Editor.qml b/kodereviewer/qml/Editor.qml
index fdd1cbd..c261eeb 100644
--- a/kodereviewer/qml/Editor.qml
+++ b/kodereviewer/qml/Editor.qml
@@ -13,7 +13,7 @@ TextEdit {
id: root
- required property string file
+ property string file: ''
signal commentClicked(string path, int startLine, int endLine)
signal newComment(string path, int startLine, int endLine)
diff --git a/kodereviewer/qml/FilesChangedPage.qml b/kodereviewer/qml/FilesChangedPage.qml
new file mode 100644
index 0000000..e74b59c
--- /dev/null
+++ b/kodereviewer/qml/FilesChangedPage.qml
@@ -0,0 +1,75 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as QQC2
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+import org.kde.kirigamiaddons.components as KirigamiComponents
+
+import org.deprecated.kodereviewer 1.0
+
+Kirigami.ScrollablePage {
+ id: root
+
+ property var pullRequest
+ property NetworkManager connection
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+
+ title: pullRequest ? pullRequest.title : ""
+
+ property string currentFile: ""
+ property string currentText: ""
+
+ onPullRequestChanged: {
+ root.currentFile = ""
+ root.currentText = ""
+ }
+
+ actions: [
+ Kirigami.Action {
+ id: openFiles
+ text: "Files"
+ icon.name: "file-catalog-symbolic"
+ enabled: !!root.pullRequest
+ onTriggered: {
+ if(contextDrawer.opened) {
+ contextDrawer.close()
+ } else {
+ contextDrawer.open()
+ }
+ }
+ }
+ ]
+
+ Kirigami.PlaceholderMessage {
+ visible: root.currentFile == ''
+ anchors.centerIn: parent
+ icon.name: "org.deprecated.kodereviewer"
+ text: "No file selected"
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ visible: root.currentFile != ''
+ Editor {
+ id: editor
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ file: root.currentFile
+ text: root.currentText
+ }
+ }
+
+ Connections {
+ target: contextDrawer
+ function onFileSelected(filename, text) {
+ console.log("file changed!")
+ root.currentFile = filename + '.diff'
+ root.currentText = text
+ }
+ }
+}
diff --git a/kodereviewer/qml/Main.qml b/kodereviewer/qml/Main.qml
index c1be6b9..dc807fe 100644
--- a/kodereviewer/qml/Main.qml
+++ b/kodereviewer/qml/Main.qml
@@ -22,6 +22,7 @@ Kirigami.ApplicationWindow {
signal projectSelected()
property Project project
+ property bool isProjectSelected: false
property NetworkManager connection: NetworkManager {
project: root.project
@@ -54,6 +55,11 @@ Kirigami.ApplicationWindow {
sourceComponent: TreeFileModel {
pullRequest: treeFileModelLoader.pullRequest
}
+
+ onPullRequestChanged: {
+ if (pullRequest)
+ root.connection.getFiles(pullRequest.number)
+ }
}
contextDrawer: FilesDrawer {
@@ -69,7 +75,7 @@ Kirigami.ApplicationWindow {
Loader {
id: projectListPageLoader
- active: false
+ active: root.isProjectSelected
sourceComponent: Component {
ProjectListPage {
connection: root.connection
@@ -78,24 +84,97 @@ Kirigami.ApplicationWindow {
onPullRequestSelected: number => {
const pullRequest = project.pullRequest(number)
pullRequestPageLoader.item.pullRequest = pullRequest
+ commentsPageLoader.item.pullRequest = pullRequest
+ reviewListPageLoader.item.pullRequest = pullRequest
+ filesChangedPageLoader.item.pullRequest = pullRequest
treeFileModelLoader.pullRequest = pullRequest
}
}
}
}
+ Kirigami.PagePool {
+ id: pagePool
+ }
+
+ Loader {
+ id: commentsPageLoader
+ active: root.isProjectSelected
+ sourceComponent: CommentPage {
+ connection: root.connection
+ }
+ }
+
Loader {
id: pullRequestPageLoader
- active: false
- sourceComponent: PullRequestPage {
+ active: root.isProjectSelected
+ sourceComponent: PullRequestDescriptionPage {
+ connection: root.connection
+ }
+ }
+
+ Loader {
+ id: reviewListPageLoader
+ active: root.isProjectSelected
+ sourceComponent: ReviewListPage {
+ connection: root.connection
+ }
+ }
+
+ Loader {
+ id: filesChangedPageLoader
+ active: root.isProjectSelected
+ sourceComponent: FilesChangedPage {
connection: root.connection
}
}
onProjectSelected: {
- projectListPageLoader.active = true
- pullRequestPageLoader.active = true
+ navigationFooter.visible = true
+
+ root.isProjectSelected = true
+
pageStack.replace(projectListPageLoader.item)
pageStack.push(pullRequestPageLoader.item)
}
+
+ footer: Kirigami.NavigationTabBar {
+ id: navigationFooter
+ visible: false
+ actions: [
+ Kirigami.Action {
+ icon.name: "info"
+ text: i18n("Info")
+ onTriggered: {
+ root.pageStack.pop()
+ root.pageStack.push(pullRequestPageLoader.item)
+ }
+ },
+ Kirigami.Action {
+ icon.name: "comment-symbolic"
+ text: i18n("Comments")
+ onTriggered: {
+ root.pageStack.pop()
+ root.pageStack.push(commentsPageLoader.item)
+ }
+
+ },
+ Kirigami.Action {
+ icon.name: "file-catalog-symbolic"
+ text: i18n("Files")
+ onTriggered: {
+ root.pageStack.pop()
+ root.pageStack.push(filesChangedPageLoader.item)
+ }
+ },
+ Kirigami.Action {
+ icon.name: "document-preview-symbolic"
+ text: i18n("Reviews")
+ onTriggered: {
+ root.pageStack.pop()
+ root.pageStack.push(reviewListPageLoader.item)
+ }
+ }
+ ]
+ }
}
diff --git a/kodereviewer/qml/PullRequestDescriptionPage.qml b/kodereviewer/qml/PullRequestDescriptionPage.qml
new file mode 100644
index 0000000..d26b232
--- /dev/null
+++ b/kodereviewer/qml/PullRequestDescriptionPage.qml
@@ -0,0 +1,41 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as QQC2
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+import org.kde.kirigamiaddons.components as KirigamiComponents
+
+import org.deprecated.kodereviewer 1.0
+
+Kirigami.ScrollablePage {
+ id: root
+
+ property var pullRequest
+ property NetworkManager connection
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+
+ title: pullRequest ? pullRequest.title : ""
+
+ Kirigami.PlaceholderMessage {
+ visible: !root.pullRequest
+ anchors.centerIn: parent
+ icon.name: "org.deprecated.kodereviewer"
+ text: "Select a pull request"
+ }
+ Loader {
+ id: contentLoader
+ active: !!root.pullRequest
+ sourceComponent: ColumnLayout {
+ PullRequestDescription {
+ pullRequest: root.pullRequest
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+ }
+}
diff --git a/kodereviewer/qml/PullRequestPage.qml b/kodereviewer/qml/PullRequestPage.qml
index 5b52c3e..914acf5 100644
--- a/kodereviewer/qml/PullRequestPage.qml
+++ b/kodereviewer/qml/PullRequestPage.qml
@@ -99,31 +99,6 @@ Kirigami.ScrollablePage {
ColumnLayout {
id: mainLayout
anchors.fill: parent
- PullRequestDescription {
- visible: !!root.pullRequest && root.currentView == "info"
- pullRequest: root.pullRequest
-
- Layout.fillWidth: true
- Layout.fillHeight: true
- //anchors.fill: parent
- }
- Kirigami.CardsListView {
- id: commentsListView
- Layout.fillWidth: true
- Layout.fillHeight: true
- visible: !!root.pullRequest && root.currentView == "comments"
- model: commentModelLoader.item
- delegate: CommentDelegate {}
- footerPositioning: ListView.OverlayFooter
- }
-
- ReviewList {
- id: reviewListView
- visible: !!root.pullRequest && root.currentView == "reviews"
- Layout.fillWidth: true
- Layout.fillHeight: true
- model: reviewLoader.item
- }
Editor {
id: editor
@@ -144,43 +119,4 @@ Kirigami.ScrollablePage {
editor.text = text
}
}
-
- footer: Kirigami.NavigationTabBar {
- actions: [
- Kirigami.Action {
- icon.name: "info"
- text: i18n("Info")
- onTriggered: {
- root.currentView = "info"
- //root.flickable = mainLayout
- }
- },
- Kirigami.Action {
- icon.name: "comment-symbolic"
- text: i18n("Comments")
- onTriggered: {
- root.currentView = "comments"
- //root.flickable = commentsListView
- }
-
- },
- Kirigami.Action {
- icon.name: "file-catalog-symbolic"
- text: i18n("Files")
- onTriggered: {
- root.currentView = "files"
- //root.flickable = reviewListView
- }
- },
- Kirigami.Action {
- icon.name: "document-preview-symbolic"
- text: i18n("Reviews")
- onTriggered: {
- root.currentView = "reviews"
-
- //root.flickable = mainLayout
- }
- }
- ]
- }
}
diff --git a/kodereviewer/qml/ReviewList.qml b/kodereviewer/qml/ReviewList.qml
index e8821af..275e433 100644
--- a/kodereviewer/qml/ReviewList.qml
+++ b/kodereviewer/qml/ReviewList.qml
@@ -25,7 +25,7 @@ Kirigami.CardsListView {
required property string diff
required property var reviews
- clip: true
+ // clip: true
header: Editor {
text: delegate.diff
diff --git a/kodereviewer/qml/ReviewListPage.qml b/kodereviewer/qml/ReviewListPage.qml
new file mode 100644
index 0000000..555858c
--- /dev/null
+++ b/kodereviewer/qml/ReviewListPage.qml
@@ -0,0 +1,40 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as QQC2
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.formcard as FormCard
+import org.kde.kirigamiaddons.components as KirigamiComponents
+
+import org.deprecated.kodereviewer 1.0
+
+Kirigami.ScrollablePage {
+ id: root
+
+ property var pullRequest
+ property NetworkManager connection
+
+ Kirigami.Theme.colorSet: Kirigami.Theme.View
+ Kirigami.Theme.inherit: false
+
+ title: pullRequest ? pullRequest.title : ""
+
+ Loader {
+ id: reviewLoader
+ active: !!root.pullRequest
+ sourceComponent: ReviewModel {
+ id: reviewModel
+ pullRequest: root.pullRequest
+ onPullRequestChanged: root.connection.getPullRequestReviews(root.pullRequest.number)
+ }
+ }
+ ReviewList {
+ id: reviewListView
+ visible: !!root.pullRequest
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ model: reviewLoader.item
+ }
+}