pad.html: UI telling the user that a contribution is required before importing

This commit is an integration to 24ee37a38f.
This commit is contained in:
John McLear 2020-04-14 11:00:47 +00:00 committed by muxator
parent c6cb253f76
commit 208c7a849c
7 changed files with 43 additions and 3 deletions

View file

@ -70,4 +70,8 @@ input {
@media (max-width: 800px) {
.hide-for-mobile { display: none; }
}
}
#importmessagepermission {
display: none;
}

View file

@ -313,6 +313,16 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}
else if (msg.type == "ACCEPT_COMMIT")
{
/*
* this is the first time this user contributed to this pad. Let's record
* it, because it will be used for allowing import.
*
* TODO: here, we are changing this variable on the client side only. The
* server has all the informations to make the same deduction, and
* broadcast to the client.
*/
clientVars.thisUserHasEditedThisPad = true;
var newRev = msg.newRev;
if (msgQueue.length > 0)
{

View file

@ -394,6 +394,17 @@ var padeditbar = (function()
toolbar.registerCommand("import_export", function () {
toolbar.toggleDropDown("import_export", function(){
if (clientVars.thisUserHasEditedThisPad) {
// the user has edited this pad historically or in this session
$('#importform').show();
$('#importmessagepermission').hide();
} else {
// this is the first time this user visits this pad
$('#importform').hide();
$('#importmessagepermission').show();
}
// If Import file input exists then focus on it..
if($('#importfileinput').length !== 0){
setTimeout(function(){

View file

@ -113,6 +113,8 @@ var padimpexp = (function()
msg = html10n.get("pad.impexp.padHasData");
} else if(status === "maxFileSize"){
msg = html10n.get("pad.impexp.maxFileSize");
} else if(status === "permission"){
msg = html10n.get("pad.impexp.permission");
}
function showError(fade)