getPageList = async (
  rows,
  roles,
  req,
  { tagId, domId, showList, filterOnTag } = {}
) => {
  const tags = await Tag.find();
  const tag_entries = await TagEntry.find({
    not: { page_id: null },
  });
  const tagsById = {};
  tags.forEach((t) => (tagsById[t.id] = t));

  const tagBadges = (page) => {
    const myTags = tag_entries.filter((te) => te.page_id === page.id);
    const myTagIds = new Set(myTags.map((t) => t.tag_id));
    return (
      myTags.map((te) => tagBadge(tagsById[te.tag_id], "pages")).join(nbsp) +
      mkAddBtn(tags, "pages", page.id, req, myTagIds)
    );
  };
  return mkTable(
    [
      {
        label: req.__("Name"),
        key: (r) => link(`/page/${encodeURIComponent(r.name)}`, r.name),
      },
      {
        label: "",
        key: (r) =>
          link(
            `/pageedit/edit/${encodeURIComponent(r.name)}`,
            req.__("Configure")
          ),
      },
      {
        label: "",
        key: (r) =>
          link(
            `/pageedit/edit-properties/${encodeURIComponent(r.name)}`,
            req.__("Edit")
          ),
      },
      ...(tagId
        ? []
        : [
            {
              label: tagsDropdown(
                tags,
                filterOnTag ? `Tag:${filterOnTag.name}` : undefined,
                req
              ),
              key: (r) => tagBadges(r),
            },
          ]),
      {
        label: req.__("Role to access"),
        key: (row) => editPageRoleForm(row, roles, req),
      },

      !tagId
        ? {
            label: "",
            key: (r) => page_dropdown(r, req),
          }
        : {
            label: req.__("Remove From Tag"),
            key: (r) =>
              post_delete_btn(
                `/tag-entries/remove/pages/${r.id}/${tagId}`,
                req,
                `${r.name} from this tag`
              ),
          },
    ],
    rows,
    {
      hover: true,
      tableClass: tagId ? `collapse ${showList ? "show" : ""}` : "",
      tableId: domId,
    }
  );
}
@param {*} rows
@param {*} roles
@param {object} req
@returns {div}