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 dialog when active contributors per month limit is hit #3676

Merged
merged 19 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
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>
5 changes: 5 additions & 0 deletions app/inputhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ QString InputHelp::merginSubscriptionLink() const
}
}

QString InputHelp::merginPricingLink() const
{
return inputWeb + "/pricing" + utmTagSubscription;
}
ValentinBuira marked this conversation as resolved.
Show resolved Hide resolved

QString InputHelp::privacyPolicyLink() const
{
return inputWeb + "/privacy-policy" + utmTagOther;
Expand Down
2 changes: 2 additions & 0 deletions app/inputhelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class InputHelp: public QObject
Q_PROPERTY( QString merginWebLink READ merginWebLink NOTIFY merginLinkChanged )
Q_PROPERTY( QString merginDashboardLink READ merginDashboardLink NOTIFY merginLinkChanged )
Q_PROPERTY( QString merginSubscriptionLink READ merginSubscriptionLink NOTIFY merginLinkChanged )
Q_PROPERTY( QString merginPricingLink READ merginPricingLink NOTIFY merginLinkChanged )
Q_PROPERTY( QString merginSubscriptionDetailsLink READ merginSubscriptionDetailsLink NOTIFY linkChanged )
Q_PROPERTY( QString howToEnableDigitizingLink READ howToEnableDigitizingLink NOTIFY linkChanged )
Q_PROPERTY( QString howToEnableBrowsingDataLink READ howToEnableBrowsingDataLink NOTIFY linkChanged )
Expand Down Expand Up @@ -63,6 +64,7 @@ class InputHelp: public QObject
QString merginWebLink() const;
QString merginDashboardLink() const;
QString merginSubscriptionLink() const;
QString merginPricingLink() const;
QString privacyPolicyLink() const;
QString merginSubscriptionDetailsLink() const;
QString howToEnableDigitizingLink() const;
Expand Down
4 changes: 2 additions & 2 deletions app/ios/iosviewdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* View controller for iOSImagePicker
*/
@interface IOSViewDelegate : NSObject<UIImagePickerControllerDelegate,
UINavigationControllerDelegate>
UINavigationControllerDelegate>
{
@public
@public

IOSImagePicker *handler;
BOOL processingPicture;
Expand Down
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

required property bool apiSupportsSubscription

signal manageAccountClicked()

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

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

primaryButton.text: apiSupportsSubscription ? qsTr( "Manage account" ) : qsTr( "Upgrade" )
ValentinBuira marked this conversation as resolved.
Show resolved Hide resolved
secondaryButton.text: qsTr( "Cancel" )

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

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

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

apiSupportsSubscription: __merginApi.apiSupportsSubscriptions
ValentinBuira marked this conversation as resolved.
Show resolved Hide resolved

onManageAccountClicked: function() {
if (__merginApi.apiSupportsSubscriptions) {
Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}
else {
Qt.openUrlExternally(__inputHelp.merginPricingLink)
}
}
ValentinBuira marked this conversation as resolved.
Show resolved Hide resolved
}

MMProjectLimitDialog {
id: projectLimitDialog

Expand Down Expand Up @@ -859,6 +874,9 @@ ApplicationWindow {
// just banner that we will try again
__notificationModel.addInfo( qsTr( "Somebody else is syncing, we will try again later" ) )
}
else if ( errorType === MM.SyncError.MonthlyContributorsLimitHit ){
monthlyContributorsLimitDialog.open()
}
else
{
syncFailedDialog.detailedText = qsTr( "Details" ) + ": " + errorMessage
Expand Down Expand Up @@ -914,7 +932,7 @@ ApplicationWindow {
}

function onMigrationRequested( version ) {
if( __appSettings.ignoreMigrateVersion !== version ) {
if ( __appSettings.ignoreMigrateVersion !== version ) {
migrationDialog.version = version
migrationDialog.open()
}
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;
}
ValentinBuira marked this conversation as resolved.
Show resolved Hide resolved
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
5 changes: 5 additions & 0 deletions app/test/testlinks.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class TestLinks: public QObject
_run( mHelp.merginSubscriptionLink() );
}

void testMerginPricingLink()
{
_run( mHelp.merginPricingLink() );
}

void testMerginSubscriptionDetailsLink()
{
_run( mHelp.merginSubscriptionDetailsLink() );
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

apiSupportsSubscription: true

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
Loading