story: Fix #1017 duplicate action name error. (#1020)

This commit is contained in:
Jason Lee 2025-06-30 11:18:57 +08:00 committed by GitHub
parent 21dbaffcf4
commit deb1187c40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 164 additions and 100 deletions

28
Cargo.lock generated
View file

@ -724,7 +724,7 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.10.5",
"itertools 0.11.0",
"lazy_static",
"lazycell",
"log",
@ -747,7 +747,7 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.10.5",
"itertools 0.11.0",
"log",
"prettyplease",
"proc-macro2",
@ -1417,7 +1417,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"indexmap 2.9.0",
"rustc-hash 2.1.0",
@ -1975,7 +1975,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"proc-macro2",
"quote",
@ -3121,7 +3121,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@ -3304,7 +3304,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@ -3574,7 +3574,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"bytes",
@ -3591,7 +3591,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"rustls",
"rustls-platform-verifier",
@ -4417,7 +4417,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"bindgen 0.71.1",
@ -6322,7 +6322,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"derive_refineable",
"workspace-hack",
@ -6477,7 +6477,7 @@ dependencies = [
[[package]]
name = "reqwest_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"bytes",
@ -7052,7 +7052,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]]
name = "semantic_version"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"serde",
@ -7634,7 +7634,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"arrayvec",
"log",
@ -8862,7 +8862,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#aa330fcf2c4c1153d5c4f0408a4f6bfc145d94d5"
source = "git+https://github.com/zed-industries/zed.git#c3d0230f89ff21257d965d4c410a274e52c4fe35"
dependencies = [
"anyhow",
"async-fs 2.1.2",

View file

@ -1,5 +1,5 @@
use gpui::{
actions, prelude::FluentBuilder, px, App, AppContext as _, ClickEvent, Context, Entity,
prelude::FluentBuilder, px, Action, App, AppContext as _, ClickEvent, Context, Entity,
Focusable, InteractiveElement, IntoElement, ParentElement as _, Render, Styled as _, Window,
};
@ -9,10 +9,18 @@ use gpui_component::{
h_flex, indigo, v_flex, white, ActiveTheme, Disableable as _, Icon, IconName, Selectable as _,
Sizable as _, Theme,
};
use serde::Deserialize;
use crate::section;
actions!(story, [Disabled, Loading, Selected, Compact]);
#[derive(Clone, Action, PartialEq, Eq, Deserialize)]
#[action(namespace = button_story, no_json)]
enum ButtonAction {
Disabled,
Loading,
Selected,
Compact,
}
pub struct ButtonStory {
focus_handle: gpui::FocusHandle,
@ -100,10 +108,14 @@ impl Render for ButtonStory {
});
v_flex()
.on_action(cx.listener(|this, _: &Disabled, _, _| this.disabled = !this.disabled))
.on_action(cx.listener(|this, _: &Loading, _, _| this.loading = !this.loading))
.on_action(cx.listener(|this, _: &Selected, _, _| this.selected = !this.selected))
.on_action(cx.listener(|this, _: &Compact, _, _| this.compact = !this.compact))
.on_action(
cx.listener(|this, action: &ButtonAction, _, _| match action {
ButtonAction::Disabled => this.disabled = !this.disabled,
ButtonAction::Loading => this.loading = !this.loading,
ButtonAction::Selected => this.selected = !this.selected,
ButtonAction::Compact => this.compact = !this.compact,
}),
)
.gap_6()
.child(
h_flex()
@ -697,10 +709,26 @@ impl Render for ButtonStory {
.button(Button::new("btn").label("Click Me"))
.selected(selected)
.popup_menu(move |this, _, _| {
this.menu("Disabled", Box::new(Disabled))
.menu("Loading", Box::new(Loading))
.menu("Selected", Box::new(Selected))
.menu("Compact", Box::new(Compact))
this.menu_with_check(
"Disabled",
disabled,
Box::new(ButtonAction::Disabled),
)
.menu_with_check(
"Loading",
loading,
Box::new(ButtonAction::Loading),
)
.menu_with_check(
"Selected",
selected,
Box::new(ButtonAction::Selected),
)
.menu_with_check(
"Compact",
compact,
Box::new(ButtonAction::Compact),
)
}),
)
.child(
@ -708,10 +736,26 @@ impl Render for ButtonStory {
.button(Button::new("btn").label("Click Me"))
.selected(selected)
.popup_menu(move |this, _, _| {
this.menu("Disabled", Box::new(Disabled))
.menu("Loading", Box::new(Loading))
.menu("Selected", Box::new(Selected))
.menu("Compact", Box::new(Compact))
this.menu_with_check(
"Disabled",
disabled,
Box::new(ButtonAction::Disabled),
)
.menu_with_check(
"Loading",
loading,
Box::new(ButtonAction::Loading),
)
.menu_with_check(
"Selected",
selected,
Box::new(ButtonAction::Selected),
)
.menu_with_check(
"Compact",
compact,
Box::new(ButtonAction::Compact),
)
}),
)
.child(
@ -720,10 +764,26 @@ impl Render for ButtonStory {
.button(Button::new("btn").label("Outline Dropdown"))
.selected(selected)
.popup_menu(move |this, _, _| {
this.menu("Disabled", Box::new(Disabled))
.menu("Loading", Box::new(Loading))
.menu("Selected", Box::new(Selected))
.menu("Compact", Box::new(Compact))
this.menu_with_check(
"Disabled",
disabled,
Box::new(ButtonAction::Disabled),
)
.menu_with_check(
"Loading",
loading,
Box::new(ButtonAction::Loading),
)
.menu_with_check(
"Selected",
selected,
Box::new(ButtonAction::Selected),
)
.menu_with_check(
"Compact",
compact,
Box::new(ButtonAction::Compact),
)
}),
)
.child(
@ -732,10 +792,26 @@ impl Render for ButtonStory {
.button(Button::new("btn").label("Ghost Dropdown"))
.selected(selected)
.popup_menu(move |this, _, _| {
this.menu("Disabled", Box::new(Disabled))
.menu("Loading", Box::new(Loading))
.menu("Selected", Box::new(Selected))
.menu("Compact", Box::new(Compact))
this.menu_with_check(
"Disabled",
disabled,
Box::new(ButtonAction::Disabled),
)
.menu_with_check(
"Loading",
loading,
Box::new(ButtonAction::Loading),
)
.menu_with_check(
"Selected",
selected,
Box::new(ButtonAction::Selected),
)
.menu_with_check(
"Compact",
compact,
Box::new(ButtonAction::Compact),
)
}),
),
)

View file

@ -13,7 +13,6 @@ use crate::section;
pub struct ColorPickerStory {
color: Entity<ColorPickerState>,
selected_color: Option<Hsla>,
_subscriptions: Vec<Subscription>,
}

View file

@ -2,9 +2,9 @@ use std::{sync::Arc, time::Duration};
use fake::Fake;
use gpui::{
actions, div, prelude::FluentBuilder as _, px, App, AppContext, Context, Entity, FocusHandle,
Focusable, InteractiveElement as _, IntoElement, ParentElement, Render, SharedString, Styled,
Task, Timer, WeakEntity, Window,
div, prelude::FluentBuilder as _, px, App, AppContext, Context, Entity, FocusHandle, Focusable,
InteractiveElement as _, IntoElement, ParentElement, Render, SharedString, Styled, Task, Timer,
WeakEntity, Window,
};
use raw_window_handle::HasWindowHandle;
@ -21,8 +21,7 @@ use gpui_component::{
};
use crate::section;
actions!(story, [TestAction]);
use crate::TestAction;
pub struct ListItemDeletegate {
story: WeakEntity<DrawerStory>,

View file

@ -1,6 +1,6 @@
use gpui::{
actions, px, App, AppContext, Context, Entity, Focusable, InteractiveElement, IntoElement,
KeyBinding, ParentElement, Render, SharedString, Styled, Window,
px, App, AppContext, Context, Entity, Focusable, InteractiveElement, IntoElement, KeyBinding,
ParentElement, Render, SharedString, Styled, Window,
};
use gpui_component::{
@ -10,8 +10,7 @@ use gpui_component::{
};
use crate::section;
actions!(story, [Tab, TabPrev]);
use crate::{Tab, TabPrev};
const CONTEXT: &str = "DropdownStory";
pub fn init(cx: &mut App) {

View file

@ -1,5 +1,5 @@
use gpui::{
actions, div, prelude::FluentBuilder as _, App, AppContext, Axis, Context, Entity, Focusable,
div, prelude::FluentBuilder as _, App, AppContext, Axis, Context, Entity, Focusable,
InteractiveElement, IntoElement, ParentElement as _, Render, Styled, Window,
};
use gpui_component::{
@ -15,8 +15,6 @@ use gpui_component::{
v_flex, AxisExt, FocusableCycle, Selectable, Sizable, Size,
};
actions!(story, [Tab, TabPrev]);
pub struct FormStory {
name_input: Entity<InputState>,
email_input: Entity<InputState>,

View file

@ -1,18 +1,15 @@
use gpui::{
actions, div, App, AppContext as _, Context, Entity, FocusHandle, Focusable,
InteractiveElement, IntoElement, KeyBinding, ParentElement as _, Render, Styled, Subscription,
Window,
div, App, AppContext as _, Context, Entity, FocusHandle, Focusable, InteractiveElement,
IntoElement, KeyBinding, ParentElement as _, Render, Styled, Subscription, Window,
};
use crate::section;
use crate::{section, Tab, TabPrev};
use gpui_component::{
button::{Button, ButtonVariants as _},
input::{InputEvent, InputState, MaskPattern, TextInput},
v_flex, ContextModal, FocusableCycle, Icon, IconName, Sizable,
};
actions!(story, [Tab, TabPrev]);
const CONTEXT: &str = "InputStory";
pub fn init(cx: &mut App) {

View file

@ -125,6 +125,8 @@ actions!(story, [Quit, Open, CloseWindow, ToggleSearch]);
const PANEL_NAME: &str = "StoryContainer";
actions!(story, [TestAction, Tab, TabPrev]);
pub struct AppState {
pub invisible_panels: Entity<Vec<SharedString>>,
}

View file

@ -16,7 +16,7 @@ use gpui_component::{
v_flex, ActiveTheme, Sizable,
};
actions!(story, [SelectedCompany]);
actions!(list_story, [SelectedCompany]);
#[derive(Clone, Default)]
struct Company {

View file

@ -12,10 +12,10 @@ use serde::Deserialize;
use crate::section;
#[derive(Action, Clone, PartialEq, Deserialize)]
#[action(namespace = story, no_json)]
#[action(namespace = menu_story, no_json)]
struct Info(usize);
actions!(story, [Copy, Paste, Cut, SearchAll, ToggleCheck]);
actions!(menu_story, [Copy, Paste, Cut, SearchAll, ToggleCheck]);
pub fn init(cx: &mut App) {
cx.bind_keys([

View file

@ -1,7 +1,6 @@
use gpui::{
actions, div, prelude::FluentBuilder as _, px, App, AppContext, Context, Entity, FocusHandle,
Focusable, InteractiveElement as _, IntoElement, ParentElement, Render, SharedString, Styled,
Window,
div, prelude::FluentBuilder as _, px, App, AppContext, Context, Entity, FocusHandle, Focusable,
InteractiveElement as _, IntoElement, ParentElement, Render, SharedString, Styled, Window,
};
use gpui_component::{
@ -16,8 +15,7 @@ use gpui_component::{
v_flex, ActiveTheme, ContextModal as _,
};
use crate::section;
actions!(story, [TestAction]);
use crate::{section, TestAction};
pub struct ModalStory {
focus_handle: FocusHandle,

View file

@ -1,18 +1,16 @@
use gpui::{
actions, App, AppContext as _, Context, Entity, FocusHandle, Focusable, InteractiveElement,
IntoElement, KeyBinding, ParentElement as _, Render, Styled, Subscription, Window,
App, AppContext as _, Context, Entity, FocusHandle, Focusable, InteractiveElement, IntoElement,
KeyBinding, ParentElement as _, Render, Styled, Subscription, Window,
};
use regex::Regex;
use crate::section;
use crate::{section, Tab, TabPrev};
use gpui_component::{
button::{Button, ButtonVariants},
input::{InputEvent, InputState, MaskPattern, NumberInput, NumberInputEvent, StepAction},
v_flex, FocusableCycle, IconName, Sizable,
};
actions!(story, [Tab, TabPrev]);
const CONTEXT: &str = "NumberInputStory";
pub fn init(cx: &mut App) {

View file

@ -1,7 +1,7 @@
use gpui::{
actions, prelude::FluentBuilder as _, px, App, AppContext as _, Context, Entity, FocusHandle,
Focusable, InteractiveElement, IntoElement, KeyBinding, ParentElement as _, Render,
SharedString, Styled, Subscription, Window,
prelude::FluentBuilder as _, px, App, AppContext as _, Context, Entity, FocusHandle, Focusable,
InteractiveElement, IntoElement, KeyBinding, ParentElement as _, Render, SharedString, Styled,
Subscription, Window,
};
use gpui_component::{
checkbox::Checkbox,
@ -10,8 +10,7 @@ use gpui_component::{
v_flex, FocusableCycle, Sizable, StyledExt,
};
use crate::section;
actions!(story, [Tab, TabPrev]);
use crate::{section, Tab, TabPrev};
const CONTEXT: &str = "OtpInputStory";

View file

@ -14,10 +14,10 @@ use gpui_component::{
use serde::Deserialize;
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = story, no_json)]
#[action(namespace = popover_story, no_json)]
struct Info(usize);
actions!(story, [Copy, Paste, Cut, SearchAll, ToggleCheck]);
actions!(popover_story, [Copy, Paste, Cut, SearchAll, ToggleCheck]);
pub fn init(cx: &mut App) {
cx.bind_keys([

View file

@ -1,5 +1,5 @@
use gpui::{
div, px, AnyElement, App, AppContext, Context, Entity, Focusable, IntoElement,
div, px, AnyElement, App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement,
ParentElement as _, Pixels, Render, SharedString, Styled, Window,
};
use gpui_component::{
@ -8,7 +8,7 @@ use gpui_component::{
};
pub struct ResizableStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
state1: Entity<ResizableState>,
state2: Entity<ResizableState>,
state3: Entity<ResizableState>,

View file

@ -22,7 +22,7 @@ use gpui_component::{
use serde::Deserialize;
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = story, no_json)]
#[action(namespace = sidebar_story, no_json)]
pub struct SelectCompany(SharedString);
pub struct SidebarStory {

View file

@ -1,6 +1,6 @@
use gpui::{
px, App, AppContext, Context, Div, Entity, Focusable, IntoElement, ParentElement, Render,
SharedString, Styled, Window,
px, App, AppContext, Context, Div, Entity, FocusHandle, Focusable, IntoElement, ParentElement,
Render, SharedString, Styled, Window,
};
use gpui_component::{
@ -10,7 +10,7 @@ use gpui_component::{
use crate::section;
pub struct SwitchStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
switch1: bool,
switch2: bool,
switch3: bool,

View file

@ -24,11 +24,11 @@ use gpui_component::{
use serde::Deserialize;
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = story, no_json)]
#[action(namespace = table_story, no_json)]
struct ChangeSize(Size);
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = story, no_json)]
#[action(namespace = table_story, no_json)]
struct OpenDetail(usize);
#[derive(Clone, Debug, Default)]

View file

@ -1,5 +1,6 @@
use gpui::{
App, AppContext, Context, Entity, Focusable, IntoElement, ParentElement, Render, Styled, Window,
App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement, Render,
Styled, Window,
};
use gpui_component::{
@ -13,7 +14,7 @@ use gpui_component::{
use crate::section;
pub struct TabsStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
active_tab_ix: usize,
size: Size,
menu: bool,

View file

@ -1,6 +1,6 @@
use gpui::{
px, App, AppContext, Context, Entity, Focusable, IntoElement, ParentElement, Render, Styled,
Window,
px, App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement,
Render, Styled, Window,
};
use gpui_component::{h_flex, indigo_50, indigo_500, tag::Tag, v_flex, ColorName, Sizable};
@ -8,7 +8,7 @@ use gpui_component::{h_flex, indigo_50, indigo_500, tag::Tag, v_flex, ColorName,
use crate::section;
pub struct TagStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
}
impl super::Story for TagStory {
@ -37,7 +37,7 @@ impl TagStory {
}
}
impl Focusable for TagStory {
fn focus_handle(&self, _: &gpui::App) -> gpui::FocusHandle {
fn focus_handle(&self, _: &App) -> FocusHandle {
self.focus_handle.clone()
}
}

View file

@ -1,9 +1,9 @@
use gpui::{
actions, px, App, AppContext as _, ClickEvent, Context, Entity, FocusHandle, Focusable,
px, App, AppContext as _, ClickEvent, Context, Entity, FocusHandle, Focusable,
InteractiveElement, IntoElement, KeyBinding, ParentElement as _, Render, Styled, Window,
};
use crate::section;
use crate::{section, Tab, TabPrev};
use gpui_component::{
button::Button,
h_flex,
@ -11,8 +11,6 @@ use gpui_component::{
v_flex, FocusableCycle, Sizable,
};
actions!(story, [Tab, TabPrev]);
const CONTEXT: &str = "TextareaStory";
pub fn init(cx: &mut App) {

View file

@ -1,5 +1,5 @@
use gpui::{
actions, App, AppContext as _, Context, Entity, Focusable, IntoElement, ParentElement as _,
App, AppContext as _, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement as _,
Render, Styled as _, Window,
};
@ -8,10 +8,8 @@ use gpui_component::{
h_flex, v_flex, IconName, Sizable,
};
actions!(story, [Disabled, Loading, Selected, Compact]);
pub struct ToggleStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
single_toggle: usize,
checked: Vec<bool>,
}

View file

@ -16,7 +16,7 @@ use gpui_component::{
use crate::{section, Story};
actions!(story, [Info]);
actions!(tooltip_story, [Info]);
pub fn init(cx: &mut App) {
cx.bind_keys([KeyBinding::new("ctrl-shift-delete", Info, Some("Tooltip"))]);

View file

@ -1,11 +1,13 @@
use gpui::{App, AppContext, Context, Entity, Focusable, ParentElement, Render, Styled, Window};
use gpui::{
App, AppContext, Context, Entity, FocusHandle, Focusable, ParentElement, Render, Styled, Window,
};
use gpui_component::{dock::PanelControl, text::TextView, v_flex};
use crate::Story;
pub struct WelcomeStory {
focus_handle: gpui::FocusHandle,
focus_handle: FocusHandle,
}
impl WelcomeStory {