Example #1
0
function makeMenu(row) {
  row = row || rootRow;
  var actions = [];
  var type = row.mode === modes.tree ? "Folder" :
             modes.isFile(row.mode) ? "File" :
             row.mode === modes.sym ? "SymLink" :
             row.path.indexOf("/") < 0 ? "Repo" : "Submodule";
  if (row.mode === modes.tree || row.mode === modes.commit) {
    if (openPaths[row.path]) {
      actions.push(
        {icon:"doc", label:"Create File", action: createFile},
        {icon:"folder", label:"Create Folder", action: createFolder},
        {icon:"link", label:"Create SymLink", action: createSymLink},
        {sep:true},
        {icon:"folder", label:"Import Folder", action: importFolder},
        {icon:"git", label: "Mount Local Repo", action: mountBareRepo},
        // {icon:"fork", label: "Clone Remote Repo", action: addSubmodule},
        {icon:"github", label: "Mount Github Repo", action: addGithubMount}
      );
      if (!row.path) {
        actions.push({icon:"ccw", label: "Remove All", action: removeAll});
      }
    }
  }
  if (row.mode === modes.commit) {
    actions.push(
      {sep:true},
      {icon:"spinner", label: "Update", action: updateRemote}
    );
    if (fs.isDirty(row.path)) actions.push(
      {icon:"floppy", label:"Commit Changes", action: commitChanges},
      {icon:"ccw", label:"Revert all Changes", action: revertChanges}
    );
    // if (!config.githubName) {
    //   actions.push({sep:true});
    //   actions.push({icon:"download-cloud", label:"Pull from Remote"});
    //   actions.push({icon:"upload-cloud", label:"Push to Remote"});
    // }
  }
  else if (modes.isFile(row.mode)) {
    var label = (row.mode === modes.exec) ?
      "Make not Executable" :
      "Make Executable";
    actions.push(
      {sep:true},
      {icon:"asterisk", label: label, action: toggleExec}
    );
  }
  if (row.path) actions.push(
    {sep:true},
    {icon:"pencil", label:"Move " + type, action: moveEntry},
    {icon:"docs", label:"Copy " + type, action: copyEntry},
    {icon:"trash", label:"Delete " + type, action: removeEntry}
  );
  actions.push(
    {sep:true},
    {icon:"globe", label:"Serve Over HTTP", action: pullServe},
    {icon:"hdd", label:"Live Export to Disk", action: pushExport}
  );

  // If there was a leading separator, remove it.
  if (actions[0].sep) actions.shift();

  return actions;
}
Example #2
0
function makeMenu(row) {
  row = row || rootRow;
  var actions = [];
  var type = row.mode === modes.tree ? "Folder" :
             modes.isFile(row.mode) ? "File" :
             row.mode === modes.sym ? "SymLink" :
             row.path.indexOf("/") < 0 ? "Repo" : "Submodule";
  if (row.mode === modes.tree || row.mode === modes.commit) {
    if (openPaths[row.path]) {
      actions.push(
        {icon:"doc", label:"Create File", action: createFile},
        {icon:"folder", label:"Create Folder", action: createFolder},
        {icon:"link", label:"Create SymLink", action: createSymLink}
      );
      if (backends.length) {
        actions.push({sep:true});
        backends.forEach(function (backend) {
          if (backend.menuItem) actions.push(backend.menuItem);
        });
      }
      if (!row.path) {
        actions.push({icon:"ccw", label: "Remove All Repos", action: removeAll});
      }
    }
  }
  if (row.mode === modes.commit) {
    if (fs.isDirty(row.path)) actions.push(
      {sep:true},
      {icon:"floppy", label:"Commit Changes", action: commitChanges},
      {icon:"ccw", label:"Revert all Changes", action: revertChanges}
    );
    var config = fs.configs[row.path];
    var repo = fs.findRepo(row.path);
    if (repo.fetch && config.current === config.head) {
      actions.push(
        {sep:true},
        {icon:"cw", label:"Sync with Remote", action: sync }
      );
      if (config.ahead && config.behind) {
        actions.push(
          {icon:"upload-cloud", label:"Force push", action: forcePush },
          {icon:"trash", label:"Discard Local Commits", action: discardCommits }
        );
      }
    }
  }
  else if (modes.isFile(row.mode)) {
    var label = (row.mode === modes.exec) ?
      "Make not Executable" :
      "Make Executable";
    actions.push(
      {sep:true},
      {icon:"asterisk", label: label, action: toggleExec}
    );
  }
  if (row.path) actions.push(
    {sep:true},
    {icon:"pencil", label:"Move " + type, action: moveEntry},
    {icon:"docs", label:"Copy " + type, action: copyEntry},
    {icon:"trash", label:"Delete " + type, action: removeEntry}
  );
  if (runtimes.length) {
    actions.push({sep:true});
    runtimes.forEach(function (runtime) {
      if (runtime.menuItem) actions.push(runtime.menuItem);
    });
  }

  // If there was a leading separator, remove it.
  if (actions[0].sep) actions.shift();

  return actions;
}