Skip to content

Commit

Permalink
Show dialog when active contributors per month limit is hit (#3676)
Browse files Browse the repository at this point in the history
* Added a dialog when  monthly active contributor limit is hit
  • Loading branch information
ValentinBuira authored Nov 25, 2024
1 parent 5cf54a6 commit 3111207
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 4 deletions.
24 changes: 24 additions & 0 deletions app/images/ReachedMonthlyContributorLimit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<file>SignIn.svg</file>
<file>NoWorkspace.svg</file>
<file>BlueInfo.svg</file>
<file>ReachedMonthlyContributorLimit.svg</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions app/mmstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class MMStyle: public QObject
Q_PROPERTY( QUrl acceptInvitationImage READ acceptInvitationImage CONSTANT )
Q_PROPERTY( QUrl acceptInvitationLogoImage READ acceptInvitationLogoImage CONSTANT )
Q_PROPERTY( QUrl reachedDataLimitImage READ reachedDataLimitImage CONSTANT )
Q_PROPERTY( QUrl reachedMonthlyContributorLimitImage READ reachedMonthlyContributorLimitImage CONSTANT )
Q_PROPERTY( QUrl uploadImage READ uploadImage CONSTANT )
Q_PROPERTY( QUrl noMapThemesImage READ noMapThemesImage CONSTANT )
Q_PROPERTY( QUrl syncFailedImage READ syncFailedImage CONSTANT )
Expand Down Expand Up @@ -496,6 +497,7 @@ class MMStyle: public QObject
QUrl noPermissionsImage() {return QUrl( "qrc:/images/NoPermissions.svg" );}
QUrl signInImage() {return QUrl( "qrc:/images/SignIn.svg" );}
QUrl reachedDataLimitImage() {return QUrl( "qrc:/images/ReachedDataLimit.svg" );}
QUrl reachedMonthlyContributorLimitImage() {return QUrl( "qrc:/images/ReachedMonthlyContributorLimit.svg" );}
QUrl warnLogoImage() {return QUrl( "qrc:/images/WarnLogoImage.svg" );}
QUrl mapPinImage() {return QUrl( "qrc:/images/MapPin.svg" );}
QUrl positionTrackingRunningImage() {return QUrl( "qrc:/images/PositionTrackingRunning.svg" );}
Expand Down
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
38 changes: 38 additions & 0 deletions app/qml/dialogs/MMMonthlyContributorsLimitDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/***************************************************************************
* *
* 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

property int contributorsQuota

signal manageAccountClicked()

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

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

primaryButton.text: qsTr( "Upgrade" )
secondaryButton.text: qsTr( "Cancel" )

onPrimaryButtonClicked: {
root.manageAccountClicked()
close()
}

onSecondaryButtonClicked: {
close()
}
}
13 changes: 12 additions & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ ApplicationWindow {
onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMProjectLimitDialog {
id: projectLimitDialog

Expand Down Expand Up @@ -895,6 +901,11 @@ ApplicationWindow {
storageLimitDialog.open()
}

function onMonthlyContributorLimitReached( quota, serverMsg ) {
monthlyContributorsLimitDialog.contributorsQuota = quota
monthlyContributorsLimitDialog.open()
}

function onProjectLimitReached( maxProjects, errorMsg ) {
__merginApi.getUserInfo()
if (__merginApi.apiSupportsSubscriptions) {
Expand All @@ -914,7 +925,7 @@ ApplicationWindow {
}

function onMigrationRequested( version ) {
if( __appSettings.ignoreMigrateVersion !== version ) {
if ( __appSettings.ignoreMigrateVersion !== version ) {
migrationDialog.version = version
migrationDialog.open()
}
Expand Down
11 changes: 9 additions & 2 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2117,14 +2117,13 @@ void MerginApi::pushStartReplyFinished()
serverMsg = sSyncCanceledMessage;

QString code = extractServerErrorCode( data );
bool showLimitReachedDialog = EnumHelper::isEqual( code, ErrorCode::StorageLimitHit );

CoreUtils::log( "push " + projectFullName, QStringLiteral( "FAILED - %1. %2" ).arg( r->errorString(), serverMsg ) );

transaction.replyPushStart->deleteLater();
transaction.replyPushStart = nullptr;

if ( showLimitReachedDialog )
if ( EnumHelper::isEqual( code, ErrorCode::StorageLimitHit ) )
{
const QList<MerginFile> files = transaction.pushQueue;
qreal uploadSize = 0;
Expand All @@ -2144,6 +2143,14 @@ void MerginApi::pushStartReplyFinished()
deleteProject( projectNamespace, projectName, false );
}
}
else if ( EnumHelper::isEqual( code, ErrorCode::MonthlyContributorsLimitHit ) )
{
int quota = 0;
QVariant maximunMonthlyContributor = extractServerErrorValue( data, "projects_quota" );
if ( maximunMonthlyContributor.isValid() )
quota = maximunMonthlyContributor.toInt();
emit monthlyContributorLimitReached( quota, serverMsg );
}
else
{
int httpCode = r->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
Expand Down
4 changes: 3 additions & 1 deletion core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class ErrorCode
{
Unknown = 0,
ProjectsLimitHit,
StorageLimitHit
StorageLimitHit,
MonthlyContributorsLimitHit,
};
Q_ENUM( Value );
};
Expand Down Expand Up @@ -597,6 +598,7 @@ class MerginApi: public QObject
);

void storageLimitReached( qreal uploadSize );
void monthlyContributorLimitReached( int contributorsQuota, const QString &message );
void projectLimitReached( int maxProjects, const QString &message );
void migrationRequested( const QString &version );
void notifySuccess( const QString &message );
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
15 changes: 15 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,16 @@ Page {
}
}

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

contributorsQuota: 15

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

MMSyncFailedDialog {
id: syncFailedDialog
}
Expand Down
1 change: 1 addition & 0 deletions gallery/qml/pages/ImagesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ScrollView {
Column { Image { source: __style.externalGpsGreenImage } Text { text: "externalGpsGreenImage" } }
Column { Image { source: __style.externalGpsRedImage } Text { text: "externalGpsRedImage" } }
Column { Image { source: __style.reachedDataLimitImage } Text { text: "reachedDataLimitImage" } }
Column { Image { source: __style.reachedMonthlyContributorLimitImage } Text { text: "reachedMonthlyContributorLimitImage" } }
Column { Image { source: __style.positiveMMSymbolImage } Text { text: "positiveMMSymbolImage" } }
Column { Image { source: __style.negativeMMSymbolImage } Text { text: "negativeMMSymbolImage" } }
Column { Image { source: __style.closeAccountImage } Text { text: "closeAccountImage" } }
Expand Down

1 comment on commit 3111207

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.11.696211 just submitted!

Please sign in to comment.