afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-07-05 12:33 pm

[dw-free] Separate "who can see command help" from "who can use command" on admi

[commit: http://hg.dwscoalition.org/dw-free/rev/cc023c368129]

http://bugs.dwscoalition.org/show_bug.cgi?id=1164

Update console to show all commands, but style commands that you can't use
so that it's obvious that they're unusable.

Patch by [staff profile] denise.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/Console.pm
  • htdocs/admin/console/reference.bml
--------------------------------------------------------------------------------
diff -r b7dfc4ad0e99 -r cc023c368129 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Sun Jul 05 12:23:01 2009 +0000
+++ b/bin/upgrading/en.dat	Sun Jul 05 12:33:12 2009 +0000
@@ -1259,6 +1259,8 @@ error.code.comm_not_found=Community not 
 error.code.comm_not_found=Community not found
 
 error.code.comm_not_member=User is not a member of this community
+
+error.console.notpermitted=You are not permitted to run this command.
 
 error.dberror=A database error occurred:
 
diff -r b7dfc4ad0e99 -r cc023c368129 cgi-bin/LJ/Console.pm
--- a/cgi-bin/LJ/Console.pm	Sun Jul 05 12:23:01 2009 +0000
+++ b/cgi-bin/LJ/Console.pm	Sun Jul 05 12:33:12 2009 +0000
@@ -180,12 +180,12 @@ sub command_reference_html {
 
     foreach my $cmd (sort keys %cmd2class) {
         my $class = $cmd2class{$cmd};
-        next if $class->is_hidden;
-        next unless $class->can_execute;
+        my $style = $class->can_execute ? "enabled" : "disabled";
 
-        $ret .= "<a name='cmd.$cmd'><h2><code><b>$cmd</b></a> ";
+        $ret .= "<hr /><div class='$style'><a name='cmd.$cmd'><h2><code><b>$cmd</b></a> ";
         $ret .= LJ::ehtml($class->usage);
         $ret .= "</code></h2>\n";
+        $ret .= "<p><em><?_ml error.console.notpermitted _ml?></em></p>" unless $class->can_execute;
 
         $ret .= $class->desc;
 
@@ -197,6 +197,7 @@ sub command_reference_html {
             }
             $ret .= "</dl>";
         }
+        $ret .= "</div>";
     }
 
 
diff -r b7dfc4ad0e99 -r cc023c368129 htdocs/admin/console/reference.bml
--- a/htdocs/admin/console/reference.bml	Sun Jul 05 12:23:01 2009 +0000
+++ b/htdocs/admin/console/reference.bml	Sun Jul 05 12:33:12 2009 +0000
@@ -32,4 +32,13 @@ _code?>
 
 <=body
 title=><?_code return $ML{'.title'};  _code?>
+head<=
+<style type='text/css'>
+<!--
+dd {margin-left: 2em; }
+dt {margin-top: 10px;}
+.disabled {color: #A0A0A0; margin-left: 3em;} 
+-->
+</style>
+<=head
 page?>
--------------------------------------------------------------------------------