Skip to content

Commit

Permalink
Filter invitation and revoked users
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineDupre committed Sep 2, 2021
1 parent 448e294 commit 1bbf0d7
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 67 deletions.
176 changes: 113 additions & 63 deletions parsec/core/gui/forms/users_widget.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>624</width>
<width>747</width>
<height>524</height>
</rect>
</property>
Expand Down Expand Up @@ -59,71 +59,13 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>15</number>
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="line_edit_search">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>TEXT_USERS_FILTER_USERS_PLACEHOLDER</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_users_filter">
<property name="text">
<string>ACTION_FILTER_LIST_USERS</string>
</property>
</widget>
</item>
<item>
<widget class="Button" name="button_add_user">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>ACTION_USER_INVITE_USER</string>
</property>
<property name="icon">
<iconset resource="../rc/resources.qrc">
<normaloff>:/icons/images/material/person_add.svg</normaloff>:/icons/images/material/person_add.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
<green>146</green>
<blue>255</blue>
</color>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand All @@ -137,6 +79,114 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="line_edit_search">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>TEXT_USERS_FILTER_USERS_PLACEHOLDER</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_users_filter">
<property name="text">
<string>ACTION_FILTER_LIST_USERS</string>
</property>
</widget>
</item>
<item>
<widget class="Button" name="button_add_user">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>ACTION_USER_INVITE_USER</string>
</property>
<property name="icon">
<iconset resource="../rc/resources.qrc">
<normaloff>:/icons/images/material/person_add.svg</normaloff>:/icons/images/material/person_add.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
<green>146</green>
<blue>255</blue>
</color>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>15</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkbox_filter_revoked">
<property name="text">
<string>ACTION_FILTER_REVOKED_USERS</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_filter_invitation">
<property name="text">
<string>ACTION_FILTER_PENDING_INVITATION</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand All @@ -163,8 +213,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>622</width>
<height>456</height>
<width>745</width>
<height>385</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down
6 changes: 6 additions & 0 deletions parsec/core/gui/tr/parsec_en.po
Expand Up @@ -2465,6 +2465,12 @@ msgstr "Filter users"
msgid "ACTION_FILTER_LIST_USERS"
msgstr "Search users"

msgid "ACTION_FILTER_REVOKED_USERS"
msgstr "Hide revoked users"

msgid "ACTION_FILTER_PENDING_INVITATION"
msgstr "Hide pending invitations"

msgid "ACTION_USER_INVITE_USER"
msgstr "Invite a new user"

Expand Down
6 changes: 6 additions & 0 deletions parsec/core/gui/tr/parsec_fr.po
Expand Up @@ -2532,6 +2532,12 @@ msgstr "Filtrer les utilisateurs"
msgid "ACTION_FILTER_LIST_USERS"
msgstr "Rechercher utilisateurs"

msgid "ACTION_FILTER_REVOKED_USERS"
msgstr "Masquer les utilisteurs révoqués"

msgid "ACTION_FILTER_PENDING_INVITATION"
msgstr "Masquer les invitations"

msgid "ACTION_USER_INVITE_USER"
msgstr "Inviter un utilisateur"

Expand Down
18 changes: 14 additions & 4 deletions parsec/core/gui/users_widget.py
Expand Up @@ -173,14 +173,20 @@ async def _do_revoke_user(core, user_info):
raise JobResultError("error") from exc


async def _do_list_users_and_invitations(core, page, pattern=None):
async def _do_list_users_and_invitations(
core, page, pattern=None, omit_revoked=False, omit_invitation=False
):
try:
if pattern is None:
users, total = await core.find_humans(page=page, per_page=USERS_PER_PAGE)
invitations = await core.list_invitations()
users, total = await core.find_humans(
page=page, per_page=USERS_PER_PAGE, omit_revoked=omit_revoked
)
invitations = [] if omit_invitation else await core.list_invitations()
return total, users, [inv for inv in invitations if inv["type"] == InvitationType.USER]
else:
users, total = await core.find_humans(page=page, per_page=USERS_PER_PAGE, query=pattern)
users, total = await core.find_humans(
page=page, per_page=USERS_PER_PAGE, query=pattern, omit_revoked=omit_revoked
)
return total, users, []
except BackendNotAvailable as exc:
raise JobResultError("offline") from exc
Expand Down Expand Up @@ -247,6 +253,8 @@ def __init__(self, core, jobs_ctx, event_bus, *args, **kwargs):
self.invite_user_error.connect(self._on_invite_user_error)
self.cancel_invitation_success.connect(self._on_cancel_invitation_success)
self.cancel_invitation_error.connect(self._on_cancel_invitation_error)
self.checkbox_filter_revoked.clicked.connect(self.reset)
self.checkbox_filter_invitation.clicked.connect(self.reset)

def show(self):
self._page = 1
Expand Down Expand Up @@ -531,4 +539,6 @@ def reset(self):
_do_list_users_and_invitations,
core=self.core,
page=self._page,
omit_revoked=self.checkbox_filter_revoked.isChecked(),
omit_invitation=self.checkbox_filter_invitation.isChecked(),
)

0 comments on commit 1bbf0d7

Please sign in to comment.