Skip to content

Commit

Permalink
Add hover background transitions to tables - Part1
Browse files Browse the repository at this point in the history
  • Loading branch information
hasyed-akamai committed Dec 27, 2024
1 parent 8af4227 commit 8f87cb6
Show file tree
Hide file tree
Showing 84 changed files with 290 additions and 68 deletions.
2 changes: 1 addition & 1 deletion packages/manager/src/features/Account/AccountLogins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const AccountLogins = () => {
}
if (data) {
return data.data.map((item: AccountLogin) => (
<AccountLoginsTableRow key={item.id} {...item} />
<AccountLoginsTableRow hover key={item.id} {...item} />
));
}

Expand Down
11 changes: 8 additions & 3 deletions packages/manager/src/features/Account/AccountLoginsTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ import type {
AccountLogin,
AccountLoginStatus,
} from '@linode/api-v4/lib/account/types';
import type { TableRowOwnProps } from '@mui/material';
import type { Status } from 'src/components/StatusIcon/StatusIcon';

interface AccountLoginProps extends AccountLogin {
hover?: TableRowOwnProps['hover'];
}

const accessIconMap: Record<AccountLoginStatus, Status> = {
failed: 'other',
successful: 'active',
};

const AccountLoginsTableRow = (props: AccountLogin) => {
const { datetime, id, ip, restricted, status, username } = props;
const AccountLoginsTableRow = (props: AccountLoginProps) => {
const { datetime, hover, id, ip, restricted, status, username } = props;
const { data: profile } = useProfile();

return (
<TableRow key={id}>
<TableRow hover={hover} key={id}>
<TableCell>
{formatDate(datetime, {
timezone: profile?.timezone,
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/features/Backups/BackupDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const BackupDrawer = (props: Props) => {
result.linode.id === linode.id && result.status === 'rejected'
) as EnableBackupsRejectedResult | undefined)?.reason?.[0]?.reason
}
hover
key={linode.id}
linode={linode}
/>
Expand Down
6 changes: 4 additions & 2 deletions packages/manager/src/features/Backups/BackupLinodeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import {
} from 'src/utilities/pricing/constants';

import type { Linode, PriceObject } from '@linode/api-v4';
import type { TableRowOwnProps } from '@mui/material';

interface Props {
error?: string;
hover?: TableRowOwnProps['hover'];
linode: Linode;
}

export const BackupLinodeRow = (props: Props) => {
const { error, linode } = props;
const { error, hover, linode } = props;
const { data: type } = useTypeQuery(linode.type ?? '', Boolean(linode.type));
const { data: regions } = useRegionsQuery();

Expand All @@ -37,7 +39,7 @@ export const BackupLinodeRow = (props: Props) => {
backupsMonthlyPrice === null || backupsMonthlyPrice === undefined;

return (
<TableRow key={`backup-linode-${linode.id}`}>
<TableRow hover={hover} key={`backup-linode-${linode.id}`}>
<TableCell>
<Typography variant="body1">{linode.label}</Typography>
{error && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { getAll } from 'src/utilities/getAll';
import { getTaxID } from '../../billingUtils';

import type { Invoice, InvoiceItem, Payment } from '@linode/api-v4/lib/account';
import type { TableRowOwnProps } from '@mui/material';
import type { SxProps, Theme } from '@mui/material/styles';

const useStyles = makeStyles()((theme: Theme) => ({
Expand Down Expand Up @@ -372,6 +373,7 @@ export const BillingActivityPanel = React.memo((props: Props) => {
: {}
}
hasError={pdfErrors.has(`${thisItem.type}-${thisItem.id}`)}
hover
isLoading={pdfLoading.has(`${thisItem.type}-${thisItem.id}`)}
key={`${thisItem.type}-${thisItem.id}`}
{...thisItem}
Expand Down Expand Up @@ -497,6 +499,7 @@ const StyledBillingAndPaymentHistoryHeader = styled('div', {
interface ActivityFeedItemProps extends ActivityFeedItem {
downloadPDF: (id: number) => void;
hasError: boolean;
hover?: TableRowOwnProps['hover'];
isLoading: boolean;
sxRow: SxProps<Theme>;
}
Expand All @@ -508,6 +511,7 @@ export const ActivityFeedItem = React.memo((props: ActivityFeedItemProps) => {
date,
downloadPDF,
hasError,
hover,
id,
isLoading,
label,
Expand All @@ -532,7 +536,7 @@ export const ActivityFeedItem = React.memo((props: ActivityFeedItemProps) => {
};

return (
<TableRow data-testid={`${type}-${id}`} sx={sxRow}>
<TableRow data-testid={`${type}-${id}`} hover={hover} sx={sxRow}>
<TableCell>
{type === 'invoice' ? (
<Link to={`/account/billing/invoices/${id}`}>{label}</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const InvoiceDetail = () => {
)}
<InvoiceTable
errors={errors}
hover
items={items}
loading={loading}
shouldShowRegion={shouldShowRegion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import { getInvoiceRegion } from '../PdfGenerator/utils';

import type { InvoiceItem } from '@linode/api-v4/lib/account';
import type { APIError } from '@linode/api-v4/lib/types';
import type { TableRowOwnProps } from '@mui/material';

interface Props {
errors?: APIError[];
hover?: TableRowOwnProps['hover'];
items?: InvoiceItem[];
loading: boolean;
shouldShowRegion: boolean;
Expand All @@ -36,7 +38,7 @@ export const InvoiceTable = (props: Props) => {
isLoading: regionsLoading,
} = useRegionsQuery();

const { errors, items, loading, shouldShowRegion } = props;
const { errors, hover, items, loading, shouldShowRegion } = props;
const NUM_COLUMNS = shouldShowRegion ? 9 : 8;

const renderTableContent = () => {
Expand Down Expand Up @@ -76,6 +78,7 @@ export const InvoiceTable = (props: Props) => {
<React.Fragment>
{paginatedData.map((invoiceItem: InvoiceItem) => (
<TableRow
hover={hover}
key={`${invoiceItem.label}-${invoiceItem.from}-${invoiceItem.to}`}
>
<TableCell data-qa-description>{invoiceItem.label}</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const AlertListing = () => {
handleDetails: () => handleDetails(alert),
}}
alert={alert}
hover
key={alert.id}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AlertActionMenu } from './AlertActionMenu';

import type { ActionHandlers } from './AlertActionMenu';
import type { Alert } from '@linode/api-v4';
import type { TableRowOwnProps } from '@mui/material';

interface Props {
/**
Expand All @@ -21,14 +22,15 @@ interface Props {
* The callback handlers for clicking an action menu item like Show Details, Delete, etc.
*/
handlers: ActionHandlers;
hover?: TableRowOwnProps['hover'];
}

export const AlertTableRow = (props: Props) => {
const { alert, handlers } = props;
const { alert, handlers, hover } = props;
const { created_by, id, label, service_type, status, type, updated } = alert;
const theme = useTheme();
return (
<TableRow data-qa-alert-cell={id} key={`alert-row-${id}`}>
<TableRow data-qa-alert-cell={id} hover={hover} key={`alert-row-${id}`}>
<TableCell>{label}</TableCell>
<TableCell>{service_type}</TableCell>
<TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const DatabaseBackupTableBody = (props: Props) => {
<BackupTableRow
backup={backup}
disabled={disabled}
hover
key={backup.id}
onRestore={onRestore}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ import { parseAPIDate } from 'src/utilities/date';

import DatabaseBackupActionMenu from './DatabaseBackupActionMenu';

import type { TableRowOwnProps } from '@mui/material';

interface Props {
backup: DatabaseBackup;
disabled?: boolean;
hover?: TableRowOwnProps['hover'];
onRestore: (id: number) => void;
}

export const BackupTableRow = ({ backup, disabled, onRestore }: Props) => {
export const BackupTableRow = ({
backup,
disabled,
hover,
onRestore,
}: Props) => {
const { created, id } = backup;

return (
<TableRow key={id}>
<TableRow hover={hover} key={id}>
<TableCell>
<DateTimeDisplay value={created} />
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const DatabaseLandingTable = ({
}}
database={database}
events={events}
hover
isNewDatabase={isNewDatabase}
key={database.id}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';
import type { TableRowOwnProps } from '@mui/material';
import type { ActionHandlers } from 'src/features/Databases/DatabaseLanding/DatabaseActionMenu';

interface Props {
Expand All @@ -31,13 +32,15 @@ interface Props {
* @since DBaaS V2 GA
*/
handlers?: ActionHandlers;
hover?: TableRowOwnProps['hover'];
isNewDatabase?: boolean;
}

export const DatabaseRow = ({
database,
events,
handlers,
hover,
isNewDatabase,
}: Props) => {
const {
Expand Down Expand Up @@ -81,7 +84,11 @@ export const DatabaseRow = ({
</>
);
return (
<TableRow data-qa-database-cluster-id={id} key={`database-row-${id}`}>
<TableRow
data-qa-database-cluster-id={id}
hover={hover}
key={`database-row-${id}`}
>
<TableCell>
{isDatabasesV2GA && isLinkInactive ? (
label
Expand Down
6 changes: 4 additions & 2 deletions packages/manager/src/features/Domains/DomainTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ import { getDomainDisplayType } from './domainUtils';

import type { Handlers } from './DomainActionMenu';
import type { Domain, DomainStatus } from '@linode/api-v4/lib/domains';
import type { TableRowOwnProps } from '@mui/material';

interface DomainTableRowProps extends Handlers {
domain: Domain;
hover?: TableRowOwnProps['hover'];
}

export const DomainTableRow = React.memo((props: DomainTableRowProps) => {
const { domain, onClone, onDisableOrEnable, onEdit, onRemove } = props;
const { domain, hover, onClone, onDisableOrEnable, onEdit, onRemove } = props;

return (
<TableRow data-qa-domain-cell={domain.domain} key={domain.id}>
<TableRow data-qa-domain-cell={domain.domain} hover={hover} key={domain.id}>
<TableCell data-qa-domain-label>
<StyledDiv>
{domain.type !== 'slave' ? (
Expand Down
7 changes: 6 additions & 1 deletion packages/manager/src/features/Domains/DomainsLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@ export const DomainsLanding = (props: DomainsLandingProps) => {
</TableHead>
<TableBody>
{domains?.data.map((domain: Domain) => (
<DomainTableRow domain={domain} key={domain.id} {...handlers} />
<DomainTableRow
domain={domain}
hover
key={domain.id}
{...handlers}
/>
))}
</TableBody>
</Table>
Expand Down
6 changes: 4 additions & 2 deletions packages/manager/src/features/Events/EventRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ import {
} from './utils';

import type { Event } from '@linode/api-v4/lib/account';
import type { TableRowOwnProps } from '@mui/material';

interface EventRowProps {
entityId?: number;
event: Event;
hover?: TableRowOwnProps['hover'];
}

export const EventRow = (props: EventRowProps) => {
const { event } = props;
const { event, hover } = props;
const theme = useTheme();
const timestamp = getEventTimestamp(event);
const { action, message, username } = {
Expand All @@ -42,7 +44,7 @@ export const EventRow = (props: EventRowProps) => {
const { progressEventDisplay, showProgress } = formatProgressEvent(event);

return (
<TableRow data-qa-event-row data-test-id={action}>
<TableRow data-qa-event-row data-test-id={action} hover={hover}>
<TableCell data-qa-event-message-cell>
<Box sx={{ mt: showProgress ? 0.5 : 0 }}>{message}</Box>
{showProgress && (
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/features/Events/EventsLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const EventsLanding = (props: Props) => {
<EventRow
entityId={entityId}
event={event}
hover
key={`event-${event.id}`}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const EventMessages: StoryObj = {
</Typography>
<Table>
<TableHead>
<TableRow>
<TableRow hover>
<TableCell style={{ width: '15%' }}>Status</TableCell>
<TableCell>Message</TableCell>
</TableRow>
Expand All @@ -55,7 +55,7 @@ export const EventMessages: StoryObj = {
const message = statuses[status]?.(event);

return (
<TableRow key={`status-${key}`}>
<TableRow hover key={`status-${key}`}>
<TableCell>
<Chip label={status} />
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const FirewallLanding = () => {
</TableHead>
<TableBody>
{data?.data.map((firewall) => (
<FirewallRow key={firewall.id} {...firewall} {...handlers} />
<FirewallRow hover key={firewall.id} {...firewall} {...handlers} />
))}
</TableBody>
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ import type { Firewall, FirewallDeviceEntity } from '@linode/api-v4';
export interface FirewallRowProps extends Firewall, ActionHandlers {}

export const FirewallRow = React.memo((props: FirewallRowProps) => {
const { entities, id, label, rules, status, ...actionHandlers } = props;
const {
entities,
hover,
id,
label,
rules,
status,
...actionHandlers
} = props;

const count = getCountOfRules(rules);

return (
<TableRow data-testid={`firewall-row-${id}`}>
<TableRow data-testid={`firewall-row-${id}`} hover={hover}>
<TableCell>
<Link tabIndex={0} to={`/firewalls/${id}`}>
{label}
Expand Down
Loading

0 comments on commit 8f87cb6

Please sign in to comment.