assistant: Show tooltips on workflow step buttons only when cursor is in step (#16108)
Release Notes: - N/A
This commit is contained in:
parent
fc64843dd5
commit
b6b081596a
1 changed files with 78 additions and 29 deletions
|
@ -1397,6 +1397,21 @@ impl WorkflowStepStatus {
|
||||||
cx: &mut BlockContext<'_, '_>,
|
cx: &mut BlockContext<'_, '_>,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let id = EntityId::from(cx.block_id);
|
let id = EntityId::from(cx.block_id);
|
||||||
|
fn display_keybind_in_tooltip(
|
||||||
|
step_range: &Range<language::Anchor>,
|
||||||
|
editor: &WeakView<ContextEditor>,
|
||||||
|
cx: &mut WindowContext<'_>,
|
||||||
|
) -> bool {
|
||||||
|
editor
|
||||||
|
.update(cx, |this, _| {
|
||||||
|
this.active_workflow_step
|
||||||
|
.as_ref()
|
||||||
|
.map(|step| &step.range == step_range)
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
match self {
|
match self {
|
||||||
WorkflowStepStatus::Resolving => Icon::new(IconName::ArrowCircle)
|
WorkflowStepStatus::Resolving => Icon::new(IconName::ArrowCircle)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
|
@ -1448,15 +1463,24 @@ impl WorkflowStepStatus {
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
.style(ButtonStyle::Tinted(TintColor::Accent))
|
.style(ButtonStyle::Tinted(TintColor::Accent))
|
||||||
.tooltip(move |cx| {
|
.tooltip({
|
||||||
cx.new_view(|cx| {
|
let step_range = step_range.clone();
|
||||||
Tooltip::new("Transform").key_binding(KeyBinding::for_action_in(
|
let editor = editor.clone();
|
||||||
&Assist,
|
move |cx| {
|
||||||
&focus_handle,
|
cx.new_view(|cx| {
|
||||||
cx,
|
let tooltip = Tooltip::new("Transform");
|
||||||
))
|
if display_keybind_in_tooltip(&step_range, &editor, cx) {
|
||||||
})
|
tooltip.key_binding(KeyBinding::for_action_in(
|
||||||
.into()
|
&Assist,
|
||||||
|
&focus_handle,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
tooltip
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on_click({
|
.on_click({
|
||||||
let editor = editor.clone();
|
let editor = editor.clone();
|
||||||
|
@ -1476,15 +1500,24 @@ impl WorkflowStepStatus {
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
.style(ButtonStyle::Tinted(TintColor::Negative))
|
.style(ButtonStyle::Tinted(TintColor::Negative))
|
||||||
.tooltip(move |cx| {
|
.tooltip({
|
||||||
cx.new_view(|cx| {
|
let step_range = step_range.clone();
|
||||||
Tooltip::new("Stop Transformation").key_binding(KeyBinding::for_action_in(
|
let editor = editor.clone();
|
||||||
&editor::actions::Cancel,
|
move |cx| {
|
||||||
&focus_handle,
|
cx.new_view(|cx| {
|
||||||
cx,
|
let tooltip = Tooltip::new("Stop Transformation");
|
||||||
))
|
if display_keybind_in_tooltip(&step_range, &editor, cx) {
|
||||||
})
|
tooltip.key_binding(KeyBinding::for_action_in(
|
||||||
.into()
|
&editor::actions::Cancel,
|
||||||
|
&focus_handle,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
tooltip
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on_click({
|
.on_click({
|
||||||
let editor = editor.clone();
|
let editor = editor.clone();
|
||||||
|
@ -1509,15 +1542,20 @@ impl WorkflowStepStatus {
|
||||||
.style(ButtonStyle::Tinted(TintColor::Negative))
|
.style(ButtonStyle::Tinted(TintColor::Negative))
|
||||||
.tooltip({
|
.tooltip({
|
||||||
let focus_handle = focus_handle.clone();
|
let focus_handle = focus_handle.clone();
|
||||||
|
let editor = editor.clone();
|
||||||
|
let step_range = step_range.clone();
|
||||||
move |cx| {
|
move |cx| {
|
||||||
cx.new_view(|cx| {
|
cx.new_view(|cx| {
|
||||||
Tooltip::new("Reject Transformation").key_binding(
|
let tooltip = Tooltip::new("Reject Transformation");
|
||||||
KeyBinding::for_action_in(
|
if display_keybind_in_tooltip(&step_range, &editor, cx) {
|
||||||
|
tooltip.key_binding(KeyBinding::for_action_in(
|
||||||
&editor::actions::Cancel,
|
&editor::actions::Cancel,
|
||||||
&focus_handle,
|
&focus_handle,
|
||||||
cx,
|
cx,
|
||||||
),
|
))
|
||||||
)
|
} else {
|
||||||
|
tooltip
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -1541,13 +1579,24 @@ impl WorkflowStepStatus {
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
.style(ButtonStyle::Tinted(TintColor::Positive))
|
.style(ButtonStyle::Tinted(TintColor::Positive))
|
||||||
.tooltip(move |cx| {
|
.tooltip({
|
||||||
cx.new_view(|cx| {
|
let editor = editor.clone();
|
||||||
Tooltip::new("Accept Transformation").key_binding(
|
let step_range = step_range.clone();
|
||||||
KeyBinding::for_action_in(&Assist, &focus_handle, cx),
|
move |cx| {
|
||||||
)
|
cx.new_view(|cx| {
|
||||||
})
|
let tooltip = Tooltip::new("Accept Transformation");
|
||||||
.into()
|
if display_keybind_in_tooltip(&step_range, &editor, cx) {
|
||||||
|
tooltip.key_binding(KeyBinding::for_action_in(
|
||||||
|
&Assist,
|
||||||
|
&focus_handle,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
tooltip
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on_click({
|
.on_click({
|
||||||
let editor = editor.clone();
|
let editor = editor.clone();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue