From 39349a7e1e4fbb16e4a71d7f741b0725e73caeb7 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sat, 5 Oct 2024 10:43:00 -0300 Subject: Add review changes functionality! --- kodereviewer/qml/PullRequestPage.qml | 43 +++++++++++----------- kodereviewer/qml/ReviewDialog.qml | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 23 deletions(-) create mode 100644 kodereviewer/qml/ReviewDialog.qml (limited to 'kodereviewer/qml') diff --git a/kodereviewer/qml/PullRequestPage.qml b/kodereviewer/qml/PullRequestPage.qml index da2b8e5..b9106c1 100644 --- a/kodereviewer/qml/PullRequestPage.qml +++ b/kodereviewer/qml/PullRequestPage.qml @@ -30,32 +30,18 @@ Kirigami.ScrollablePage { } ] - Kirigami.Dialog { + ReviewDialog { id: reviewChangesDialog - standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel - title: i18nc("@title:window", "Review changes") - padding: Kirigami.Units.largeSpacing - preferredWidth: Kirigami.Units.gridUnit * 20 - ColumnLayout { - MarkdownTextArea { - Layout.fillWidth: true - } - Kirigami.Separator { - Kirigami.FormData.isSection: true - Layout.fillWidth: true - } - QQC2.RadioButton { - text: "Approve" - } - QQC2.RadioButton { - text: "Comment" - } - QQC2.RadioButton { - text: "Request changes" - } + onAccepted: { + print('Sending', root.pullRequest.number, root.pullRequest.last_commit, + reviewBodyText, event) + root.connection.createReview( + root.pullRequest.number, root.pullRequest.last_commit, + reviewBodyText, event + ) + clearForm() } } - Loader { id: commentModelLoader active: !!root.pullRequest @@ -136,6 +122,17 @@ Kirigami.ScrollablePage { } } + RowLayout { + QQC2.Label { + text: "Last commit: " + elide: Text.ElideRight + } + QQC2.Label { + text: root.pullRequest ? root.pullRequest.last_commit : "" + elide: Text.ElideLeft + } + } + Loader { id: labelModelLoader active: !!root.pullRequest diff --git a/kodereviewer/qml/ReviewDialog.qml b/kodereviewer/qml/ReviewDialog.qml new file mode 100644 index 0000000..7dcaf9c --- /dev/null +++ b/kodereviewer/qml/ReviewDialog.qml @@ -0,0 +1,69 @@ +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.deprecated.kodereviewer 1.0 + + +Kirigami.Dialog { + id: root + standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel + title: i18nc("@title:window", "Review changes") + padding: Kirigami.Units.largeSpacing + preferredWidth: Kirigami.Units.gridUnit * 20 + property string event: '' + property alias reviewBodyText: reviewBody.text + ColumnLayout { + MarkdownTextArea { + id: reviewBody + Layout.fillWidth: true + } + Kirigami.Separator { + Kirigami.FormData.isSection: true + Layout.fillWidth: true + } + QQC2.RadioButton { + id: approveRadioButton + text: "Approve" + onCheckedChanged: if(checked) { + root.event = 'APPROVE' + } + } + QQC2.RadioButton { + id: commentRadioButton + text: "Comment" + onCheckedChanged: if(checked) { + root.event = 'COMMENT' + } + } + QQC2.RadioButton { + id: requestChangesRadioButton + text: "Request changes" + onCheckedChanged: if(checked) { + root.event = 'REQUEST_CHANGES' + } + } + } + + function requiredFieldsFilled() { + return event != '' && reviewBodyText != '' + } + + function clearForm() { + reviewBodyText = '' + approveRadioButton.checked = false + commentRadioButton.checked = false + requestChangesRadioButton = false + event = '' + } + + Component.onCompleted: { + const button = standardButton(Kirigami.Dialog.Ok); + button.enabled = Qt.binding( () => requiredFieldsFilled() ); + } +} -- cgit v1.2.3-70-g09d2