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

show invitations on startup #3205

Merged
merged 1 commit into from
Apr 3, 2024
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
6 changes: 6 additions & 0 deletions app/notificationmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ void NotificationModel::onNotificationClicked( uint id )
emit showProjectIssuesActionClicked();
break;
}
case NotificationType::ActionType::ShowSwitchWorkspaceAction:
{
remove( id );
emit showSwitchWorkspaceActionClicked();
break;
}
default: break;
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/notificationmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class NotificationType
enum ActionType
{
NoAction,
ShowProjectIssuesAction
ShowProjectIssuesAction,
ShowSwitchWorkspaceAction
};
Q_ENUM( ActionType )

Expand Down Expand Up @@ -107,6 +108,7 @@ class NotificationModel : public QAbstractListModel
signals:
void rowCountChanged();
void showProjectIssuesActionClicked();
void showSwitchWorkspaceActionClicked();

private:
void add( const QString &message, uint interval, NotificationType::MessageType type = NotificationType::Information, NotificationType::IconType icon = NotificationType::NoneIcon, NotificationType::ActionType action = NotificationType::ActionType::NoAction );
Expand Down
21 changes: 7 additions & 14 deletions app/qml/account/MMAcceptInvitationController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,25 @@ import mm 1.0 as MM
* e.g. on app start
*/
Item {
id: controller

required property bool enabled
required property var stackView
id: root

property bool enabled: true
property MM.MerginInvitation invitation

Connections {
id: openInvitationsListener

target: __merginApi
enabled: controller.enabled && !stackView.containsPage("signUpPanel")
enabled: root.enabled

function onUserInfoReplyFinished() {
// let's not show invitations when registration finish page is opened
// this should be redundant - never reached
if ( stackView.containsPage("signUpPanel") ) {
return;
}

if ( !__merginApi.userAuth.hasAuthData() ) {
return;
}

if ( __merginApi.userInfo.hasInvitations ) {
__notificationModel.addWarning( qsTr( "You have pending workspace invitations! You may accept or reject them in your workspace selection page" ) )
__notificationModel.addWarning(
__inputUtils.htmlLink(qsTr( "You have pending workspace invitations.<br>Please %1accept or reject%2 them." ), __style.grapeColor),
MM.NotificationType.ShowSwitchWorkspaceAction
)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ ApplicationWindow {
projectIssuesPage.projectLoadingLog = __activeProject.projectLoadingLog();
projectIssuesPage.visible = true;
}
function onShowSwitchWorkspaceActionClicked() {
stateManager.state = "projects"
projectController.showSelectWorkspacePage()
}
}

Connections {
Expand Down
19 changes: 13 additions & 6 deletions app/qml/project/MMProjectController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Item {
root.openChangesPanel( projectId )
}

function showSelectWorkspacePage() {
stackView.push( workspaceListComponent )
}

visible: false
focus: true

Expand Down Expand Up @@ -468,9 +472,12 @@ Item {

MMAcceptInvitationController {
id: acceptInvitationController
// TODO enabled add controller.showInvitationsList
enabled: root.visible && __merginApi.apiSupportsWorkspaces
stackView: stackView
// Do not show accept invitation notification when
// - there is onboarding ongoing
// - account page is already opened
enabled: !accountController.inProgress &&
!stackView.containsPage("accountPage") &&
__merginApi.apiSupportsWorkspaces
}

Component {
Expand All @@ -489,6 +496,8 @@ Item {
MMAccountPage {
id: workspaceAccountPage

objectName: "accountPage"

abbrName: __merginApi.userInfo.nameAbbr
fullName: __merginApi.userInfo.name
userName: __merginApi.userAuth.username
Expand Down Expand Up @@ -522,9 +531,7 @@ Item {
root.resetView()
}

onSelectWorkspaceClicked: {
stackView.push( workspaceListComponent )
}
onSelectWorkspaceClicked: root.showSelectWorkspacePage()
}
}

Expand Down
Loading