|
@@ -9,15 +9,33 @@ import Loading from "components/Loading";
|
|
|
import _ from "lodash";
|
|
import _ from "lodash";
|
|
|
import DeploymentCard from "./DeploymentCard";
|
|
import DeploymentCard from "./DeploymentCard";
|
|
|
import { Environment, PRDeployment } from "../types";
|
|
import { Environment, PRDeployment } from "../types";
|
|
|
|
|
+import { useRouting } from "shared/routing";
|
|
|
|
|
+import { useHistory, useLocation } from "react-router";
|
|
|
|
|
+
|
|
|
|
|
+const AvailableStatusFilters = [
|
|
|
|
|
+ "all",
|
|
|
|
|
+ "creating",
|
|
|
|
|
+ "failed",
|
|
|
|
|
+ "active",
|
|
|
|
|
+ "inactive",
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+type AvailableStatusFiltersType = typeof AvailableStatusFilters[number];
|
|
|
|
|
|
|
|
const DeploymentList = ({ environments }: { environments: Environment[] }) => {
|
|
const DeploymentList = ({ environments }: { environments: Environment[] }) => {
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
const [hasError, setHasError] = useState(false);
|
|
const [hasError, setHasError] = useState(false);
|
|
|
const [deploymentList, setDeploymentList] = useState<PRDeployment[]>([]);
|
|
const [deploymentList, setDeploymentList] = useState<PRDeployment[]>([]);
|
|
|
- const [statusSelectorVal, setStatusSelectorVal] = useState<string>("all");
|
|
|
|
|
|
|
+ const [
|
|
|
|
|
+ statusSelectorVal,
|
|
|
|
|
+ setStatusSelectorVal,
|
|
|
|
|
+ ] = useState<AvailableStatusFiltersType>("all");
|
|
|
const [selectedRepo, setSelectedRepo] = useState("all");
|
|
const [selectedRepo, setSelectedRepo] = useState("all");
|
|
|
|
|
|
|
|
const { currentProject, currentCluster } = useContext(Context);
|
|
const { currentProject, currentCluster } = useContext(Context);
|
|
|
|
|
+ const { getQueryParam, pushQueryParams } = useRouting();
|
|
|
|
|
+ const location = useLocation();
|
|
|
|
|
+ const history = useHistory();
|
|
|
|
|
|
|
|
const getPRDeploymentList = () => {
|
|
const getPRDeploymentList = () => {
|
|
|
return api.getPRDeploymentList(
|
|
return api.getPRDeploymentList(
|
|
@@ -30,6 +48,40 @@ const DeploymentList = ({ environments }: { environments: Environment[] }) => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const selected_repo = getQueryParam("repository");
|
|
|
|
|
+
|
|
|
|
|
+ const repo = environments.find(
|
|
|
|
|
+ (env) => `${env.git_repo_owner}/${env.git_repo_name}` === selected_repo
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (!repo) {
|
|
|
|
|
+ pushQueryParams({}, ["repository"]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (selected_repo !== selectedRepo) {
|
|
|
|
|
+ setSelectedRepo(`${repo.git_repo_owner}/${repo.git_repo_name}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [location.search, history]);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const status_filter = getQueryParam("status_filter");
|
|
|
|
|
+
|
|
|
|
|
+ if (!AvailableStatusFilters.includes(status_filter)) {
|
|
|
|
|
+ pushQueryParams({}, ["status_filter"]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (status_filter !== statusSelectorVal) {
|
|
|
|
|
+ setStatusSelectorVal(status_filter);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [location.search, history]);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ pushQueryParams({}, ["status_filter", "repository"]);
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
let isSubscribed = true;
|
|
let isSubscribed = true;
|
|
|
getPRDeploymentList()
|
|
getPRDeploymentList()
|
|
@@ -117,17 +169,28 @@ const DeploymentList = ({ environments }: { environments: Environment[] }) => {
|
|
|
value: "all",
|
|
value: "all",
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const handleStatusFilterChange = (value: string) => {
|
|
|
|
|
+ pushQueryParams({ status_filter: value });
|
|
|
|
|
+ setStatusSelectorVal(value);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleRepoFilterChange = (value: string) => {
|
|
|
|
|
+ pushQueryParams({ repository: value });
|
|
|
|
|
+ setSelectedRepo(value);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<Container>
|
|
<Container>
|
|
|
<ControlRow>
|
|
<ControlRow>
|
|
|
<ActionsWrapper>
|
|
<ActionsWrapper>
|
|
|
- <RefreshButton color={"#7d7d81"} onClick={handleRefresh}>
|
|
|
|
|
- <i className="material-icons">refresh</i>
|
|
|
|
|
- </RefreshButton>
|
|
|
|
|
<StyledStatusSelector>
|
|
<StyledStatusSelector>
|
|
|
|
|
+ <Label>
|
|
|
|
|
+ <i className="material-icons">filter_alt</i>
|
|
|
|
|
+ Status
|
|
|
|
|
+ </Label>
|
|
|
<Selector
|
|
<Selector
|
|
|
activeValue={statusSelectorVal}
|
|
activeValue={statusSelectorVal}
|
|
|
- setActiveValue={setStatusSelectorVal}
|
|
|
|
|
|
|
+ setActiveValue={handleStatusFilterChange}
|
|
|
options={[
|
|
options={[
|
|
|
{
|
|
{
|
|
|
value: "all",
|
|
value: "all",
|
|
@@ -156,15 +219,25 @@ const DeploymentList = ({ environments }: { environments: Environment[] }) => {
|
|
|
closeOverlay={true}
|
|
closeOverlay={true}
|
|
|
/>
|
|
/>
|
|
|
</StyledStatusSelector>
|
|
</StyledStatusSelector>
|
|
|
- <Selector
|
|
|
|
|
- activeValue={selectedRepo}
|
|
|
|
|
- setActiveValue={(val) => setSelectedRepo(val)}
|
|
|
|
|
- options={repoOptions}
|
|
|
|
|
- dropdownLabel="Repository"
|
|
|
|
|
- width="200px"
|
|
|
|
|
- dropdownWidth="300px"
|
|
|
|
|
- closeOverlay
|
|
|
|
|
- ></Selector>
|
|
|
|
|
|
|
+ <StyledStatusSelector>
|
|
|
|
|
+ <Label>
|
|
|
|
|
+ <i className="material-icons">filter_alt</i>
|
|
|
|
|
+ Repository
|
|
|
|
|
+ </Label>
|
|
|
|
|
+ <Selector
|
|
|
|
|
+ activeValue={selectedRepo}
|
|
|
|
|
+ setActiveValue={handleRepoFilterChange}
|
|
|
|
|
+ options={repoOptions}
|
|
|
|
|
+ dropdownLabel="Repository"
|
|
|
|
|
+ width="200px"
|
|
|
|
|
+ dropdownWidth="300px"
|
|
|
|
|
+ closeOverlay
|
|
|
|
|
+ />
|
|
|
|
|
+ </StyledStatusSelector>
|
|
|
|
|
+
|
|
|
|
|
+ <RefreshButton color={"#7d7d81"} onClick={handleRefresh}>
|
|
|
|
|
+ <i className="material-icons">refresh</i>
|
|
|
|
|
+ </RefreshButton>
|
|
|
</ActionsWrapper>
|
|
</ActionsWrapper>
|
|
|
</ControlRow>
|
|
</ControlRow>
|
|
|
<EventsGrid>{renderDeploymentList()}</EventsGrid>
|
|
<EventsGrid>{renderDeploymentList()}</EventsGrid>
|
|
@@ -187,7 +260,7 @@ const RefreshButton = styled.button`
|
|
|
border: none;
|
|
border: none;
|
|
|
background: none;
|
|
background: none;
|
|
|
border-radius: 50%;
|
|
border-radius: 50%;
|
|
|
- margin-right: 10px;
|
|
|
|
|
|
|
+ margin-left: 10px;
|
|
|
> i {
|
|
> i {
|
|
|
font-size: 20px;
|
|
font-size: 20px;
|
|
|
}
|
|
}
|
|
@@ -197,27 +270,6 @@ const RefreshButton = styled.button`
|
|
|
}
|
|
}
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
-const SettingsButton = styled.div`
|
|
|
|
|
- font-size: 12px;
|
|
|
|
|
- padding: 8px 10px;
|
|
|
|
|
- margin-left: 10px;
|
|
|
|
|
- border-radius: 5px;
|
|
|
|
|
- color: white;
|
|
|
|
|
- display: flex;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- background: #ffffff08;
|
|
|
|
|
- cursor: pointer;
|
|
|
|
|
- :hover {
|
|
|
|
|
- background: #ffffff22;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- > i {
|
|
|
|
|
- color: white;
|
|
|
|
|
- font-size: 18px;
|
|
|
|
|
- margin-right: 8px;
|
|
|
|
|
- }
|
|
|
|
|
-`;
|
|
|
|
|
-
|
|
|
|
|
const Placeholder = styled.div`
|
|
const Placeholder = styled.div`
|
|
|
padding: 30px;
|
|
padding: 30px;
|
|
|
margin-top: 35px;
|
|
margin-top: 35px;
|
|
@@ -264,6 +316,9 @@ const StyledStatusSelector = styled.div`
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
font-size: 13px;
|
|
font-size: 13px;
|
|
|
|
|
+ :not(:first-child) {
|
|
|
|
|
+ margin-left: 15px;
|
|
|
|
|
+ }
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
const Header = styled.div`
|
|
const Header = styled.div`
|
|
@@ -277,3 +332,14 @@ const Header = styled.div`
|
|
|
const Subheader = styled.div`
|
|
const Subheader = styled.div`
|
|
|
width: 50%;
|
|
width: 50%;
|
|
|
`;
|
|
`;
|
|
|
|
|
+
|
|
|
|
|
+const Label = styled.div`
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-right: 12px;
|
|
|
|
|
+
|
|
|
|
|
+ > i {
|
|
|
|
|
+ margin-right: 8px;
|
|
|
|
|
+ font-size: 18px;
|
|
|
|
|
+ }
|
|
|
|
|
+`;
|