workflow: Add button to open the step view (#16387)

This PR adds an icon button that appears as you hover over the step header, which allows users to visit the step view.

---

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2024-08-17 13:06:34 -03:00 committed by GitHub
parent 07d5e22cbe
commit e4a591dcbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 19 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-search-code"><path d="m13 13.5 2-2.5-2-2.5"/><path d="m21 21-4.3-4.3"/><path d="M9 8.5 7 11l2 2.5"/><circle cx="11" cy="11" r="8"/></svg>

After

Width:  |  Height:  |  Size: 340 B

View file

@ -36,10 +36,10 @@ use fs::Fs;
use gpui::{ use gpui::{
canvas, div, img, percentage, point, pulsating_between, size, Action, Animation, AnimationExt, canvas, div, img, percentage, point, pulsating_between, size, Action, Animation, AnimationExt,
AnyElement, AnyView, AppContext, AsyncWindowContext, ClipboardEntry, ClipboardItem, AnyElement, AnyView, AppContext, AsyncWindowContext, ClipboardEntry, ClipboardItem,
Context as _, CursorStyle, DismissEvent, Empty, Entity, EntityId, EventEmitter, FocusHandle, Context as _, DismissEvent, Empty, Entity, EntityId, EventEmitter, FocusHandle, FocusableView,
FocusableView, FontWeight, InteractiveElement, IntoElement, Model, ParentElement, Pixels, FontWeight, InteractiveElement, IntoElement, Model, ParentElement, Pixels, ReadGlobal, Render,
ReadGlobal, Render, RenderImage, SharedString, Size, StatefulInteractiveElement, Styled, RenderImage, SharedString, Size, StatefulInteractiveElement, Styled, Subscription, Task,
Subscription, Task, Transformation, UpdateGlobal, View, VisualContext, WeakView, WindowContext, Transformation, UpdateGlobal, View, VisualContext, WeakView, WindowContext,
}; };
use indexed_docs::IndexedDocsStore; use indexed_docs::IndexedDocsStore;
use language::{ use language::{
@ -69,8 +69,8 @@ use ui::TintColor;
use ui::{ use ui::{
prelude::*, prelude::*,
utils::{format_distance_from_now, DateTimeType}, utils::{format_distance_from_now, DateTimeType},
Avatar, AvatarShape, ButtonLike, ContextMenu, Disclosure, ElevationIndex, KeyBinding, ListItem, Avatar, AvatarShape, ButtonLike, ContextMenu, Disclosure, ElevationIndex, IconButtonShape,
ListItemSpacing, PopoverMenu, PopoverMenuHandle, Tooltip, KeyBinding, ListItem, ListItemSpacing, PopoverMenu, PopoverMenuHandle, Tooltip,
}; };
use util::ResultExt; use util::ResultExt;
use workspace::{ use workspace::{
@ -2539,19 +2539,35 @@ impl ContextEditor {
div().child(step_label) div().child(step_label)
}; };
let step_label = step_label let step_label_element = step_label.into_any_element();
let step_label = h_flex()
.id("step") .id("step")
.cursor(CursorStyle::PointingHand) .group("step-label")
.on_click({ .items_center()
let this = weak_self.clone(); .gap_1()
let step_range = step_range.clone(); .child(step_label_element)
move |_, cx| { .child(
this.update(cx, |this, cx| { IconButton::new("edit-step", IconName::SearchCode)
this.open_workflow_step(step_range.clone(), cx); .size(ButtonSize::Compact)
}) .icon_size(IconSize::Small)
.ok(); .shape(IconButtonShape::Square)
} .visible_on_hover("step-label")
}); .tooltip(|cx| Tooltip::text("Open Step View", cx))
.on_click({
let this = weak_self.clone();
let step_range = step_range.clone();
move |_, cx| {
this.update(cx, |this, cx| {
this.open_workflow_step(
step_range.clone(),
cx,
);
})
.ok();
}
}),
);
div() div()
.w_full() .w_full()

View file

@ -273,7 +273,7 @@ impl Item for WorkflowStepView {
} }
fn tab_icon(&self, _cx: &WindowContext) -> Option<ui::Icon> { fn tab_icon(&self, _cx: &WindowContext) -> Option<ui::Icon> {
Some(Icon::new(IconName::Pencil)) Some(Icon::new(IconName::SearchCode))
} }
fn to_item_events(event: &Self::Event, mut f: impl FnMut(item::ItemEvent)) { fn to_item_events(event: &Self::Event, mut f: impl FnMut(item::ItemEvent)) {

View file

@ -230,6 +230,7 @@ pub enum IconName {
Save, Save,
Screen, Screen,
SearchSelection, SearchSelection,
SearchCode,
SelectAll, SelectAll,
Server, Server,
Settings, Settings,
@ -396,6 +397,7 @@ impl IconName {
IconName::Save => "icons/save.svg", IconName::Save => "icons/save.svg",
IconName::Screen => "icons/desktop.svg", IconName::Screen => "icons/desktop.svg",
IconName::SearchSelection => "icons/search_selection.svg", IconName::SearchSelection => "icons/search_selection.svg",
IconName::SearchCode => "icons/search_code.svg",
IconName::SelectAll => "icons/select_all.svg", IconName::SelectAll => "icons/select_all.svg",
IconName::Server => "icons/server.svg", IconName::Server => "icons/server.svg",
IconName::Settings => "icons/file_icons/settings.svg", IconName::Settings => "icons/file_icons/settings.svg",