pluginForm = (req, plugin) => {
  const schema = db.getTenantSchema();
  const form = new Form({
    action: "/plugins",
    fields: [
      new Field({
        label: req.__("Name"),
        name: "name",
        input_type: "text",
        sublabel: req.__("Module name"),
      }),
      new Field({
        label: req.__("Source"),
        name: "source",
        type: getState().types.String,
        required: true,
        attributes: { options: ["npm", "local", "github", "git"] },
        sublabel: req.__(
          "Source of module for install. Few options:" +
            "npm - download from npm repository," +
            "local - get from local file system," +
            "github - download from github," +
            "git - get from git"
        ),
      }),
      new Field({
        label: req.__("Location"),
        name: "location",
        input_type: "text",
        sublabel: req.__(
          "For npm - name of npm package, e.g. @saltcorn/html or saltcorn-gantt, check at npmjs.com, " +
            "for local - absolute path to module folder in file system, e.g. C:\\gitsrc\\any-bootstrap-theme\\, " +
            "for github - name of github project."
        ),
      }),
      ...(schema === db.connectObj.default_schema
        ? [
            new Field({
              label: req.__("Version"),
              name: "version",
              input_type: "text",
              sublabel: req.__("Version of module, latest is default value"),
            }),
          ]
        : []),
      new Field({
        label: req.__("Private SSH key"),
        sublabel:
          "Optional, for private repositories. Generate key by running ssh-keygen, then upload public key as GitHub or GitLab deploy key",
        name: "deploy_private_key",
        input_type: "textarea",
        showIf: { source: "git" },
      }),
    ],
    submitLabel: plugin ? req.__("Save") : req.__("Create"),
  });
  if (plugin) {
    if (plugin.id) form.hidden("id");
    form.values = plugin;
  }
  return form;
}
Plugin Form Creation
@param {object} req
@param {object} plugin
@returns {Form}