async getForList()

in src/list/list-users-groups-source.ts [58:104]


  async getForList(query?: string, filter = Filter.ALL) {
    const [users, groups] = await this.getUserAndGroups(query);
    const items = [];

    if (filter === Filter.ALL) {
      items.push({
        rgItemType: List.ListProps.Type.SEPARATOR,
        key: 2,
        description: this.getUsersSectionTitle(users),
      });
    }

    if (filter !== Filter.GROUPS) {
      users.forEach(user =>
        items.push({
          ...user,
          key: user.id,
          label: user.name,
          avatar: user.profile ? user.profile.avatar?.url : null,
          description: user.login,
        }),
      );
    }

    if (filter === Filter.ALL) {
      items.push({
        rgItemType: List.ListProps.Type.SEPARATOR,
        key: 1,
        description: this.getGroupsSectionTitle(groups),
      });
    }

    if (filter !== Filter.USERS) {
      groups.forEach(group =>
        items.push({
          ...group,
          key: group.id,
          label: group.name,
          avatar: group.iconUrl,
          glyph: group.iconUrl ? null : GroupIcon,
          description: this.listSourceOptions.getPluralForUserCount(group.userCount),
        }),
      );
    }

    return items;
  }