webmin / authentic-theme

Official theme for the best server management panel of the 21st Century
https://authentic-theme.com
MIT License
947 stars 163 forks source link

Can you help me troubleshoot this JS error in Authentic? #654

Closed swelljoe closed 7 years ago

swelljoe commented 7 years ago

Hey Ilia,

I've built a new module for managing Jailkit configuration. Super simple with just a few forms. It works fine in the old framed theme, but the delete confirmation form fails in Authentic theme with a JavaScript error.

In Firefox the error is:

ReferenceError: $load____ext is not defined

In Chrome the error is:

Uncaught ReferenceError: $load____ext is not defined
at HTMLIFrameElement.<anonymous> (init.min.js?1832:6)
at HTMLIFrameElement.dispatch (bundle.min.js?1832:2)
at HTMLIFrameElement.r.handle (bundle.min.js?1832:2)

The new module which exhibits this problem is here:

https://github.com/swelljoe/webmin-jailkit

It's kinda clunky (it's been a while since I've built a Webmin module), but it works in the old theme, so I dunno what to do about it. The problem shows up when you select a jail, and click delete.

The see this, you don't need Jailkit installed, but you do need a file in /etc/jailkit/jk_init.ini

That file would look something like this (it can have any number of sections, this is enough to allow you to test with multi deletes though both single and multi-deletes fail with the same error; it's the delete confirmation page that fails to work):

[logbasics]
comment=timezone information and log sockets
paths=/etc/localtime
need_logsocket=1

[jk_lsh]
comment=Jailkit limited shell
paths=/usr/sbin/jk_lsh, /etc/jailkit/jk_lsh.ini
users=root
groups=root
includesections=logbasics

[limitedshell]
comment=alias for jk_lsh

[cvs]
comment=Concurrent Versions System
paths=cvs
devices=/dev/null

As an aside, I hate the use of ____ in variables! There's so many underscores throughout Authentic, and the number of underscores seems to be significant (there's a lot of them, but different numbers of them in different variables...very hard to read and make sense of).

iliajie commented 7 years ago

Joe, hi!

I will try to take a look tonight.

iliajie commented 7 years ago

Joe,

When Config::IniFiles is not installed the error is returned:

Error - Perl execution failed

Can't locate Config/IniFiles.pm in @INC (@INC contains: /usr/libexec/webmin /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /usr/libexec/webmin/ ..) at ./jailkit-lib.pl line 32.
BEGIN failed--compilation aborted at ./jailkit-lib.pl line 32.
Compilation failed in require at /usr/libexec/webmin/webmin-jailkit/index.cgi line 8.

Here is the fix https://github.com/swelljoe/webmin-jailkit/pull/1

Yes, I used those for the purpose of giving a notion to the level of the variable. I will try to avoid using it in the future. (for Mail Module).

iliajie commented 7 years ago

I built JailKit quickly, it works! ;)

iliajie commented 7 years ago

The other reason why I used it, is to make sure that global variables are not overwritten due to old and stupid concept that has been fixed in ES6.

Now we can and should use const and let.

Block-scoped binding constructs. let is the new var. const is single-assignment. Static restrictions prevent use before assignment.

function f() {
  {
    let x;
    {
      // okay, block scoped name
      const x = "sneaky";
      // error, const
      x = "foo";
    }
    // error, already declared in block
    let x = "inner";
  }
}

Have a look at ES6 features - it's a joy!

swelljoe commented 7 years ago

Block scope is great! I agree! (It's something I missed when going to Python many years ago...Perl had block scope, but Python didn't.)

swelljoe commented 7 years ago

Also, thanks! That fixes it. Now I can work on other stuff for Virtualmin 6 release!