-
Notifications
You must be signed in to change notification settings - Fork 897
refactor: Show template versions as timeline #4800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
9271497
0f51a23
8ff38c8
0f84455
ffa188d
ec029e8
cf599aa
d80a7d7
0935969
053dc9b
5b835ba
2cc3127
15c7d9c
acdb081
0723e3d
67e51f0
b0729ce
cf6484c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE template_versions ALTER COLUMN created_by SET NULL |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE template_versions ALTER COLUMN created_by SET NOT NULL | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ type TemplateVersion struct { | |
Name string `json:"name"` | ||
Job ProvisionerJob `json:"job"` | ||
Readme string `json:"readme"` | ||
CreatedByID uuid.UUID `json:"created_by_id"` | ||
CreatedByName string `json:"created_by_name"` | ||
CreatedBy User `json:"created_by"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a strong opinion about that? I like the |
||
} | ||
|
||
// TemplateVersion returns a template version by ID. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { TimelineDateRow } from "components/Timeline/TimelineDateRow" | ||
import { Fragment } from "react" | ||
|
||
type GetDateFn<TData> = (data: TData) => Date | ||
|
||
const groupByDate = <TData,>( | ||
items: TData[], | ||
getDate: GetDateFn<TData>, | ||
): Record<string, TData[]> => { | ||
const itemsByDate: Record<string, TData[]> = {} | ||
|
||
items.forEach((item) => { | ||
const dateKey = getDate(item).toDateString() | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (itemsByDate[dateKey]) { | ||
itemsByDate[dateKey].push(item) | ||
} else { | ||
itemsByDate[dateKey] = [item] | ||
} | ||
}) | ||
|
||
return itemsByDate | ||
} | ||
|
||
export interface TimelineProps<TData> { | ||
items: TData[] | ||
getDate: GetDateFn<TData> | ||
row: (item: TData) => JSX.Element | ||
} | ||
|
||
export const Timeline = <TData,>({ | ||
items, | ||
getDate, | ||
row, | ||
}: TimelineProps<TData>): JSX.Element => { | ||
const itemsByDate = groupByDate(items, getDate) | ||
|
||
return ( | ||
<> | ||
{Object.keys(itemsByDate).map((dateStr) => { | ||
const items = itemsByDate[dateStr] | ||
|
||
return ( | ||
<Fragment key={dateStr}> | ||
<TimelineDateRow date={new Date(dateStr)} /> | ||
{items.map(row)} | ||
</Fragment> | ||
) | ||
})} | ||
</> | ||
) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.