Skip to content

Commit

Permalink
add login option to softlimit dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bennet0496 committed Feb 22, 2024
1 parent 66d2374 commit fcd8891
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 23 deletions.
74 changes: 51 additions & 23 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,57 @@ rcmail.addEventListener('init', function(evt) {
return false;
} else // Soft limit hit, prompt the user to hopefully share link instead.
if(rcmail.env.nextcloud_attachment_softlimit && size * 1.33 > rcmail.env.nextcloud_attachment_softlimit) {
// noinspection SpellCheckingInspection
let dialog = rcmail.show_popup_dialog(
rcmail.gettext("file_big_explain", "nextcloud_attachments")
.replace("%size%", human_size.toFixed(0) + " " + unit[unit_idx] + "B"),
rcmail.gettext("file_big", "nextcloud_attachments"), [
{
text: rcmail.gettext("link_file", "nextcloud_attachments"),
'class': 'mainaction',
click: () => {
post_args = {_target: "cloud", ...post_args};
rcmail.__file_upload(files, post_args, props);
dialog.dialog('close');
}
},
{
text: rcmail.gettext("attach", "nextcloud_attachments"),
'class': 'secondary',
click: () => {
rcmail.__file_upload(files, post_args, props);
dialog.dialog('close');
}
},
]);
//server indicated, it can't use the known username and password from the session
//to login to nextcloud. Probably because, 2FA is active.
if (rcmail.env.nextcloud_upload_available !== true && rcmail.env.nextcloud_upload_login_available === true) {
// noinspection SpellCheckingInspection
let dialog = rcmail.show_popup_dialog(
rcmail.gettext("file_big_not_logged_in_explain", "nextcloud_attachments")
.replace("%size%", human_limit.toFixed(0) + " " + unit[unit_idx] + "B"),
rcmail.gettext("file_big", "nextcloud_attachments"), [
{
text: rcmail.gettext("login_and_link_file", "nextcloud_attachments"),
'class': 'mainaction login',
click: (e) => {
post_args = {_target: "cloud", ...post_args};
rcmail.nextcloud_login_button_click_handler(e, dialog, files, post_args, props);
}

},
{
text: rcmail.gettext("attach", "nextcloud_attachments"),
'class': 'secondary',
click: () => {
rcmail.__file_upload(files, post_args, props);
dialog.dialog('close');
}
},
]);
} else {
// noinspection SpellCheckingInspection
let dialog = rcmail.show_popup_dialog(
rcmail.gettext("file_big_explain", "nextcloud_attachments")
.replace("%size%", human_size.toFixed(0) + " " + unit[unit_idx] + "B"),
rcmail.gettext("file_big", "nextcloud_attachments"), [
{
text: rcmail.gettext("link_file", "nextcloud_attachments"),
'class': 'mainaction',
click: () => {
post_args = {_target: "cloud", ...post_args};
rcmail.__file_upload(files, post_args, props);
dialog.dialog('close');
}
},
{
text: rcmail.gettext("attach", "nextcloud_attachments"),
'class': 'secondary',
click: () => {
rcmail.__file_upload(files, post_args, props);
dialog.dialog('close');
}
},
]);
}
//pass on to original function, as we can't feasibly delay until the finishes, if they do at all
return false;
}//upload the files
Expand Down
4 changes: 4 additions & 0 deletions l10n/de_DE.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ $labels['logging_in'] = "Melde bei Nextcloud an.";
$labels['no_login_link'] = "Keinen Link empfangen. Bitte versuchen Sie es später erneut.";
$labels['logged_in_reupload'] = "Erfolgreich bei Nextcloud angemeldet.";
$labels['login'] = "Anmelden";
$labels['login_and_link_file'] = "Anmelden und Link teilen";


$labels['file_too_big'] = "Datei zu groß";

Expand All @@ -16,6 +18,8 @@ $labels['file_too_big_explain'] = " Die Datei ist größer als %limit%
$labels['file_big'] = "Wie möchten Sie diese Datei teilen?";
$labels['file_big_explain'] = "Die Datei ist ziemlich groß: %size%. Sie können Ihre E-Mails klein halten, ".
"in dem Sie sie über Nextcloud als Datei-Link teilen.";
$labels['file_big_not_logged_in_explain'] = "Die Datei ist ziemlich groß: %size%. Sie können Ihre E-Mails klein halten, in dem Sie unten".
" ihren Nextcloud Account verbinden und stattdessen einen Datei-Link teilen.";

$labels['link_file'] = "Hochladen und als Link teilen";
$labels['attach'] = "Als Kopie anfügen";
Expand Down
3 changes: 3 additions & 0 deletions l10n/en_US.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $labels['logging_in'] = "Logged-in to Nextcloud.";
$labels['no_login_link'] = "No login link received. Please try again later.";
$labels['logged_in'] = "Successfully logged-in to Nextcloud.";
$labels['login'] = "Login";
$labels['login_and_link_file'] = "Login and share Link";

$labels['file_too_big'] = "File Too Big";

Expand All @@ -15,6 +16,8 @@ $labels['file_too_big_explain'] = "The file is larger then %limit% and can't be

$labels['file_big'] = "How do You Want to Share the File?";
$labels['file_big_explain'] = "The file is quite large: %size%. You can keep your emails small by sharing it as a file-link instead.";
$labels['file_big_not_logged_in_explain'] = "The file is quite large: %size%. You can keep your emails small by connecting".
" your Nextcloud account below and sharing it as a file-link instead.";

$labels['link_file'] = "Upload and share link";
$labels['attach'] = "Attach copy";
Expand Down

0 comments on commit fcd8891

Please sign in to comment.