Skip to content

Commit

Permalink
Global Refresh for Tenant Details (#822)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Jun 18, 2021
1 parent d372a2c commit 61cf109
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ import { IPodListElement } from "../ListTenants/types";
import { setErrorSnackMessage } from "../../../../actions";
import api from "../../../../common/api";
import TableWrapper from "../../Common/TableWrapper/TableWrapper";
import { AppState } from "../../../../store";
import {
setTenantDetailsLoad,
setTenantInfo,
setTenantName,
setTenantTab,
} from "../actions";

interface IPodsSummary {
match: any;
history: any;
loadingTenant: boolean;
setTenantDetailsLoad: typeof setTenantDetailsLoad;
}

const styles = (theme: Theme) =>
Expand All @@ -38,7 +47,7 @@ const styles = (theme: Theme) =>
...containerForHeader(theme.spacing(4)),
});

const PodsSummary = ({ match, history }: IPodsSummary) => {
const PodsSummary = ({ match, history, loadingTenant }: IPodsSummary) => {
const [pods, setPods] = useState<IPodListElement[]>([]);
const [loadingPods, setLoadingPods] = useState<boolean>(true);

Expand All @@ -53,6 +62,12 @@ const PodsSummary = ({ match, history }: IPodsSummary) => {
};
const podTableActions = [{ type: "view", onClick: podViewAction }];

useEffect(() => {
if (loadingTenant) {
setLoadingPods(true);
}
}, [loadingTenant]);

useEffect(() => {
if (loadingPods) {
api
Expand Down Expand Up @@ -104,7 +119,11 @@ const PodsSummary = ({ match, history }: IPodsSummary) => {
);
};

const connector = connect(null, {
const mapState = (state: AppState) => ({
loadingTenant: state.tenants.tenantDetails.loadingTenant,
});

const connector = connect(mapState, {
setErrorSnackMessage,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import PodsSummary from "./PodsSummary";
import { AppState } from "../../../../store";
import TenantMetrics from "./TenantMetrics";
import TenantSecurity from "./TenantSecurity";
import RefreshIcon from "@material-ui/icons/Refresh";

interface ITenantDetailsProps {
classes: any;
Expand Down Expand Up @@ -217,6 +218,18 @@ const TenantDetails = ({
</Menu>
</Fragment>
}
actions={
<IconButton
color="primary"
aria-label="Refresh List"
component="span"
onClick={() => {
setTenantDetailsLoad(true);
}}
>
<RefreshIcon />
</IconButton>
}
/>
<Grid item xs={12} className={classes.container} />
<Grid container>
Expand Down

0 comments on commit 61cf109

Please sign in to comment.