Skip to content

Commit

Permalink
Add dialog for montly active contributor limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBuira committed Nov 14, 2024
1 parent 5cf54a6 commit 84d4d8f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ set(MM_QML
dialogs/MMDownloadProjectDialog.qml
dialogs/MMMigrateToMerginDialog.qml
dialogs/MMMissingAuthDialog.qml
dialogs/MMMonthlyContributorsLimitDialog.qml
dialogs/MMNoPermissionsDialog.qml
dialogs/MMPositionTrackingDialog.qml
dialogs/MMProjectLimitDialog.qml
Expand Down
34 changes: 34 additions & 0 deletions app/qml/dialogs/MMMonthlyContributorsLimitDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

import QtQuick

import "../components" as MMComponents


MMComponents.MMDrawerDialog {
id: root

required property bool apiSupportsSubscription

signal manageAccountClicked()

title: qsTr("You've reached the maximum number of active monthly contributors for your current subscription.")
imageSource: __style.reachedDataLimitImage

description: qsTr( "Upgrade your subscription or wait until next month for the limit to reset." )

primaryButton.text: apiSupportsSubscription ? qsTr("Manage account") : ""
secondaryButton.text: qsTr("Cancel")

onPrimaryButtonClicked: {
root.manageAccountClicked()
close()
}
}
12 changes: 12 additions & 0 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ ApplicationWindow {
onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

apiSupportsSubscription: __merginApi.apiSupportsSubscriptions

onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMProjectLimitDialog {
id: projectLimitDialog

Expand Down Expand Up @@ -874,6 +882,10 @@ ApplicationWindow {
}
}
}

function onMonthlyContributorsLimitReached( uploadSize ) {
monthlyContributorsLimitDialog.open()
}
}

Connections {
Expand Down
5 changes: 5 additions & 0 deletions app/synchronizationerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ SynchronizationError::ErrorType SynchronizationError::errorType( int errorCode,
// Project no longer exists / is on different server
return ErrorType::ProjectNotFound;
}
else if ( errorCode == 422 )
{
// Hit the maximun number of contributor per month
return ErrorType::MonthlyContributorsLimitHit;
}
else if ( errorCode >= 500 )
{
// Exceptions in server code or maintenance mode
Expand Down
1 change: 1 addition & 0 deletions app/synchronizationerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SynchronizationError
ProjectNotFound,
VersionMismatch,
ServerError,
MonthlyContributorsLimitHit,
UnknownError
};
Q_ENUMS( ErrorType );
Expand Down
3 changes: 3 additions & 0 deletions app/synchronizationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ void SynchronizationManager::onProjectSyncFailure(
}
else
{
if (error == SynchronizationError::MonthlyContributorsLimitHit){
emit monthlyContributorsLimitReached("");
}
mSyncProcesses.remove( projectFullName );
emit syncFinished( projectFullName, false, -1, false );

Expand Down
1 change: 1 addition & 0 deletions app/synchronizationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SynchronizationManager : public QObject
void syncFinished( const QString &projectFullName, bool success, int newVersion, bool reloadNeeded );

void syncError( const QString &projectFullName, int errorType, bool willRetry = false, const QString &errorMessage = QLatin1String() );
void monthlyContributorsLimitReached( const QString &message );

public slots:

Expand Down
1 change: 1 addition & 0 deletions gallery/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<file>../app/qml/dialogs/MMStreamingModeDialog.qml</file>
<file>../app/qml/dialogs/MMPositionTrackingDialog.qml</file>
<file>../app/qml/dialogs/MMStorageLimitDialog.qml</file>
<file>../app/qml/dialogs/MMMonthlyContributorsLimitDialog.qml</file>
<file>../app/qml/dialogs/MMCloseAccountDialog.qml</file>
<file>../app/qml/dialogs/MMRemoveProjectDialog.qml</file>
<file>../app/qml/dialogs/MMDownloadProjectDialog.qml</file>
Expand Down
18 changes: 18 additions & 0 deletions gallery/qml/pages/DrawerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Page {
onClicked: storageLimitDialog.open()
}

Button {
text: "MMMonthlyContributorsLimitDialog"
onClicked: monthlyContributorsLimitDialog.open()
}

Button {
text: "MMCloseAccountDialog"
onClicked: closeAccountDialog.open()
Expand Down Expand Up @@ -289,6 +294,19 @@ Page {
}
}

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

dataToSync: "643.8 MB"
dataUsing: "9.23 MB / 10.0 MB"
usedData: 0.923
apiSupportsSubscription: true

onPrimaryButtonClicked: {
console.log("Manage workspace clicked")
}
}

MMSyncFailedDialog {
id: syncFailedDialog
}
Expand Down

0 comments on commit 84d4d8f

Please sign in to comment.