This repository was archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Create Activities page to display all deployments in one place #382
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
16ee740
Add the activities view
5530ccf
Add the state for the activities page
eb81c85
Fix SearchActivities responsible
5de7add
Add ActivityHistory
fcfe4a1
Refactorying the `activities` view
fd4d949
Add the `production_only` param to the query
e94cb6b
Fix the bug from rebasing
593cb4e
Fix to adjust the text space
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
import { DeploymentStatusEnum } from "../../models" | ||
|
||
// https://ant.design/components/timeline/#Timeline.Item | ||
export const getStatusColor = (status: DeploymentStatusEnum): string => { | ||
switch (status) { | ||
case DeploymentStatusEnum.Waiting: | ||
return "gray" | ||
case DeploymentStatusEnum.Created: | ||
return "purple" | ||
case DeploymentStatusEnum.Queued: | ||
return "purple" | ||
case DeploymentStatusEnum.Running: | ||
return "purple" | ||
case DeploymentStatusEnum.Success: | ||
return "green" | ||
case DeploymentStatusEnum.Failure: | ||
return "red" | ||
case DeploymentStatusEnum.Canceled: | ||
return "gray" | ||
default: | ||
return "gray" | ||
} | ||
} |
This file contains hidden or 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,3 @@ | ||
import { getStatusColor } from "./deploymentStatus" | ||
|
||
export { getStatusColor } |
This file contains hidden or 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,66 @@ | ||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit" | ||
|
||
import { | ||
searchDeployments as _searchDeployments, | ||
} from "../apis" | ||
import { Deployment, } from "../models" | ||
|
||
export const perPage = 30 | ||
|
||
interface ActivitiesState { | ||
loading: boolean | ||
deployments: Deployment[] | ||
page: number | ||
} | ||
|
||
const initialState: ActivitiesState = { | ||
loading: false, | ||
deployments: [], | ||
page: 1, | ||
} | ||
|
||
export const searchDeployments = createAsyncThunk< | ||
Deployment[], { | ||
start?: Date, | ||
end?: Date, | ||
productionOnly: boolean, | ||
}, { | ||
state: { activities: ActivitiesState } | ||
}>( | ||
"activities/searchDeployments", | ||
async ({start, end, productionOnly}, { getState, rejectWithValue }) => { | ||
const {page} = getState().activities | ||
try { | ||
return await _searchDeployments([], false, productionOnly, start, end, page, perPage) | ||
} catch (e) { | ||
return rejectWithValue(e) | ||
} | ||
} | ||
) | ||
|
||
export const activitiesSlice = createSlice({ | ||
name: "activities", | ||
initialState, | ||
reducers: { | ||
increasePage: (state) => { | ||
state.page = state.page + 1 | ||
}, | ||
decreasePage: (state) => { | ||
state.page = state.page - 1 | ||
}, | ||
}, | ||
extraReducers: builder => { | ||
builder | ||
.addCase(searchDeployments.pending, (state) => { | ||
state.loading = true | ||
state.deployments = [] | ||
}) | ||
.addCase(searchDeployments.fulfilled, (state, action) => { | ||
state.loading = false | ||
state.deployments = action.payload | ||
}) | ||
.addCase(searchDeployments.rejected, (state) => { | ||
state.loading = false | ||
}) | ||
} | ||
}) |
This file contains hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
import { Timeline, Typography } from 'antd' | ||
import moment from "moment" | ||
|
||
import { Deployment } from "../../models" | ||
import DeploymentStatusBadge from "../../components/DeploymentStatusBadge" | ||
import UserAvatar from '../../components/UserAvatar' | ||
import DeploymentRefCode from '../../components/DeploymentRefCode' | ||
import { getStatusColor } from "../../components/partials" | ||
|
||
const { Text } = Typography | ||
|
||
export interface ActivityHistoryProps { | ||
deployments: Deployment[] | ||
} | ||
|
||
export default function ActivityHistory(props: ActivityHistoryProps): JSX.Element { | ||
return ( | ||
<Timeline> | ||
{props.deployments.map((d, idx) => { | ||
return ( | ||
<Timeline.Item key={idx} color={getStatusColor(d.status)}> | ||
<p> | ||
<Text strong> | ||
{`${d.repo?.namespace} / ${d.repo?.name}`} | ||
</Text> | ||
<a href={`/${d.repo?.namespace}/${d.repo?.name}/deployments/${d.number}`}> | ||
#{d.number} | ||
</a> | ||
</p> | ||
<p> | ||
<UserAvatar user={d.deployer} /> deployed <DeploymentRefCode deployment={d}/> to <Text strong>{d.env}</Text> on {moment(d.createdAt).format("LLL")} <DeploymentStatusBadge deployment={d}/> | ||
</p> | ||
</Timeline.Item> | ||
) | ||
})} | ||
</Timeline> | ||
) | ||
} |
This file contains hidden or 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,63 @@ | ||
import { Row, Col, Form, DatePicker, Button, Switch } from "antd" | ||
import moment, { Moment } from "moment" | ||
|
||
export interface SearchActivitiesValues { | ||
period?: [Moment, Moment] | ||
productionOnly?: boolean | ||
} | ||
|
||
export interface SearchActivitiesProps { | ||
initialValues?: SearchActivitiesValues | ||
onClickSearch(values: SearchActivitiesValues): void | ||
Comment on lines
+10
to
+11
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. It defines only the initial value and action for clicking the search button as a property of the component. |
||
} | ||
|
||
export default function SearchActivities(props: SearchActivitiesProps): JSX.Element { | ||
const content = ( | ||
<> | ||
<Form.Item label="Period" name="period"> | ||
<DatePicker.RangePicker | ||
format="YYYY-MM-DD HH:mm" | ||
showTime={{ | ||
showSecond: false, | ||
defaultValue: [moment().hour(0).minute(0), moment().hour(23).minute(59)], | ||
}} | ||
/> | ||
</Form.Item> | ||
<Form.Item label="Production" name="productionOnly" valuePropName="checked"> | ||
<Switch size="small" /> | ||
</Form.Item> | ||
<Form.Item > | ||
<Button | ||
htmlType="submit" | ||
type="primary" | ||
> | ||
Search | ||
</Button> | ||
</Form.Item> | ||
</> | ||
) | ||
return ( | ||
<Row> | ||
{/* Mobile view */} | ||
<Col span={24} lg={0}> | ||
<Form | ||
layout="horizontal" | ||
initialValues={props.initialValues} | ||
onFinish={props.onClickSearch} | ||
> | ||
{content} | ||
</Form> | ||
</Col> | ||
{/* Laptop */} | ||
<Col span={0} lg={24}> | ||
<Form | ||
layout="inline" | ||
initialValues={props.initialValues} | ||
onFinish={props.onClickSearch} | ||
> | ||
{content} | ||
</Form> | ||
</Col> | ||
</Row> | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the bug