-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display commit date and author in table
- Loading branch information
1 parent
21fc495
commit f6a7369
Showing
5 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-disable react/display-name */ | ||
/** @jsx jsx */ | ||
import { FC, useMemo } from 'react'; | ||
import { jsx } from 'theme-ui'; | ||
import { | ||
BlockContainer, | ||
BlockContainerProps, | ||
Table, | ||
} from '@component-controls/components'; | ||
import { dateToLocalString } from '@component-controls/core'; | ||
import { StoryInputProps, useStoryComponent } from '@component-controls/store'; | ||
import { useCustomProps } from '../context'; | ||
|
||
export type ComponentCommitsProps = BlockContainerProps & StoryInputProps; | ||
|
||
/** | ||
* Displays commit history for a component | ||
*/ | ||
export const ComponentCommits: FC<ComponentCommitsProps> = ({ | ||
id, | ||
name, | ||
...rest | ||
}) => { | ||
const props = useCustomProps<ComponentCommitsProps>('commits', rest); | ||
const component = useStoryComponent({ id, name }); | ||
|
||
const data = useMemo( | ||
() => | ||
component?.fileInfo?.commits?.map(i => { | ||
return { | ||
date: i.committerDate | ||
? dateToLocalString(new Date(i.committerDate)) | ||
: 'N/A', | ||
username: i.authorName, | ||
}; | ||
}), | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[], | ||
); | ||
|
||
const columns = useMemo( | ||
() => | ||
[ | ||
{ | ||
Header: 'Datee', | ||
accessor: 'date', | ||
}, | ||
{ | ||
Header: 'User Name', | ||
accessor: 'username', | ||
}, | ||
] as any[], | ||
[], | ||
); | ||
return ( | ||
<BlockContainer {...props}> | ||
<Table data={data} columns={columns} /> | ||
</BlockContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ComponentCommits'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters