DisplayNames returns a list of display names for the assigned actors.
()
| 156 | |
| 157 | // DisplayNames returns a list of display names for the assigned actors. |
| 158 | func (a AssignedActors) DisplayNames() []string { |
| 159 | // These display names are used for populating the "default" assigned actors |
| 160 | // from the AssignedActors type. But, this is only one piece of the puzzle |
| 161 | // as later, other queries will fetch the full list of possible assignable |
| 162 | // actors from the repository, and the two lists will be reconciled. |
| 163 | // |
| 164 | // It's important that the display names are the same between the defaults |
| 165 | // (the values returned here) and the full list (the values returned by |
| 166 | // other repository queries). Any discrepancy would result in an |
| 167 | // "invalid default", which means an assigned actor will not be matched |
| 168 | // to an assignable actor and not presented as a "default" selection. |
| 169 | // Not being presented as a default would cause the actor to be potentially |
| 170 | // unassigned if the edits were submitted. |
| 171 | // |
| 172 | // To prevent this, we need shared logic to look up an actor's display name. |
| 173 | // However, our API types between assignedActors and the full list of |
| 174 | // assignableActors are different. So, as an attempt to maintain |
| 175 | // consistency we convert the assignedActors to the same types as the |
| 176 | // repository's assignableActors, treating the assignableActors DisplayName |
| 177 | // methods as the sources of truth. |
| 178 | // TODO KW: make this comment less of a wall of text if needed. |
| 179 | var displayNames []string |
| 180 | for _, a := range a.Nodes { |
| 181 | if a.TypeName == "User" { |
| 182 | u := NewAssignableUser( |
| 183 | a.ID, |
| 184 | a.Login, |
| 185 | a.Name, |
| 186 | ) |
| 187 | displayNames = append(displayNames, u.DisplayName()) |
| 188 | } else if a.TypeName == "Bot" { |
| 189 | b := NewAssignableBot( |
| 190 | a.ID, |
| 191 | a.Login, |
| 192 | ) |
| 193 | displayNames = append(displayNames, b.DisplayName()) |
| 194 | } |
| 195 | } |
| 196 | return displayNames |
| 197 | } |
| 198 | |
| 199 | type Labels struct { |
| 200 | Nodes []IssueLabel |
no test coverage detected