Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/alerts/acknowledgement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'space-between',
gap: space.m,
minHeight: 44,
// The Acknowledge button's height, so taking it on or undoing it doesn't move what's under it.
minHeight: 50,
paddingHorizontal: space.xxs,
},
text: {
Expand Down
26 changes: 14 additions & 12 deletions src/alerts/activity-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,17 @@ export function ActivityCard({ organizationId, monitors, onSetUp }: Props) {
))}
<Text style={[styles.date, { color: palette.foreground.tertiary }]}>Today</Text>
</View>
{firedLevels.length > 0 && (
<View style={styles.legend}>
{firedLevels.map((level) => (
<View key={level} style={styles.key}>
<View style={[styles.swatch, { backgroundColor: palette.chart.severity[level] }]} />
<Text style={[styles.date, { color: palette.foreground.secondary }]}>
{severityLabels[level]} {levels[level]}
</Text>
</View>
))}
</View>
)}
{/* Always there, a line tall while the days load, so the card doesn't grow under what follows it. */}
<View style={styles.legend}>
{firedLevels.map((level) => (
<View key={level} style={styles.key}>
<View style={[styles.swatch, { backgroundColor: palette.chart.severity[level] }]} />
<Text style={[styles.date, { color: palette.foreground.secondary }]}>
{severityLabels[level]} {levels[level]}
</Text>
</View>
))}
</View>
</Card>
);
}
Expand Down Expand Up @@ -132,8 +131,11 @@ const styles = StyleSheet.create({
},
date: {
fontSize: 12,
lineHeight: 16,
fontVariant: ['tabular-nums'],
},
legend: {
minHeight: 16,
flexDirection: 'row',
flexWrap: 'wrap',
columnGap: space.l,
Expand Down
10 changes: 7 additions & 3 deletions src/alerts/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ export function AlertHistory({
staleTime: 5 * 60_000,
});

if (!alert.metric || history.isError || projects.isError || (projects.data !== undefined && project === undefined)) {
if (!alert.metric) {
return null;
}
const points = history.data ?? [];
// The card stays, at the chart's height, when the readings can't load: it said it was loading them, and taking it
// away would pull everything under it up.
const failed = history.isError || projects.isError || (projects.data !== undefined && project === undefined);
const points = failed ? [] : (history.data ?? []);

return (
<Card style={styles.card}>
Expand All @@ -54,7 +57,8 @@ export function AlertHistory({
points={points}
format={(value) => formatValue(alert, value)}
onSelect={setSelected}
loading={history.data === undefined}
loading={!failed && history.data === undefined}
empty={failed ? 'Couldn’t load the readings around this alert.' : undefined}
/>
</Card>
);
Expand Down
2 changes: 1 addition & 1 deletion src/alerts/threshold-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { usePalette } from '@/theme/use-palette';
const axisFont = require('@/assets/fonts/Inter-Regular.ttf');
const labelFont = require('@/assets/fonts/Inter-Medium.ttf');

const height = 170;
export const height = 170;
/** Room above the top gridline for its value, and below the plot for the dates. */
const top = 10;
const bottom = 24;
Expand Down
22 changes: 13 additions & 9 deletions src/app/(app)/(tabs)/(home)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { OrganizationPicker, ScreenToolbar } from '@/organizations/header';
import { projectsQuery } from '@/projects/api';
import { ProjectCard, ProjectLine, ProjectRow } from '@/projects/project-row';
import { SnoozeCard } from '@/settings/snooze-card';
import { prefsQuery } from '@/settings/use-prefs';
import { SetupCard } from '@/setup/setup-card';
import { statusLabel, statusQuery } from '@/status/api';
import { fonts, space } from '@/theme/tokens';
Expand All @@ -48,6 +49,7 @@ export default function Home() {
const status = useQuery(statusQuery);
const projects = useQuery(projectsQuery(organizationId));
const updates = useQuery(updatesQuery);
const prefs = useQuery(prefsQuery);
const { isUnread } = useUnread();

const session = useSession();
Expand Down Expand Up @@ -82,6 +84,9 @@ export default function Home() {
const failed = 'Couldn’t load alerts. Pull to retry.';
const note = alerts.isError ? failed : 'Loading alerts…';
const incident = status.data?.incidents[0];
// The snooze card shows from the alerts and prefs, above everything else, so what's under it waits for both rather
// than drawing and then being pushed down when the card turns up.
const decided = (alerts.data !== undefined || alerts.isError) && (prefs.data !== undefined || prefs.isError);

const firingIn = (projectId: string) => firing.filter((alert) => projectOf(alert) === projectId).length;
// Firing projects first, then the Projects tab's own order, so Home and the tab agree.
Expand Down Expand Up @@ -171,12 +176,11 @@ export default function Home() {
: `${firing.length} firing`}
</Text>
</View>
{/* Under the count rather than beside it, so it has the card's width; past that it wraps rather than hiding a level. */}
{(pending || detail !== '') && (
<Text style={[styles.healthDetail, { color: palette.foreground.secondary }]}>
{pending ? note : detail}
</Text>
)}
{/* Under the count rather than beside it, so it has the card's width; past that it wraps rather than hiding a level.
Kept a line tall when there's nothing to add, as "Loading alerts…" was, so the card keeps its height. */}
<Text style={[styles.healthDetail, { color: palette.foreground.secondary }]}>
{pending ? note : detail === '' ? ' ' : detail}
</Text>
</Card>

<Card
Expand All @@ -200,10 +204,10 @@ export default function Home() {
</Card>
</View>

<SnoozeCard alerts={alerts.data} />
<SetupCard />
{decided && <SnoozeCard alerts={alerts.data} />}
{decided && <SetupCard />}

{layout.wide ? (
{!decided ? null : layout.wide ? (
// Two columns that each flow on their own, so a long list on one side leaves no gap on the other.
<View style={styles.row}>
<View style={styles.main}>
Expand Down
Loading