Hide post gallery action in preview mode.

This commit is contained in:
2026-07-20 18:18:53 +02:00
parent 47d069dfac
commit e531d32a77

View File

@@ -870,6 +870,7 @@ pub fn view<'a>(
] ]
.spacing(6) .spacing(6)
.align_y(iced::Alignment::Center); .align_y(iced::Alignment::Center);
let show_content_actions = content_actions_visible(&state.editor_mode);
let body_toolbar = inputs::toolbar( let body_toolbar = inputs::toolbar(
vec![ vec![
row![ row![
@@ -881,7 +882,7 @@ pub fn view<'a>(
.into(), .into(),
], ],
vec![ vec![
if state.editor_mode == "markdown" { if show_content_actions {
button( button(
text(t(locale, "editor.insertLink")) text(t(locale, "editor.insertLink"))
.size(13) .size(13)
@@ -894,7 +895,7 @@ pub fn view<'a>(
} else { } else {
Space::new(0, 0).into() Space::new(0, 0).into()
}, },
if state.editor_mode == "markdown" { if show_content_actions {
button( button(
text(t(locale, "editor.insertMedia")) text(t(locale, "editor.insertMedia"))
.size(13) .size(13)
@@ -907,6 +908,7 @@ pub fn view<'a>(
} else { } else {
Space::new(0, 0).into() Space::new(0, 0).into()
}, },
if show_content_actions {
button( button(
text(t(locale, "editor.gallery")) text(t(locale, "editor.gallery"))
.size(13) .size(13)
@@ -915,7 +917,10 @@ pub fn view<'a>(
.on_press(Message::PostEditor(PostEditorMsg::Gallery)) .on_press(Message::PostEditor(PostEditorMsg::Gallery))
.padding([6, 16]) .padding([6, 16])
.style(inputs::secondary_button) .style(inputs::secondary_button)
.into(), .into()
} else {
Space::new(0, 0).into()
},
], ],
); );
let editor_widget: Element<'a, Message> = if state.editor_mode == "preview" { let editor_widget: Element<'a, Message> = if state.editor_mode == "preview" {
@@ -1106,6 +1111,10 @@ fn normalize_editor_mode(mode: &str) -> String {
} }
} }
fn content_actions_visible(mode: &str) -> bool {
mode == "markdown"
}
fn status_badge<'a>(status: &PostStatus) -> Element<'a, Message> { fn status_badge<'a>(status: &PostStatus) -> Element<'a, Message> {
let (label, color) = match status { let (label, color) = match status {
PostStatus::Draft => ("Draft", Color::from_rgb(0.8, 0.7, 0.2)), PostStatus::Draft => ("Draft", Color::from_rgb(0.8, 0.7, 0.2)),
@@ -1245,4 +1254,10 @@ mod tests {
state.set_editor_mode("preview"); state.set_editor_mode("preview");
assert_eq!(state.editor_mode, "preview"); assert_eq!(state.editor_mode, "preview");
} }
#[test]
fn content_actions_are_only_visible_in_markdown_mode() {
assert!(content_actions_visible("markdown"));
assert!(!content_actions_visible("preview"));
}
} }