Skip to content

Commit

Permalink
Add last event to execution name and fix padding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
val500 committed Jul 26, 2024
1 parent c412293 commit e43f264
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 62 deletions.
101 changes: 47 additions & 54 deletions frontend/lib/ui/artefact_page/test_event_log_expandable.dart
Original file line number Diff line number Diff line change
@@ -1,79 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

import '../../providers/test_events.dart';
import '../../models/test_event.dart';
import '../spacing.dart';

class TestEventLogExpandable extends ConsumerWidget {
const TestEventLogExpandable({
super.key,
required this.testExecutionId,
required this.initiallyExpanded,
required this.testEvents,
});

final int testExecutionId;
final bool initiallyExpanded;
final List<TestEvent> testEvents;

@override
Widget build(BuildContext context, WidgetRef ref) {
final testEvents = ref.watch(testEventsProvider(testExecutionId));

return testEvents.when(
loading: () => const Center(child: YaruCircularProgressIndicator()),
error: (error, stackTrace) => Center(child: Text('Error: $error')),
data: (testEvents) {
return ExpansionTile(
controlAffinity: ListTileControlAffinity.leading,
childrenPadding: const EdgeInsets.only(left: Spacing.level4),
shape: const Border(),
title: const Text('Event Log'),
initiallyExpanded: initiallyExpanded,
children: <Widget>[
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
columns: const <DataColumn>[
DataColumn(
label: Expanded(
child: Text(
'Event Name',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
return ExpansionTile(
controlAffinity: ListTileControlAffinity.leading,
childrenPadding: const EdgeInsets.only(left: Spacing.level4),
shape: const Border(),
title: const Text('Event Log'),
initiallyExpanded: initiallyExpanded,
children: <Widget>[
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
columns: const <DataColumn>[
DataColumn(
label: Expanded(
child: Text(
'Event Name',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Expanded(
child: Text(
'Timestamp',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
),
DataColumn(
label: Expanded(
child: Text(
'Timestamp',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Expanded(
child: Text(
'Detail',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
),
DataColumn(
label: Expanded(
child: Text(
'Detail',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
),
],
rows: testEvents.map(
(testEvent) => DataRow(
cells: <DataCell>[
DataCell(Text(testEvent.eventName)),
DataCell(Text(testEvent.timestamp)),
DataCell(Text(testEvent.detail)),
],
rows: testEvents.map(
(testEvent) => DataRow(
cells: <DataCell>[
DataCell(Text(testEvent.eventName)),
DataCell(Text(testEvent.timestamp)),
DataCell(Text(testEvent.detail)),
],
),
)
.toList(),
),
),
],
);
},
)
.toList(),
),
),
],
);
}
}
45 changes: 37 additions & 8 deletions frontend/lib/ui/artefact_page/test_execution_expandable.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

import '../../models/test_execution.dart';
import '../../models/test_result.dart';
import '../../providers/artefact_builds.dart';
import '../../providers/test_events.dart';
import '../../routing.dart';
import '../inline_url_text.dart';
import '../spacing.dart';
Expand All @@ -19,14 +21,41 @@ class TestExecutionExpandable extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final testEvents = ref.watch(testEventsProvider(testExecution.id));

Widget eventLogExpandable(bool initiallyExpanded) => testEvents.when(
loading: () => const Center(child: YaruCircularProgressIndicator()),
error: (error, stackTrace) => Center(child: Text('Error: $error')),
data: (testEvents) => TestEventLogExpandable(
testExecutionId: testExecution.id,
initiallyExpanded: initiallyExpanded,
testEvents: testEvents,
),
);

final executionTitle = _TestExecutionTileTitle(
testExecution: testExecution,
titleAdditions: testEvents.when(
loading: () => '',
error: (error, stackTrace) => '',
data: (testEvents) {
if (testEvents.isNotEmpty) {
return ' (${testEvents[testEvents.length - 1].eventName})';
} else {
return '';
}
},
),
);

if (!testExecution.status.isCompleted) {
return ExpansionTile(
controlAffinity: ListTileControlAffinity.leading,
childrenPadding: const EdgeInsets.only(left: Spacing.level4),
shape: const Border(),
title: _TestExecutionTileTitle(testExecution: testExecution),
title: executionTitle,
children: <Widget>[
TestEventLogExpandable(testExecutionId: testExecution.id, initiallyExpanded: true),
eventLogExpandable(true),
],
);
}
Expand All @@ -35,9 +64,9 @@ class TestExecutionExpandable extends ConsumerWidget {
controlAffinity: ListTileControlAffinity.leading,
childrenPadding: const EdgeInsets.only(left: Spacing.level4),
shape: const Border(),
title: _TestExecutionTileTitle(testExecution: testExecution),
title: executionTitle,
children: <Widget>[
TestEventLogExpandable(testExecutionId: testExecution.id, initiallyExpanded: false),
eventLogExpandable(false),
ExpansionTile(
controlAffinity: ListTileControlAffinity.leading,
childrenPadding: const EdgeInsets.only(left: Spacing.level4),
Expand All @@ -59,22 +88,22 @@ class TestExecutionExpandable extends ConsumerWidget {
}

class _TestExecutionTileTitle extends StatelessWidget {
const _TestExecutionTileTitle({required this.testExecution});
const _TestExecutionTileTitle({required this.testExecution, required this.titleAdditions});

final TestExecution testExecution;
final String titleAdditions;

@override
Widget build(BuildContext context) {
final ciLink = testExecution.ciLink;
final c3Link = testExecution.c3Link;

return Row(
children: [
if (!testExecution.status.isCompleted) const SizedBox(width: 36.0),
children: [
testExecution.status.icon,
const SizedBox(width: Spacing.level4),
Text(
testExecution.environment.name,
testExecution.environment.name + titleAdditions,
style: Theme.of(context).textTheme.titleLarge,
),
const Spacer(),
Expand Down

0 comments on commit e43f264

Please sign in to comment.