-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVPROD-7658: Create event log tables on Event Log page (#304)
- Loading branch information
1 parent
7b4c56c
commit 89f6165
Showing
19 changed files
with
986 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe("event log page", () => { | ||
const IMAGE_EVENT_LIMIT = 5; | ||
it("load more button should return twice as many events", () => { | ||
cy.visit("/image/ubuntu2204/event-log"); | ||
cy.dataCy("image-event-log-card").should("have.length", IMAGE_EVENT_LIMIT); | ||
cy.dataCy("load-more-button").click(); | ||
cy.dataCy("image-event-log-card").should( | ||
"have.length", | ||
2 * IMAGE_EVENT_LIMIT, | ||
); | ||
}); | ||
|
||
it("should show no events when filtering for a nonexistent item", () => { | ||
cy.visit("/image/ubuntu2204/event-log"); | ||
cy.dataCy("image-event-log-card").should("have.length", IMAGE_EVENT_LIMIT); | ||
cy.dataCy("image-event-log-name-filter").first().click(); | ||
cy.get('input[placeholder="Search name"]').type("bogus{enter}"); | ||
cy.dataCy("image-event-log-card") | ||
.first() | ||
.within(() => { | ||
cy.dataCy("image-event-log-table-row").should("have.length", 0); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { EventDiffTable } from "./EventDiffTable"; | ||
export { EventLog } from "./EventLog"; | ||
export { EVENT_LIMIT, useEvents } from "./useEvents"; | ||
export { useEvents } from "hooks/useEvents"; | ||
export type { Event } from "./types"; |
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
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,20 @@ | ||
query ImageEvents($imageId: String!, $limit: Int!, $page: Int!) { | ||
image(imageId: $imageId) { | ||
events(limit: $limit, page: $page) { | ||
count | ||
eventLogEntries { | ||
amiAfter | ||
amiBefore | ||
entries { | ||
action | ||
after | ||
before | ||
name | ||
type | ||
} | ||
timestamp | ||
} | ||
} | ||
id | ||
} | ||
} |
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
2 changes: 0 additions & 2 deletions
2
...components/Settings/EventLog/useEvents.ts → apps/spruce/src/hooks/useEvents/index.ts
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
6 changes: 4 additions & 2 deletions
6
apps/spruce/src/pages/distroSettings/tabs/EventLogTab/useDistroEvents.ts
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,36 @@ | ||
import styled from "@emotion/styled"; | ||
import { Disclaimer, Subtitle } from "@leafygreen-ui/typography"; | ||
import { size } from "constants/tokens"; | ||
import { useDateFormat } from "hooks"; | ||
|
||
interface HeaderProps { | ||
amiBefore: string; | ||
amiAfter: string; | ||
timestamp: Date; | ||
} | ||
|
||
export const Header: React.FC<HeaderProps> = ({ | ||
amiAfter, | ||
amiBefore, | ||
timestamp, | ||
}) => { | ||
const getDateCopy = useDateFormat(); | ||
|
||
return ( | ||
<StyledHeader> | ||
<Subtitle data-cy="event-log-timestamp"> | ||
{getDateCopy(timestamp)} | ||
</Subtitle> | ||
<Disclaimer data-cy="event-log-ami"> | ||
AMI changed from {amiBefore} to {amiAfter} | ||
</Disclaimer> | ||
</StyledHeader> | ||
); | ||
}; | ||
|
||
const StyledHeader = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${size.xxs}; | ||
padding-bottom: ${size.s}; | ||
`; |
69 changes: 69 additions & 0 deletions
69
apps/spruce/src/pages/image/ImageEventLog/ImageEventLog.tsx
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,69 @@ | ||
import styled from "@emotion/styled"; | ||
import Card from "@leafygreen-ui/card"; | ||
import { Subtitle } from "@leafygreen-ui/typography"; | ||
import { LoadingButton } from "components/Buttons"; | ||
import { size } from "constants/tokens"; | ||
import { ImageEvent } from "gql/generated/types"; | ||
import { Header } from "./Header"; | ||
import { ImageEventLogTable } from "./ImageEventLogTable"; | ||
|
||
type ImageEventLogProps = { | ||
allEventsFetched: boolean; | ||
events: ImageEvent[]; | ||
handleFetchMore: () => void; | ||
loading?: boolean; | ||
}; | ||
|
||
export const ImageEventLog: React.FC<ImageEventLogProps> = ({ | ||
allEventsFetched, | ||
events, | ||
handleFetchMore, | ||
loading, | ||
}) => { | ||
const allEventsFetchedCopy = | ||
events.length > 0 ? "No more events to show." : "No events to show."; | ||
|
||
return ( | ||
<Container> | ||
{events.map((event) => { | ||
const { amiAfter, amiBefore, entries, timestamp } = event; | ||
return ( | ||
<ImageEventLogCard | ||
key={`event_log_${timestamp}`} | ||
data-cy="image-event-log-card" | ||
> | ||
<Header | ||
amiAfter={amiAfter} | ||
amiBefore={amiBefore ?? ""} | ||
timestamp={timestamp} | ||
/> | ||
<ImageEventLogTable entries={entries} /> | ||
</ImageEventLogCard> | ||
); | ||
})} | ||
{!allEventsFetched && events.length > 0 && ( | ||
<LoadingButton | ||
data-cy="load-more-button" | ||
loading={loading} | ||
onClick={handleFetchMore} | ||
variant="primary" | ||
> | ||
Load more events | ||
</LoadingButton> | ||
)} | ||
{allEventsFetched && <Subtitle>{allEventsFetchedCopy}</Subtitle>} | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: ${size.l}; | ||
`; | ||
|
||
const ImageEventLogCard = styled(Card)` | ||
width: 100%; | ||
padding: ${size.m}; | ||
`; |
Oops, something went wrong.