Skip to content

Commit

Permalink
feat: dev fail pipeline, overall pipeline fail UI state
Browse files Browse the repository at this point in the history
  • Loading branch information
kasp1 committed Oct 11, 2022
1 parent a3aaaa9 commit 3ccfdd0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
5 changes: 5 additions & 0 deletions examples/dev/dev-fail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- title: 10 Second Step
command: node examples/dev/delayed.js 10
- title: Failing Step
command: exit /b 1
2 changes: 1 addition & 1 deletion nativeui/lib/enums.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
enum StepStatus { initial, progress, success, failure }

enum ExecutionStatus { done, connecting, disconnected, progress }
enum ExecutionStatus { success, connecting, disconnected, progress, failure }
4 changes: 4 additions & 0 deletions nativeui/lib/model/pipeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class Pipeline with ChangeNotifier {
}
}

if (filteredLines.isEmpty) {
filteredLines.add('Nothing seems to match the filter.');
}

return filteredLines.join('\n');
}
}
55 changes: 40 additions & 15 deletions nativeui/lib/views/pipeline_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {
pipeline.title = recapStep['title'];
}

if (status == StepStatus.failure) {
pipeline.executionStatus = ExecutionStatus.failure;
}

if (recapStep.containsKey('totalTime')) {
step.time = recapStep['totalTime'];
}
Expand Down Expand Up @@ -96,26 +100,31 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {

if (json.containsKey('step') && json.containsKey('status')) {
var index = json['step'];
StepStatus status = pipeline.strToStepStatus(json['status']);

if (status == StepStatus.failure) {
pipeline.executionStatus = ExecutionStatus.failure;
}

if (json.containsKey('totalTime')) {
pipeline.updateStatus(
stepIndex: index,
status: pipeline.strToStepStatus(json['status']),
time: json['totalTime']);
stepIndex: index, status: status, time: json['totalTime']);
} else {
pipeline.updateStatus(
stepIndex: index,
status: pipeline.strToStepStatus(json['status']));
pipeline.updateStatus(stepIndex: index, status: status);
}
}
},
onError: (error) => print(error),
onDone: () async {
await Future.delayed(const Duration(seconds: 1));

pipeline.executionStatus = pipeline.finished
? ExecutionStatus.done
: ExecutionStatus.disconnected;
if (pipeline.finished) {
if (pipeline.executionStatus != ExecutionStatus.failure) {
pipeline.executionStatus = ExecutionStatus.success;
}
} else {
pipeline.executionStatus = ExecutionStatus.disconnected;
}
});
}

Expand Down Expand Up @@ -159,15 +168,24 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {
actions: Row(mainAxisAlignment: MainAxisAlignment.end, children: [
executionStatusNotification(pipeline.executionStatus),
IconButton(
icon: Icon(FluentIcons.add_space_before,
color: pipeline.followExecution
? Colors.blue
: theme.iconTheme.color),
icon: pipeline.followExecution
? Icon(FluentIcons.pinned_solid, color: Colors.blue)
: Icon(FluentIcons.pinned, color: theme.iconTheme.color),
onPressed: () => pipeline.toggleFollowExecution()),
IconButton(
icon: const Icon(FluentIcons.copy),
onPressed: () => FlutterClipboard.copy(pipeline
.filteredOuptut(pipeline[pipeline.selectedStep].output))),
if (pipeline.length > 0)
if (pipeline[pipeline.selectedStep].startVars.isNotEmpty)
IconButton(
icon: const Icon(FluentIcons.align_horizontal_left),
onPressed: () {}),
if (pipeline.length > 0)
if (pipeline[pipeline.selectedStep].endVars.isNotEmpty)
IconButton(
icon: const Icon(FluentIcons.align_horizontal_right),
onPressed: () {}),
Padding(
padding: const EdgeInsetsDirectional.only(end: 10),
child: IconButton(
Expand Down Expand Up @@ -247,7 +265,9 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {
scrollController: pipeline.scrollC,
children: [
SelectableText(
pipeline.filteredOuptut(pipeline[index].output),
pipeline[index].output.isEmpty
? 'No output (yet).'
: pipeline.filteredOuptut(pipeline[index].output),
style: const TextStyle(fontSize: 12))
],
))),
Expand Down Expand Up @@ -318,7 +338,7 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {

Widget executionStatusNotification(ExecutionStatus status) {
switch (status) {
case ExecutionStatus.done:
case ExecutionStatus.success:
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Icon(FluentIcons.skype_check, color: Colors.teal));
Expand All @@ -331,6 +351,11 @@ class _PipelinePageState extends State<PipelinePage> with WindowListener {
style: TextStyle(color: Colors.warningPrimaryColor)));
case ExecutionStatus.connecting:
return const SizedBox(width: 100, child: Text('Connecting...'));
case ExecutionStatus.failure:
return const Padding(
padding: EdgeInsets.only(left: 10, right: 10),
child: Icon(FluentIcons.error_badge12,
color: Colors.warningPrimaryColor));
}
}
}
Expand Down

0 comments on commit 3ccfdd0

Please sign in to comment.