Skip to content

Commit

Permalink
UI:Adds rating
Browse files Browse the repository at this point in the history
This patch adds:
- User can rate a particular resource
- User can see their previous rating
- User can update their rating
- To rate a resource user needs to be authenticated to Hub

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 authored and tekton-robot committed Dec 23, 2020
1 parent 2dc7b11 commit 77cb573
Show file tree
Hide file tree
Showing 20 changed files with 527 additions and 391 deletions.
6 changes: 5 additions & 1 deletion ui/src/components/Cards/Cards.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}

.hub-rating {
margin-top: 0.32em;
margin-top: 0.1em;
}

.hub-resource-name {
Expand Down Expand Up @@ -44,6 +44,10 @@
vertical-align: -0.125em;
}

.hub-rating-icon svg {
color: #484848;
}

.hub-card-link {
text-decoration: none;
}
Expand Down
28 changes: 21 additions & 7 deletions ui/src/components/Cards/__snapshots__/Cards.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4\\" />
</span>
<TextContent className=\\"hub-rating\\">
4
</TextContent>
Expand Down Expand Up @@ -57,7 +59,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
</span>
<TextContent className=\\"hub-rating\\">
5
</TextContent>
Expand Down Expand Up @@ -100,7 +104,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
</span>
<TextContent className=\\"hub-rating\\">
5
</TextContent>
Expand Down Expand Up @@ -143,7 +149,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
</span>
<TextContent className=\\"hub-rating\\">
5
</TextContent>
Expand Down Expand Up @@ -189,7 +197,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"5\\" />
</span>
<TextContent className=\\"hub-rating\\">
5
</TextContent>
Expand Down Expand Up @@ -233,7 +243,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"user\\" size=\\"sm\\" label=\\"tekton\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4.5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4.5\\" />
</span>
<TextContent className=\\"hub-rating\\">
4.5
</TextContent>
Expand Down Expand Up @@ -276,7 +288,9 @@ exports[`Cards should render the resources on cards 1`] = `
<Icon id=\\"cat\\" size=\\"sm\\" label=\\"tekton-hub\\" />
</span>
<CardActions>
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4.5\\" />
<span className=\\"hub-rating-icon\\">
<Icon id=\\"star\\" size=\\"sm\\" label=\\"4.5\\" />
</span>
<TextContent className=\\"hub-rating\\">
4.5
</TextContent>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/Cards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const Cards: React.FC<Props> = (resources) => {
</span>

<CardActions>
<Icon id={Icons.Star} size={IconSize.sm} label={String(resource.rating)} />
<span className="hub-rating-icon">
<Icon id={Icons.Star} size={IconSize.sm} label={String(resource.rating)} />
</span>
<TextContent className="hub-rating">{resource.rating}</TextContent>
</CardActions>
</CardHeader>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Icon/__snapshots__/Icon.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`Icon Component should render icon for Official Catalog 1`] = `"<CatIcon

exports[`Icon Component should render icon for Pipeline Kind 1`] = `"<DomainIcon size=\\"md\\" className=\\"hub-icon\\" label=\\"Pipeline\\" color=\\"currentColor\\" noVerticalAlign={false} />"`;

exports[`Icon Component should render icon for Rating 1`] = `"<StarIcon size=\\"sm\\" className=\\"hub-icon\\" label=\\"Rating\\" color=\\"currentColor\\" noVerticalAlign={false} />"`;
exports[`Icon Component should render icon for Rating 1`] = `"<StarIcon size=\\"sm\\" label=\\"Rating\\" color=\\"currentColor\\" noVerticalAlign={false} />"`;

exports[`Icon Component should render icon for Task Kind 1`] = `"<BuildIcon size=\\"sm\\" className=\\"hub-icon\\" label=\\"Task\\" color=\\"currentColor\\" noVerticalAlign={false} />"`;

Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Icon: React.FC<Props> = (props: Props) => {
case Icons.Domain:
return <DomainIcon size={size} className="hub-icon" label={label} />;
case Icons.Star:
return <StarIcon size={size} className="hub-icon" label={label} />;
return <StarIcon size={size} label={label} />;
case Icons.Github:
return <GithubIcon size={size} className="hub-icon" label={label} />;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/containers/Authentication/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Authentication: React.FC = observer(() => {
/>
</CardBody>
</Card>
{user.err ? (
{user.authErr ? (
<AlertGroup isToast>
<Alert
isLiveRegion
Expand Down
4 changes: 4 additions & 0 deletions ui/src/containers/BasicDetails/BasicDetails.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@
position: relative;
left: 3em;
}

.hub-details-average-rating svg {
color: #484848;
}
5 changes: 5 additions & 0 deletions ui/src/containers/BasicDetails/BasicDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const { Provider, root } = createProviderAndStore(api);

jest.mock('react-router-dom', () => {
return {
useHistory: () => {
return {
history: ''
};
},
useParams: () => {
return {
name: 'buildah'
Expand Down
Loading

0 comments on commit 77cb573

Please sign in to comment.