/*
Copyright (C) 2017 Cloudbase Solutions SRL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
import * as React from "react";
import { observer } from "mobx-react";
import styled from "styled-components";
import { Link } from "react-router-dom";
import StatusIcon from "@src/components/ui/StatusComponents/StatusIcon";
import StatusImage from "@src/components/ui/StatusComponents/StatusImage";
import Button from "@src/components/ui/Button";
import {
InfoColumn,
MainItemInfo,
ItemTransferBadge,
ItemTitle,
ItemDescription,
} from "@src/components/ui/Dropdowns/NotificationDropdown";
import type { NotificationItemData } from "@src/@types/NotificationItem";
import { ThemePalette, ThemeProps } from "@src/components/Theme";
import transferImage from "./images/transfer.svg";
const Wrapper = styled.div`
flex-grow: 1;
`;
const Title = styled.div`
font-size: 24px;
font-weight: ${ThemeProps.fontWeights.light};
margin-bottom: 12px;
`;
const Module = styled.div`
background: ${ThemePalette.grayscale[0]};
display: flex;
overflow: hidden;
border-radius: ${ThemeProps.borderRadius};
height: 273px;
`;
const LoadingWrapper = styled.div`
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
`;
const List = styled.div`
width: 100%;
display: flex;
flex-direction: column;
flex-wrap: wrap;
`;
const ListItem = styled(Link)`
padding: 8px 16px 8px 16px;
cursor: pointer;
text-decoration: none;
color: inherit;
display: block;
transition: all ${ThemeProps.animations.swift};
&:hover {
background: ${ThemePalette.grayscale[1]};
}
`;
const NoItems = styled.div`
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
`;
const TransferImage = styled.div`
${ThemeProps.exactSize("148px")}
background: url('${transferImage}') center no-repeat;
`;
const Message = styled.div`
text-align: center;
margin-bottom: 32px;
`;
type Props = {
notificationItems: NotificationItemData[];
style?: React.CSSProperties | null;
loading?: boolean;
large?: boolean;
onNewClick?: () => void;
};
@observer
class DashboardActivity extends React.Component {
renderList() {
return (
{this.props.notificationItems
.filter((_, i) => i < (this.props.large ? 10 : 5))
.map((item, i) => {
const actionHref =
item.type === "transfer"
? "transfers" : "deployments"
const executionsHref =
item.status === "RUNNING"
? item.type === "transfer"
? "/executions"
: item.type === "deployment"
? "/tasks"
: ""
: "";
return (
{item.type === "transfer" ? "TR" : "DE"}
{item.name}{item.description}
);
})}
);
}
renderNoItems() {
return (
There is no recent activity
in this project.
);
}
renderLoading() {
return (
);
}
render() {
return (
Recent Activity
{this.props.notificationItems.length === 0 && this.props.loading
? this.renderLoading()
: this.props.notificationItems.length
? this.renderList()
: this.renderNoItems()}
);
}
}
export default DashboardActivity;