Open a run or pipeline in a new chat
The run and pipeline More menus offer Open in chat: a new chat in the run's (or the pipeline's latest run's) workspace opens on the Chat tab with a draft naming the run or pipeline and how to inspect or change it.
This commit is contained in:
@@ -224,6 +224,7 @@ class PipelineRun {
|
||||
required this.createdAt,
|
||||
required this.finishedAt,
|
||||
required this.executing,
|
||||
this.workspace = '',
|
||||
});
|
||||
|
||||
factory PipelineRun.fromJson(PipelineJson json) => PipelineRun(
|
||||
@@ -233,6 +234,7 @@ class PipelineRun {
|
||||
createdAt: _string(json['created_at']),
|
||||
finishedAt: _string(json['finished_at']),
|
||||
executing: json['executing'] == true,
|
||||
workspace: '${json['workspace'] ?? ''}',
|
||||
);
|
||||
|
||||
final int id;
|
||||
@@ -241,6 +243,7 @@ class PipelineRun {
|
||||
final String createdAt;
|
||||
final String finishedAt;
|
||||
final bool executing;
|
||||
final String workspace;
|
||||
}
|
||||
|
||||
/// Timestamps decide recency; a higher run id breaks an exact tie or two bad
|
||||
|
||||
@@ -41,6 +41,8 @@ class PipelinesScreen extends StatefulWidget {
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
this.initialStageKey,
|
||||
this.onOpenInChat,
|
||||
this.onOpenPipelineInChat,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -87,6 +89,10 @@ class PipelinesScreen extends StatefulWidget {
|
||||
/// pane; a key the pinned version does not declare opens the Graph tab with
|
||||
/// nothing selected. Null keeps the ordinary default tab.
|
||||
final String? initialStageKey;
|
||||
final Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||
onOpenPipelineInChat;
|
||||
|
||||
@override
|
||||
State<PipelinesScreen> createState() => _PipelinesScreenState();
|
||||
@@ -235,6 +241,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
showBack: false,
|
||||
onRunStarted: widget.onRunStarted,
|
||||
onViewPipelineRuns: widget.onViewPipelineRuns,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
stageKey: stageKey,
|
||||
stagePipelineId: widget.initialPipelineId,
|
||||
stageVersion: widget.initialVersion,
|
||||
@@ -252,12 +259,18 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
);
|
||||
if (!wide) {
|
||||
return ContentWidth(
|
||||
child: PipelineListPanel(controller: _controller),
|
||||
child: PipelineListPanel(
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListDetailPanes(
|
||||
list: ContentWidth(
|
||||
child: PipelineListPanel(controller: _controller),
|
||||
child: PipelineListPanel(
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
),
|
||||
),
|
||||
detailIdentity: _controller.selectedId,
|
||||
detail: _controller.hasSelection
|
||||
|
||||
@@ -18,17 +18,29 @@ String archiveConfirmation(String name) =>
|
||||
Widget pipelineActionsMenu(
|
||||
BuildContext context,
|
||||
PipelinesController controller,
|
||||
PipelineDetail detail,
|
||||
) {
|
||||
PipelineDetail detail, {
|
||||
Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat,
|
||||
}) {
|
||||
final archived = detail.archived;
|
||||
final label = archived ? 'Unarchive' : 'Archive…';
|
||||
void run(BuildContext context) =>
|
||||
archiveOrUnarchive(context, controller, detail);
|
||||
return SegmentedOverflowAction(
|
||||
overflowEntry: SegmentedOverflowEntry(
|
||||
label: archived ? 'Unarchive pipeline' : 'Archive pipeline…',
|
||||
label: 'Pipeline actions',
|
||||
icon: Icons.archive_outlined,
|
||||
onPressed: () => run(context),
|
||||
choices: [
|
||||
SegmentedMenuChoice(
|
||||
label: archived ? 'Unarchive pipeline' : 'Archive pipeline…',
|
||||
onSelected: () => run(context),
|
||||
),
|
||||
if (onOpenInChat != null)
|
||||
SegmentedMenuChoice(
|
||||
label: 'Open in chat',
|
||||
onSelected: () => onOpenInChat(context, detail, null),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: AppOverflowMenu<bool>(
|
||||
key: const Key('pipeline-actions-menu'),
|
||||
@@ -40,8 +52,15 @@ Widget pipelineActionsMenu(
|
||||
value: true,
|
||||
label: label,
|
||||
),
|
||||
if (onOpenInChat != null)
|
||||
const AppMenuAction<bool>(
|
||||
value: false,
|
||||
label: 'Open in chat',
|
||||
icon: Icons.chat_bubble_outline,
|
||||
),
|
||||
],
|
||||
onSelected: (context, _) => run(context),
|
||||
onSelected: (context, value) =>
|
||||
value ? run(context) : onOpenInChat!(context, detail, null),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
this.stagePipelineId,
|
||||
this.stageVersion = 0,
|
||||
this.stageRequest = 0,
|
||||
this.onOpenInChat,
|
||||
}) : assert(
|
||||
stageKey == null || stagePipelineId != null,
|
||||
'a routed stage names the pipeline it belongs to',
|
||||
@@ -77,6 +78,8 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
/// definition pane even though the pinned detail may be re-read in place. A
|
||||
/// later version switch from this screen is not a new route request.
|
||||
final int stageRequest;
|
||||
final Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
|
||||
@override
|
||||
State<PipelineDetailPanel> createState() => _PipelineDetailPanelState();
|
||||
@@ -420,7 +423,18 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
onRunStarted: widget.onRunStarted,
|
||||
inBar: true,
|
||||
),
|
||||
pipelineActionsMenu(context, _controller, detail),
|
||||
pipelineActionsMenu(
|
||||
context,
|
||||
_controller,
|
||||
detail,
|
||||
onOpenInChat: widget.onOpenInChat == null
|
||||
? null
|
||||
: (context, detail, _) => widget.onOpenInChat!(
|
||||
context,
|
||||
detail,
|
||||
_controller.latestRuns[detail.id],
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _source(BuildContext context, PipelineDetail detail) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import '../pipelines_controller.dart';
|
||||
import 'pipeline_controls.dart';
|
||||
import 'pipeline_filter_page.dart';
|
||||
import 'pipeline_scope_control.dart';
|
||||
import '../../../ui/layout/app_overflow_menu.dart';
|
||||
|
||||
/// The list's horizontal rhythm, matching the web's toolbar and row inset
|
||||
/// (`var(--space-s)`: 12px). The detail pane keeps its own content padding.
|
||||
@@ -21,9 +22,15 @@ const double kPipelineListInset = 12;
|
||||
|
||||
/// The left/top pane: filter and sort controls, then the truthful list states.
|
||||
class PipelineListPanel extends StatelessWidget {
|
||||
const PipelineListPanel({super.key, required this.controller});
|
||||
const PipelineListPanel({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.onOpenInChat,
|
||||
});
|
||||
|
||||
final PipelinesController controller;
|
||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -264,6 +271,22 @@ class PipelineListPanel extends StatelessWidget {
|
||||
: Text(
|
||||
ServerContext.metadata(context, runStateLabel(badge.state)),
|
||||
),
|
||||
menu: onOpenInChat == null
|
||||
? null
|
||||
: AppOverflowMenu<bool>(
|
||||
key: Key('pipeline-row-more-menu-${pipeline.id}'),
|
||||
label: 'Pipeline actions',
|
||||
sheetTitle: pipeline.displayName,
|
||||
actions: const [
|
||||
AppMenuAction<bool>(
|
||||
value: true,
|
||||
label: 'Open in chat',
|
||||
icon: Icons.chat_bubble_outline,
|
||||
),
|
||||
],
|
||||
onSelected: (context, _) =>
|
||||
onOpenInChat!(context, pipeline, run),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user