mirror of
https://github.com/coder/coder.git
synced 2026-10-28 02:42:54 +08:00
refactor(site): generalize UserCell component (#484)
Summary: This is a first step in porting over v1 AuditLog in a refactored/cleaned up fashion. The existing `UserCell` component was generalized for re-use across various tables (AuditLog, Users, Orgs). Details: - Move UserCell to `components/Table/Cells` - Add tests and stories for UserCell Impact: This unblocks future work in list views like the audit log, user management panel and organizations management panel. Relations: - This commit relates to https://github.com/coder/coder/issues/472, but does not finish it. - This commit should not merge until after https://github.com/coder/coder/pull/465 and https://github.com/coder/coder/pull/483 because it's based on them.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { firstLetter } from "./first-letter"
|
||||
|
||||
describe("first-letter", () => {
|
||||
it.each<[string, string]>([
|
||||
["", ""],
|
||||
["User", "U"],
|
||||
["test", "T"],
|
||||
])(`firstLetter(%p) returns %p`, (input, expected) => {
|
||||
expect(firstLetter(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* firstLetter extracts the first character and returns it, uppercased.
|
||||
*/
|
||||
export const firstLetter = (str: string): string => {
|
||||
if (str.length > 0) {
|
||||
return str[0].toLocaleUpperCase()
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user