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

Add instructional dialog for reporting issues #68

Merged
merged 2 commits into from
Sep 20, 2023
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
4 changes: 2 additions & 2 deletions res/pyinstaller/create_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import PyInstaller.__main__

from mapclient.core.provenance import reproducibility_info
from mapclient.settings.definitions import FROZEN_PROVENANCE_INFO_FILE
from mapclient.settings.definitions import APPLICATION_NAME, FROZEN_PROVENANCE_INFO_FILE


# Set Python optimisations on.
Expand All @@ -20,7 +20,7 @@
def main(variant):
run_command = [
'../../src/mapclient/application.py',
'-n', f'MAP-Client{variant}',
'-n', f'{APPLICATION_NAME}{variant}',
# '--debug', 'noarchive',
'--windowed',
# '--console',
Expand Down
16 changes: 15 additions & 1 deletion src/mapclient/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,28 @@
from subprocess import Popen, PIPE, DEVNULL
import PySide6 as RefMod

from mapclient.settings.definitions import PLUGINS_PACKAGE_NAME
from mapclient.settings.definitions import APPLICATION_NAME, PLUGINS_PACKAGE_NAME
from mapclient.settings.general import get_configuration_file


def is_frozen():
return getattr(sys, 'frozen', False)


def is_mapping_tools():
variant = get_map_client_variant()
return variant == "mapping-tools"


def get_map_client_variant():
application_name = os.path.basename(sys.executable)
pattern = r'{}-(.*).exe'.format(APPLICATION_NAME)
match = re.search(pattern, application_name)
variant = match.group(1) if match else ""

return variant


def convertExceptionToMessage(e):
string_e = str(e)
if '\n' in string_e:
Expand Down
1 change: 1 addition & 0 deletions src/mapclient/settings/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
keep the strings the same, obviously it doesn't help with the side-effects of
changing the string.
"""
APPLICATION_NAME = "MAP-Client"

# Options related strings
OPTIONS_SETTINGS_TAG = 'Options'
Expand Down
Empty file.
44 changes: 44 additions & 0 deletions src/mapclient/view/dialogs/error/errordialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

from PySide6 import QtWidgets

from mapclient.view.dialogs.reportissue.utils import create_github_issue


class ErrorDialog(QtWidgets.QDialog):
def __init__(self, title, text, parent=None):
super().__init__(parent=parent)
self._text = text

critical_icon = QtWidgets.QMessageBox.standardIcon(QtWidgets.QMessageBox.Icon.Critical)
layout = QtWidgets.QVBoxLayout()

# Create and add the icon.
critical_icon_label = QtWidgets.QLabel()
critical_icon_label.setPixmap(critical_icon)
layout.addWidget(critical_icon_label)

# Create text.
label = QtWidgets.QLabel(text)
label.setWordWrap(True)
layout.addWidget(label)

# Create buttons.
button_layout = QtWidgets.QHBoxLayout()
github_issue_button = QtWidgets.QPushButton("Submit GitHub Issue")
spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding)
ok_button = QtWidgets.QPushButton("OK")
button_layout.addWidget(github_issue_button)
button_layout.addSpacerItem(spacer)
button_layout.addWidget(ok_button)
layout.addLayout(button_layout)
ok_button.clicked.connect(self.accept)
github_issue_button.clicked.connect(self._create_github_issue)

self.setWindowTitle(title)
self.setWindowIcon(critical_icon)
self.setLayout(layout)

def _create_github_issue(self):
text = self._text.replace("\n", "%0A")
text = "<Describe steps to reproduce the error here>%0A%0A```%0A" + text + "```"
create_github_issue(text)
Empty file.
168 changes: 168 additions & 0 deletions src/mapclient/view/dialogs/reportissue/qt/reportissuedialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportIssueDialog</class>
<widget class="QDialog" name="ReportIssueDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Report Issue</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="description">
<property name="text">
<string>&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Issue Reporting&lt;/span&gt;&lt;/p&gt;

&lt;p align=&quot;justify&quot;&gt;If you have encountered an issue with the Mapping-Tools, please consider submitting an issue report using one of the following methods:&lt;/p&gt;

&lt;p align=&quot;justify&quot; style=&quot;margin-left:20; margin-right:20;&quot;&gt;

If possible, we recommend submitting an issue in the &lt;a href=&quot;https://github.com/MusculoskeletalAtlasProject/mapclient&quot;&gt;MAP-Client&lt;/a&gt; GitHub repository. This is our primary location for all issues related to the MAP-Client and Mapping-Tools. Once you have submitted an issue, the MAP-Client developers will be notified and you can use the issue page to track any progress made in response to your submission. Note that you will need a GitHub account for this method.

&lt;/p&gt;
</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="wrike_description">
<property name="text">
<string>&lt;p align=&quot;justify&quot; style=&quot;margin-left:20; margin-right:20;&quot;&gt;

If you are a member of the SPARC Wrike group, you may also wish to submit a request for a Wrike ticket using the link provided below.

&lt;/p&gt;
</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="description_2">
<property name="text">
<string>&lt;p align=&quot;justify&quot; style=&quot;margin-left:20; margin-right:20;&quot;&gt;

Alternatively, it is also possible to report an issue by email if you'd prefer. Please direct your messages to &lt;i&gt;[email protected]&lt;/i&gt; for any issues or questions you have in regards to the MAP-Client.

&lt;br/&gt;&lt;/p&gt;

&lt;p align=&quot;justify&quot;&gt;Make sure to provide a description of the issue or error that you have encountered, including any steps that may be required to reproduce it. If possible, please also include any relevant error messages. Note that the MAP-Client keeps a log of the current session if you need to review any error messages or related application events. A copy of this log can be accessed within the MAP-Client under &lt;i&gt;View -&gt; Log Information&lt;/i&gt;. If the error occurred during the execution of a plugin step, please include the name of the plugin in your report.&lt;/p&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="github_issue_button">
<property name="text">
<string>GitHub Issue</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="wrike_ticket_button">
<property name="text">
<string>Wrike Ticket</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="close_button">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>close_button</sender>
<signal>clicked()</signal>
<receiver>ReportIssueDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>530</x>
<y>362</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>
31 changes: 31 additions & 0 deletions src/mapclient/view/dialogs/reportissue/reportissuedialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from PySide6 import QtWidgets

from mapclient.core.utils import is_mapping_tools
from mapclient.view.dialogs.reportissue.utils import create_github_issue, create_wrike_ticket
from mapclient.view.dialogs.reportissue.ui.ui_reportissuedialog import Ui_ReportIssueDialog


class ReportIssueDialog(QtWidgets.QDialog):
"""
Dialog with instructions on how and where to report issues in the MAP-Client.
"""

def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self._ui = Ui_ReportIssueDialog()
self._ui.setupUi(self)
self._make_connections()
self._check_variant()

def _make_connections(self):
self._ui.github_issue_button.clicked.connect(_create_github_issue)
self._ui.wrike_ticket_button.clicked.connect(create_wrike_ticket)

def _check_variant(self):
if not is_mapping_tools():
self._ui.wrike_description.hide()
self._ui.wrike_ticket_button.hide()


def _create_github_issue():
create_github_issue()
Loading