parameters: (self, mode="strict", base_dir=False)
return_statement: return menu
docstring: menu_item = MenuItem(type='action', label='Download Files')
          menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
              var search_type = activator.getAttribute("spt_search_type");
              var search_codes = activator.getAttribute("spt_search_codes");
              if (! search_codes ) {
                  alert( "No SObject associated with this folder" );
                  return;
              }
  
              search_codes = search_codes.split("|");
              if (search_codes.length > 1) {
                  alert( "Too many sobjects associated with this folder");
                  return;
              }
  
              var search_key = search_type + "&code=" + search_codes[0];
              var class_name = 'tactic.ui.widget.CheckinWdg';
              var kwargs = {
                  search_key: search_key
              };
              spt.panel.load_popup("Check-in", class_name, kwargs);
              '''
          } )
docstring_summary: menu_item = MenuItem(type='action', label='Download Files')
          menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
              var search_type = activator.getAttribute("spt_search_type");
              var search_codes = activator.getAttribute("spt_search_codes");
              if (! search_codes ) {
                  alert( "No SObject associated with this folder" );
                  return;
              }
docstring_tokens: menu_item = MenuItem ( type = action label = Download Files ) menu . add ( menu_item ) menu_item . add_behavior ( { type : click_up cbjs_action : var activator = spt . smenu . get_activator ( bvr ) ; var search_type = activator . getAttribute ( spt_search_type ) ; var search_codes = activator . getAttribute ( spt_search_codes ) ; if ( ! search_codes ) { alert ( No SObject associated with this folder ) ; return ; }
function: def get_dir_context_menu(self, mode="strict", base_dir=False):
  
          parent_key = self.kwargs.get("parent_key")
          search_types = self.kwargs.get("search_types")
          
          parent_mode = self.parent_mode
  
          menu = Menu(width=180)
          
          menu.set_allow_icons(False)
  
          menu_item = MenuItem(type='title', label='Actions')
          menu.add(menu_item)
  
          if mode == "freeform":
              menu_item = MenuItem(type='action', label='New Folder')
              menu.add(menu_item)
              menu_item.add_behavior( {
                  'type': 'click_up',
                  'cbjs_action': r'''
                 
                  spt.repo_browser.set_lock(true, "context_menu_action");
  
                  var activator = spt.smenu.get_activator(bvr);
                  var relative_dir = activator.getAttribute("spt_relative_dir");
                  var search_type = activator.getAttribute("spt_search_type");
                
                  //TODO: If direct ry is not open, open it to edit new item.
                  //if (!activator.hasClass("spt_open")) {
                  //    var swap_top = activator.getElement(".spt_swap_top");
                  //    var swap_child = swap_top.getLast();
                  //    var expand_bvrs = spt.behavior.get_bvrs_by_type("click_up", swap_child);
                  //    for (var i = 0; i < expand_bvrs.length; i++) {
                  //        spt.behavior.run_cbjs(expand_bvrs[i].cbjs_action, {src_el: swap_child});
                  //    }
                  //}
  
                  var div = document.createElement("div");
                  div = document.id(div);
                  div.setStyle("margin-top: 3px")
  
                  var arrow = "/context/icons/silk/_spt_bullet_arrow_down_dark.png";
                  var icon = "/context/icons/silk/folder.png";
                  var html = "";
                  html += '<img src="'+arrow+'"/>';
                  html += '<img src="'+icon+'"/>';
                  html += '<input class="new_folder_input" type="text" value="New Folder" style="z-index:10;"/>';
                  div.innerHTML = html;
  
                  if (activator.hasClass("spt_base_dir")) {
                      activator = activator.getParent();                    
                      var content = activator.getNext(".spt_dir_list_handler_top");    
                  } else {
                      var content = activator.getNext(".spt_dir_content");
                      dyn_content = content.getElement(".spt_dir_list_handler_top");
                      if (dyn_content) {
                          content = dyn_content;
                      }
                  }
   
                  var children = content.getElements(".spt_dir");
                  if (content.childNodes.length)
                      div.inject(content.childNodes[0], "before");
                  else
                      div.inject(content);
  
                  var padding = activator.getStyle("padding-left");
                  padding = parseInt( padding.replace("px", "") );
                  div.setStyle("padding-left", padding);
            
  
                  var input = div.getElement(".new_folder_input");
                  input.onblur = function() {
                      // Attempt to create new folder
                      var value = this.value;
  
                      var valid_regex = /^[a-zA-Z0-9\_\s\-\.]+$/;
                      if (!valid_regex.test(value)) {
                          spt.alert("Please enter a valid file system name. Names may contain alphanumeric characters, underscores, hyphens and spaces.");
                          div.destroy();
                          spt.repo_browser.set_lock(false);
                          return; 
                      }     
                      
                      var span = document.id(document.createElement("span"));
                      span.innerHTML = " " +value;
                      span.replaces(input);
                      span.addClass("spt_dir_value");
  
                      div.setAttribute("spt_relative_dir", new_relative_dir);
                      div.addClass("spt_dir_item");
                      
                      var new_relative_dir = relative_dir + "/" + value;
                      
                      var server = TacticServerStub.get();
                      var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
                      
                      var kwargs = {
                          search_type: bvr.search_type,
                          action: 'create_folder',
                          relative_dir: new_relative_dir
                      }
                      
                      try {
                          server.execute_cmd(class_name, kwargs);
                          
                          var dir_top = span.getParent(".spt_dir_list_handler_top");
                          spt.repo_browser.set_lock(false);   
                          if (!spt.repo_browser.update_ready()) {
                              spt.repo_browser.refresh_directory_listing(dir_top);
                          }
                      } catch(err) {
                          spt.alert(spt.exception.handler(err));
                          div.destroy();
                          spt.repo_browser.set_lock(false);
                          return;
                      }
                      
  
                  };
                  
                  input.addEvent( "keyup", function(evt) {
                      var key = evt.key;
                      if (key == 'enter') {
                          evt.stop();
                          this.blur();
                      }
                      // FIXME: This creates the new folder anyways.
                      //else if (key == 'esc') {
                      //    div.destroy();
                      //    spt.repo_browser.set_lock(false);
                      //}
                  } );
  
                  input.select();
  
                  '''
              } )
  
          if mode=="freeform" and base_dir==False:
              menu_item = MenuItem(type='action', label='Rename Folder')
              menu.add(menu_item)
              menu_item.add_behavior( {
                  'type': 'click_up',
                  'cbjs_action': '''
                  var activator = spt.smenu.get_activator(bvr);
                  
                  var relative_dir = activator.getAttribute("spt_relative_dir");
                  var original_dir = activator.getAttribute("spt_reldir");
                  var original_el = activator.getElement(".spt_dir_value");
                  
                  // Create dummy entry
                  var div = document.createElement("div");
                  div = document.id(div);
                  div.setStyles(activator.style);
                  var arrow = "/context/icons/silk/_spt_bullet_arrow_down_dark.png";
                  var icon = "/context/icons/silk/folder.png";
                  var html = '<img src="'+arrow+'"/>';
                  html += '<img src="'+icon+'"/>';
                  html += '<input class="rename_folder_input" type="text" style="z-index:10;"/>';
                  div.innerHTML = html;
                  var input = div.getElement(".rename_folder_input");
  
                  var parts = relative_dir.split("/");
                  var original_value = parts[parts.length-1];
                  input.value = original_value;
                  var base_relative_dir = parts.slice(0, parts.length-1).join("/");
                  
                  activator.setStyle("display", "none");
                  div.inject(activator, "after");
                  
                  spt.repo_browser.set_lock(true, "context_menu_action");
   
                  var exit = function(div, activator) {
                      div.destroy();
                      activator.setStyle("display", "");
                      spt.repo_browser.set_lock(false);
                  }
  
                  input.onblur = function() {
                      
                      var value = this.value;
                      var valid_regex = /^[a-zA-Z0-9\_\s\-\.]+$/;
                      if (!valid_regex.test(value)) {
                          spt.alert("Please enter a valid file system name. Names may contain alphanumeric characters, underscores, hyphens and spaces.");
                          this.value = original_value;
                          spt.repo_browser.set_lock(false);
                          return; 
                      } else if (value == original_value) {
                          exit(div, activator);
                          return;
                      }
   
                      var new_relative_dir = base_relative_dir + "/" + value;
                      
                      var span = document.id(document.createElement("span"));
                      span.innerHTML = " " +value;
                      span.replaces(input);
  
                      try {
                          var server = TacticServerStub.get();
                          var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
                          var kwargs = {
                              search_type: bvr.search_type,
                              action: 'rename_folder',
                              old_relative_dir: relative_dir,
                              new_relative_dir: new_relative_dir
                          };
  
                          server.execute_cmd(class_name, kwargs)
                      
                          spt.notify.show_message("Folder renamed.");
                          var dir_top = activator.getParent(".spt_dir_list_handler_top");
                          
                          spt.repo_browser.update_folder_state(relative_dir, new_relative_dir);
                          
                          spt.repo_browser.set_lock(false);   
                          if (!spt.repo_browser.update_ready()) {
                              spt.repo_browser.refresh_directory_listing(dir_top);
                          } 
                      } catch(err) {
                          exit(div, activator);
                          spt.alert(spt.exception.handler(err));
                      }
  
                  };
                 
                  input.addEvent( "keyup", function(evt) {
                      var key = evt.key;
                      if (key == 'enter') {
                          evt.stop();
                          this.blur();
                      }
                  } ); 
                 
                  input.focus();
                  input.select();
  
                  '''
              } )
              
              menu_item = MenuItem(type='action', label='Delete Folder')
              menu.add(menu_item)
              menu_item.add_behavior( {
                  'type': 'click_up',
                  'parent_mode': parent_mode,
                  'cbjs_action': '''
                      spt.repo_browser.delete_assets(bvr); 
                  '''
              } )
  
  
  
              menu_item = MenuItem(type='separator')
              menu.add(menu_item)
  
  
          """
          menu_item = MenuItem(type='action', label='Download Files')
          menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
              var search_type = activator.getAttribute("spt_search_type");
              var search_codes = activator.getAttribute("spt_search_codes");
              if (! search_codes ) {
                  alert( "No SObject associated with this folder" );
                  return;
              }
  
              search_codes = search_codes.split("|");
              if (search_codes.length > 1) {
                  alert( "Too many sobjects associated with this folder");
                  return;
              }
  
              var search_key = search_type + "&code=" + search_codes[0];
              var class_name = 'tactic.ui.widget.CheckinWdg';
              var kwargs = {
                  search_key: search_key
              };
              spt.panel.load_popup("Check-in", class_name, kwargs);
              '''
          } )
          """
  
          if parent_key:
              parent = Search.get_by_search_key(parent_key)
              if parent:
                  search_type = parent.get_search_type()
          else:
              search_type = search_types[0]
  
  
          if search_type:
              ingest_key = "repo_browser_ingest:%s" % search_type
              ingest_settings = jsonloads(WidgetSettings.get_value_by_key(ingest_key))
              ingest_data_view = ingest_settings.get("ingest_data_view") or ""
              ingest_custom_view = ingest_settings.get("ingest_custom_view") or ""
              menu_item = MenuItem(type='action', label='Ingest Files')
              menu.add(menu_item)
              menu_item.add_behavior( {
                  'type': 'click_up',
                  'ingest_custom_view': ingest_custom_view,
                  'ingest_data_view': ingest_data_view,
                  'search_type': search_type,
                  'search_key': parent_key,
                  'cbjs_action': '''
                      var activator = spt.smenu.get_activator(bvr);
                      var relative_dir = activator.getAttribute("spt_relative_dir");
  
                      var kwargs = {
                          search_type: bvr.search_type,
                          search_key: bvr.search_key,
                          relative_dir: relative_dir,
                          ingest_data_view: bvr.ingest_data_view
                      };
                      
                      if (bvr.ingest_custom_view) {
                          kwargs['view'] = bvr.ingest_custom_view;
                          var class_name = 'tactic.ui.panel.CustomLayoutWdg';
                      } else {
                          var class_name = 'tactic.ui.tools.IngestUploadWdg';
                      }
  
                      var title = "Ingest Files";
                      spt.tab.set_main_body_tab();
                      spt.tab.add_new("ingest_" + bvr.search_type, title, class_name, kwargs);  
                  '''    
                      
              } ) 
  
  
          menu_item = MenuItem(type='separator')
          #menu.add(menu_item)
          
          menu_item = MenuItem(type='action', label='Copy To Clipboard')
          #menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
              var relative_dir = activator.getAttribute("spt_relative_dir");
  
              var server = TacticServerStub.get();
  
              var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
              var kwargs = {
                  search_type: bvr.search_type,
                  action: 'copy_clipboard',
                  relative_dir: relative_dir
              }
  
              var server = TacticServerStub.get();
              server.execute_cmd(class_name, kwargs);
  
  
              '''
          } )
  
  
          """
          TODO: This should not be exposed unless the applet is available.
          menu_item = MenuItem(type='action', label='Check-out Files')
          menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
  
              var relative_dir = activator.getAttribute("spt_relative_dir");
  
              var server = TacticServerStub.get();
              var snapshots = server.get_snapshots_by_relative_dir(relative_dir);
              if (!snapshots.length) {
                  alert("No files checked into this folder");
                  return;
              }
  
              var snapshot_codes = []
              for (var i = 0; i < snapshots.length; i++) {
                  snapshot_codes.push(snapshots[i].code);
              }
  
              var class_name = 'tactic.ui.tools.checkout_wdg.CheckoutWdg';
              var kwargs = {
                  base_dir: relative_dir,
                  snapshot_codes: snapshot_codes,
              }
              spt.panel.load_popup("Check-out", class_name, kwargs);
  
              return;
              '''
          } )
          """
  
  
          return menu
function_tokens: def get_dir_context_menu ( self , mode = "strict" , base_dir = False ) : parent_key = self . kwargs . get ( "parent_key" ) search_types = self . kwargs . get ( "search_types" ) parent_mode = self . parent_mode menu = Menu ( width = 180 ) menu . set_allow_icons ( False ) menu_item = MenuItem ( type = 'title' , label = 'Actions' ) menu . add ( menu_item ) if mode == "freeform" : menu_item = MenuItem ( type = 'action' , label = 'New Folder' ) menu . add ( menu_item ) menu_item . add_behavior ( { 'type' : 'click_up' , 'cbjs_action' : r'''
                 
                  spt.repo_browser.set_lock(true, "context_menu_action");
  
                  var activator = spt.smenu.get_activator(bvr);
                  var relative_dir = activator.getAttribute("spt_relative_dir");
                  var search_type = activator.getAttribute("spt_search_type");
                
                  //TODO: If direct ry is not open, open it to edit new item.
                  //if (!activator.hasClass("spt_open")) {
                  //    var swap_top = activator.getElement(".spt_swap_top");
                  //    var swap_child = swap_top.getLast();
                  //    var expand_bvrs = spt.behavior.get_bvrs_by_type("click_up", swap_child);
                  //    for (var i = 0; i < expand_bvrs.length; i++) {
                  //        spt.behavior.run_cbjs(expand_bvrs[i].cbjs_action, {src_el: swap_child});
                  //    }
                  //}
  
                  var div = document.createElement("div");
                  div = document.id(div);
                  div.setStyle("margin-top: 3px")
  
                  var arrow = "/context/icons/silk/_spt_bullet_arrow_down_dark.png";
                  var icon = "/context/icons/silk/folder.png";
                  var html = "";
                  html += '<img src="'+arrow+'"/>';
                  html += '<img src="'+icon+'"/>';
                  html += '<input class="new_folder_input" type="text" value="New Folder" style="z-index:10;"/>';
                  div.innerHTML = html;
  
                  if (activator.hasClass("spt_base_dir")) {
                      activator = activator.getParent();                    
                      var content = activator.getNext(".spt_dir_list_handler_top");    
                  } else {
                      var content = activator.getNext(".spt_dir_content");
                      dyn_content = content.getElement(".spt_dir_list_handler_top");
                      if (dyn_content) {
                          content = dyn_content;
                      }
                  }
   
                  var children = content.getElements(".spt_dir");
                  if (content.childNodes.length)
                      div.inject(content.childNodes[0], "before");
                  else
                      div.inject(content);
  
                  var padding = activator.getStyle("padding-left");
                  padding = parseInt( padding.replace("px", "") );
                  div.setStyle("padding-left", padding);
            
  
                  var input = div.getElement(".new_folder_input");
                  input.onblur = function() {
                      // Attempt to create new folder
                      var value = this.value;
  
                      var valid_regex = /^[a-zA-Z0-9\_\s\-\.]+$/;
                      if (!valid_regex.test(value)) {
                          spt.alert("Please enter a valid file system name. Names may contain alphanumeric characters, underscores, hyphens and spaces.");
                          div.destroy();
                          spt.repo_browser.set_lock(false);
                          return; 
                      }     
                      
                      var span = document.id(document.createElement("span"));
                      span.innerHTML = " " +value;
                      span.replaces(input);
                      span.addClass("spt_dir_value");
  
                      div.setAttribute("spt_relative_dir", new_relative_dir);
                      div.addClass("spt_dir_item");
                      
                      var new_relative_dir = relative_dir + "/" + value;
                      
                      var server = TacticServerStub.get();
                      var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
                      
                      var kwargs = {
                          search_type: bvr.search_type,
                          action: 'create_folder',
                          relative_dir: new_relative_dir
                      }
                      
                      try {
                          server.execute_cmd(class_name, kwargs);
                          
                          var dir_top = span.getParent(".spt_dir_list_handler_top");
                          spt.repo_browser.set_lock(false);   
                          if (!spt.repo_browser.update_ready()) {
                              spt.repo_browser.refresh_directory_listing(dir_top);
                          }
                      } catch(err) {
                          spt.alert(spt.exception.handler(err));
                          div.destroy();
                          spt.repo_browser.set_lock(false);
                          return;
                      }
                      
  
                  };
                  
                  input.addEvent( "keyup", function(evt) {
                      var key = evt.key;
                      if (key == 'enter') {
                          evt.stop();
                          this.blur();
                      }
                      // FIXME: This creates the new folder anyways.
                      //else if (key == 'esc') {
                      //    div.destroy();
                      //    spt.repo_browser.set_lock(false);
                      //}
                  } );
  
                  input.select();
  
                  ''' } ) if mode == "freeform" and base_dir == False : menu_item = MenuItem ( type = 'action' , label = 'Rename Folder' ) menu . add ( menu_item ) menu_item . add_behavior ( { 'type' : 'click_up' , 'cbjs_action' : '''
                  var activator = spt.smenu.get_activator(bvr);
                  
                  var relative_dir = activator.getAttribute("spt_relative_dir");
                  var original_dir = activator.getAttribute("spt_reldir");
                  var original_el = activator.getElement(".spt_dir_value");
                  
                  // Create dummy entry
                  var div = document.createElement("div");
                  div = document.id(div);
                  div.setStyles(activator.style);
                  var arrow = "/context/icons/silk/_spt_bullet_arrow_down_dark.png";
                  var icon = "/context/icons/silk/folder.png";
                  var html = '<img src="'+arrow+'"/>';
                  html += '<img src="'+icon+'"/>';
                  html += '<input class="rename_folder_input" type="text" style="z-index:10;"/>';
                  div.innerHTML = html;
                  var input = div.getElement(".rename_folder_input");
  
                  var parts = relative_dir.split("/");
                  var original_value = parts[parts.length-1];
                  input.value = original_value;
                  var base_relative_dir = parts.slice(0, parts.length-1).join("/");
                  
                  activator.setStyle("display", "none");
                  div.inject(activator, "after");
                  
                  spt.repo_browser.set_lock(true, "context_menu_action");
   
                  var exit = function(div, activator) {
                      div.destroy();
                      activator.setStyle("display", "");
                      spt.repo_browser.set_lock(false);
                  }
  
                  input.onblur = function() {
                      
                      var value = this.value;
                      var valid_regex = /^[a-zA-Z0-9\_\s\-\.]+$/;
                      if (!valid_regex.test(value)) {
                          spt.alert("Please enter a valid file system name. Names may contain alphanumeric characters, underscores, hyphens and spaces.");
                          this.value = original_value;
                          spt.repo_browser.set_lock(false);
                          return; 
                      } else if (value == original_value) {
                          exit(div, activator);
                          return;
                      }
   
                      var new_relative_dir = base_relative_dir + "/" + value;
                      
                      var span = document.id(document.createElement("span"));
                      span.innerHTML = " " +value;
                      span.replaces(input);
  
                      try {
                          var server = TacticServerStub.get();
                          var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
                          var kwargs = {
                              search_type: bvr.search_type,
                              action: 'rename_folder',
                              old_relative_dir: relative_dir,
                              new_relative_dir: new_relative_dir
                          };
  
                          server.execute_cmd(class_name, kwargs)
                      
                          spt.notify.show_message("Folder renamed.");
                          var dir_top = activator.getParent(".spt_dir_list_handler_top");
                          
                          spt.repo_browser.update_folder_state(relative_dir, new_relative_dir);
                          
                          spt.repo_browser.set_lock(false);   
                          if (!spt.repo_browser.update_ready()) {
                              spt.repo_browser.refresh_directory_listing(dir_top);
                          } 
                      } catch(err) {
                          exit(div, activator);
                          spt.alert(spt.exception.handler(err));
                      }
  
                  };
                 
                  input.addEvent( "keyup", function(evt) {
                      var key = evt.key;
                      if (key == 'enter') {
                          evt.stop();
                          this.blur();
                      }
                  } ); 
                 
                  input.focus();
                  input.select();
  
                  ''' } ) menu_item = MenuItem ( type = 'action' , label = 'Delete Folder' ) menu . add ( menu_item ) menu_item . add_behavior ( { 'type' : 'click_up' , 'parent_mode' : parent_mode , 'cbjs_action' : '''
                      spt.repo_browser.delete_assets(bvr); 
                  ''' } ) menu_item = MenuItem ( type = 'separator' ) menu . add ( menu_item ) if parent_key : parent = Search . get_by_search_key ( parent_key ) if parent : search_type = parent . get_search_type ( ) else : search_type = search_types [ 0 ] if search_type : ingest_key = "repo_browser_ingest:%s" % search_type ingest_settings = jsonloads ( WidgetSettings . get_value_by_key ( ingest_key ) ) ingest_data_view = ingest_settings . get ( "ingest_data_view" ) or "" ingest_custom_view = ingest_settings . get ( "ingest_custom_view" ) or "" menu_item = MenuItem ( type = 'action' , label = 'Ingest Files' ) menu . add ( menu_item ) menu_item . add_behavior ( { 'type' : 'click_up' , 'ingest_custom_view' : ingest_custom_view , 'ingest_data_view' : ingest_data_view , 'search_type' : search_type , 'search_key' : parent_key , 'cbjs_action' : '''
                      var activator = spt.smenu.get_activator(bvr);
                      var relative_dir = activator.getAttribute("spt_relative_dir");
  
                      var kwargs = {
                          search_type: bvr.search_type,
                          search_key: bvr.search_key,
                          relative_dir: relative_dir,
                          ingest_data_view: bvr.ingest_data_view
                      };
                      
                      if (bvr.ingest_custom_view) {
                          kwargs['view'] = bvr.ingest_custom_view;
                          var class_name = 'tactic.ui.panel.CustomLayoutWdg';
                      } else {
                          var class_name = 'tactic.ui.tools.IngestUploadWdg';
                      }
  
                      var title = "Ingest Files";
                      spt.tab.set_main_body_tab();
                      spt.tab.add_new("ingest_" + bvr.search_type, title, class_name, kwargs);  
                  ''' } ) menu_item = MenuItem ( type = 'separator' ) #menu.add(menu_item) menu_item = MenuItem ( type = 'action' , label = 'Copy To Clipboard' ) #menu.add(menu_item) menu_item . add_behavior ( { 'type' : 'click_up' , 'cbjs_action' : '''
              var activator = spt.smenu.get_activator(bvr);
              var relative_dir = activator.getAttribute("spt_relative_dir");
  
              var server = TacticServerStub.get();
  
              var class_name = 'tactic.ui.tools.RepoBrowserActionCmd';
              var kwargs = {
                  search_type: bvr.search_type,
                  action: 'copy_clipboard',
                  relative_dir: relative_dir
              }
  
              var server = TacticServerStub.get();
              server.execute_cmd(class_name, kwargs);
  
  
              ''' } ) """
          TODO: This should not be exposed unless the applet is available.
          menu_item = MenuItem(type='action', label='Check-out Files')
          menu.add(menu_item)
          menu_item.add_behavior( {
              'type': 'click_up',
              'cbjs_action': '''
              var activator = spt.smenu.get_activator(bvr);
  
              var relative_dir = activator.getAttribute("spt_relative_dir");
  
              var server = TacticServerStub.get();
              var snapshots = server.get_snapshots_by_relative_dir(relative_dir);
              if (!snapshots.length) {
                  alert("No files checked into this folder");
                  return;
              }
  
              var snapshot_codes = []
              for (var i = 0; i < snapshots.length; i++) {
                  snapshot_codes.push(snapshots[i].code);
              }
  
              var class_name = 'tactic.ui.tools.checkout_wdg.CheckoutWdg';
              var kwargs = {
                  base_dir: relative_dir,
                  snapshot_codes: snapshot_codes,
              }
              spt.panel.load_popup("Check-out", class_name, kwargs);
  
              return;
              '''
          } )
          """ return menu