Skip to content

Commit

Permalink
merging master to branch
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Dec 10, 2024
2 parents 8a92bff + 185dfb9 commit 193574d
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 14 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 @@ -716,6 +716,12 @@ ApplicationWindow {
onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMMonthlyContributorsLimitDialog {
id: monthlyContributorsLimitDialog

onManageAccountClicked: Qt.openUrlExternally(__inputHelp.merginSubscriptionLink)
}

MMProjectLimitDialog {
id: projectLimitDialog

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

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

function onProjectLimitReached( maxProjects, errorMsg ) {
__merginApi.getUserInfo()
if (__merginApi.apiSupportsSubscriptions) {
Expand All @@ -915,7 +926,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 @@ -602,6 +603,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
10 changes: 0 additions & 10 deletions core/merginprojectmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ MerginProjectMetadata MerginProjectMetadata::fromJson( const QByteArray &data )
project.projectNamespace = docObj.value( QStringLiteral( "namespace" ) ).toString();
project.role = docObj.value( QStringLiteral( "role" ) ).toString();

QJsonValue access = docObj.value( QStringLiteral( "access" ) );
if ( access.isObject() )
{
QJsonArray writersnames = access.toObject().value( "writersnames" ).toArray();
for ( QJsonValueRef tag : writersnames )
{
project.writersnames.append( tag.toString() );
}
}

QString versionStr = docObj.value( QStringLiteral( "version" ) ).toString();
if ( versionStr.isEmpty() )
{
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 193574d

@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.12.697211 just submitted!

Please sign in to comment.