Skip to content

Commit ea63ba1

Browse files
dirvineclaude
andcommitted
feat(ui): wire Call and Canvas into entity tabs, clean dead_code annotations
- Add Call and Canvas variants to EntityTab enum - Create EntityCallContent wrapping CallView in entity pages - Create EntityCanvasContent wrapping CanvasView in entity pages - Call tab available on Channels, Groups, Organizations, Persons - Canvas tab available on Projects - Remove dead_code annotations from call, canvas, and drive components - Remove truly unused items: SortColumn::Type, dialog functions - Move test-only utilities behind #[cfg(test)] Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 1c4d487 commit ea63ba1

15 files changed

Lines changed: 90 additions & 171 deletions

communitas-dioxus/src/components/call/call_view.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ pub fn CallView(props: CallViewProps) -> Element {
295295
}
296296

297297
/// Format duration in MM:SS or HH:MM:SS format.
298-
#[allow(dead_code)] // Used by CallView components which aren't wired into routes yet
299298
fn format_duration(seconds: u64) -> String {
300299
let hours = seconds / 3600;
301300
let minutes = (seconds % 3600) / 60;

communitas-dioxus/src/components/call/screen_share_picker.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ pub fn ScreenSharePicker(props: ScreenSharePickerProps) -> Element {
254254

255255
// Note: Used in the rsx! macro for selected_tab signal and match
256256
#[derive(Clone, Copy, PartialEq, Debug)]
257-
#[allow(dead_code)]
258257
enum SourceTab {
259258
Monitors,
260259
Windows,

communitas-dioxus/src/components/canvas/canvas_view.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ pub fn CanvasView(props: CanvasViewProps) -> Element {
333333
}
334334

335335
/// Render remote cursors overlay if any are present.
336-
#[allow(dead_code)]
337336
fn render_remote_cursors(
338337
cursors: &[communitas_ui_api::canvas::RemoteCursor],
339338
viewport_width: f32,
@@ -444,7 +443,6 @@ fn CanvasElement(props: CanvasElementProps) -> Element {
444443
}
445444

446445
/// Render the content of an element based on its kind.
447-
#[allow(dead_code)]
448446
fn render_element_content(kind: &ElementKindView, transform: &TransformView) -> Element {
449447
match kind {
450448
ElementKindView::Text {

communitas-dioxus/src/components/canvas/history_scrubber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn HistoryEntryDot(props: HistoryEntryDotProps) -> Element {
160160
}
161161

162162
/// Get icon for history action type.
163-
#[allow(dead_code)]
163+
#[allow(dead_code)] // Called from RSX macro in HistoryEntryDot component
164164
fn action_icon(action_type: HistoryActionType) -> &'static str {
165165
match action_type {
166166
HistoryActionType::AddElement => "+",

communitas-dioxus/src/components/canvas/offline_indicator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fn OperationItem(props: OperationItemProps) -> Element {
237237
}
238238

239239
/// Get icon for operation type.
240-
#[allow(dead_code)]
240+
#[allow(dead_code)] // Called from RSX macro in OperationItem component
241241
fn operation_icon(op_type: OperationType) -> &'static str {
242242
match op_type {
243243
OperationType::AddElement => "➕",

communitas-dioxus/src/components/canvas/remote_cursors.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub fn RemoteCursors(props: RemoteCursorsProps) -> Element {
7070
}
7171

7272
/// Calculate opacity based on last activity time.
73-
#[allow(dead_code)]
7473
fn calculate_opacity(last_active: i64, current_time: i64, timeout: i64) -> f32 {
7574
if current_time == 0 {
7675
return 1.0;
@@ -170,7 +169,6 @@ fn RemoteCursorMarker(props: RemoteCursorMarkerProps) -> Element {
170169
}
171170

172171
/// Get short abbreviation for tool name.
173-
#[allow(dead_code)]
174172
fn tool_abbreviation(tool: &str) -> &str {
175173
match tool.to_lowercase().as_str() {
176174
"select" => "S",
@@ -232,7 +230,7 @@ pub fn CollaboratorList(props: CollaboratorListProps) -> Element {
232230
}
233231

234232
/// Get initials from a name.
235-
#[allow(dead_code)]
233+
#[allow(dead_code)] // Called from RSX macro in CollaboratorList component
236234
fn initials(name: &str) -> String {
237235
name.split_whitespace()
238236
.filter_map(|word| word.chars().next())
@@ -245,19 +243,6 @@ fn initials(name: &str) -> String {
245243
mod tests {
246244
use super::*;
247245

248-
#[allow(dead_code)]
249-
fn make_cursor(user_id: &str, name: &str, x: f32, y: f32, color: &str) -> RemoteCursor {
250-
RemoteCursor {
251-
user_id: user_id.to_string(),
252-
user_name: name.to_string(),
253-
x,
254-
y,
255-
color: color.to_string(),
256-
last_active: 1000,
257-
tool: None,
258-
}
259-
}
260-
261246
#[test]
262247
fn initials_extraction() {
263248
assert_eq!(initials("Alice Smith"), "AS");

communitas-dioxus/src/components/canvas/toolbar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn ToolButton(props: ToolButtonProps) -> Element {
212212
}
213213

214214
/// Get the emoji icon for a tool type.
215-
#[allow(dead_code)]
215+
#[allow(dead_code)] // Called from RSX macro in ToolButton component
216216
fn tool_icon(tool: ToolType) -> &'static str {
217217
match tool {
218218
ToolType::Select => "↖",

communitas-dioxus/src/components/drive/browser.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pub enum SortColumn {
2929
Name,
3030
Size,
3131
Modified,
32-
#[allow(dead_code)]
33-
Type,
3432
}
3533

3634
/// Sort direction.

communitas-dioxus/src/components/drive/file_list.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ pub fn FileList(props: FileListProps) -> Element {
6464
SortColumn::Name => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
6565
SortColumn::Size => a.size_bytes.cmp(&b.size_bytes),
6666
SortColumn::Modified => a.modified_at.cmp(&b.modified_at),
67-
SortColumn::Type => {
68-
let a_type = a.mime_type.as_deref().unwrap_or("");
69-
let b_type = b.mime_type.as_deref().unwrap_or("");
70-
a_type.cmp(b_type)
71-
}
7267
};
7368

7469
match props.sort_direction {

communitas-dioxus/src/components/drive/file_picker.rs

Lines changed: 35 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! - Last used directory memory
88
99
use dioxus::prelude::*;
10-
use native_dialog::{FileDialog, MessageDialog, MessageType};
10+
use native_dialog::FileDialog;
1111
use std::path::PathBuf;
1212
use tracing::{debug, info, warn};
1313

@@ -20,43 +20,43 @@ pub struct FileFilter {
2020
pub extensions: &'static [&'static str],
2121
}
2222

23-
#[allow(dead_code)]
2423
impl FileFilter {
25-
/// Common filter for image files.
24+
/// Common filter for all files.
25+
pub const ALL: Self = Self {
26+
name: "All Files",
27+
extensions: &["*"],
28+
};
29+
30+
// Test-only constants
31+
#[cfg(test)]
2632
pub const IMAGES: Self = Self {
2733
name: "Images",
2834
extensions: &["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg"],
2935
};
3036

31-
/// Common filter for document files.
37+
#[cfg(test)]
3238
pub const DOCUMENTS: Self = Self {
3339
name: "Documents",
3440
extensions: &["pdf", "doc", "docx", "txt", "rtf", "odt", "md"],
3541
};
3642

37-
/// Common filter for video files.
43+
#[cfg(test)]
3844
pub const VIDEOS: Self = Self {
3945
name: "Videos",
4046
extensions: &["mp4", "mkv", "avi", "mov", "webm", "m4v"],
4147
};
4248

43-
/// Common filter for audio files.
49+
#[cfg(test)]
4450
pub const AUDIO: Self = Self {
4551
name: "Audio",
4652
extensions: &["mp3", "wav", "flac", "ogg", "m4a", "aac"],
4753
};
4854

49-
/// Common filter for archive files.
55+
#[cfg(test)]
5056
pub const ARCHIVES: Self = Self {
5157
name: "Archives",
5258
extensions: &["zip", "tar", "gz", "7z", "rar", "xz"],
5359
};
54-
55-
/// Common filter for all files.
56-
pub const ALL: Self = Self {
57-
name: "All Files",
58-
extensions: &["*"],
59-
};
6060
}
6161

6262
/// Result of a file picker operation.
@@ -70,14 +70,14 @@ pub enum PickerResult {
7070
Error(String),
7171
}
7272

73-
#[allow(dead_code)]
73+
74+
// Test-only methods for PickerResult
75+
#[cfg(test)]
7476
impl PickerResult {
75-
/// Returns true if files were selected.
7677
pub fn has_selection(&self) -> bool {
7778
matches!(self, Self::Selected(files) if !files.is_empty())
7879
}
7980

80-
/// Returns the selected files, or an empty vec.
8181
pub fn files(&self) -> Vec<PathBuf> {
8282
match self {
8383
Self::Selected(files) => files.clone(),
@@ -113,19 +113,7 @@ impl Default for PickerConfig {
113113
}
114114
}
115115

116-
#[allow(dead_code)]
117116
impl PickerConfig {
118-
/// Create a config for single file selection.
119-
pub fn single_file() -> Self {
120-
Self {
121-
title: "Select File".to_string(),
122-
multiple: false,
123-
directory: false,
124-
filters: vec![FileFilter::ALL],
125-
start_directory: None,
126-
}
127-
}
128-
129117
/// Create a config for multi-file selection.
130118
pub fn multiple_files() -> Self {
131119
Self {
@@ -137,58 +125,48 @@ impl PickerConfig {
137125
}
138126
}
139127

140-
/// Create a config for directory selection.
141-
pub fn directory() -> Self {
142-
Self {
143-
title: "Select Folder".to_string(),
144-
multiple: false,
145-
directory: true,
146-
filters: vec![],
147-
start_directory: None,
148-
}
128+
/// Builder: set the title.
129+
pub fn with_title(mut self, title: impl Into<String>) -> Self {
130+
self.title = title.into();
131+
self
149132
}
150133

151-
/// Create a config for image file selection.
152-
pub fn images() -> Self {
134+
// Test-only builder methods
135+
#[cfg(test)]
136+
pub fn single_file() -> Self {
153137
Self {
154-
title: "Select Images".to_string(),
155-
multiple: true,
138+
title: "Select File".to_string(),
139+
multiple: false,
156140
directory: false,
157-
filters: vec![FileFilter::IMAGES, FileFilter::ALL],
141+
filters: vec![FileFilter::ALL],
158142
start_directory: None,
159143
}
160144
}
161145

162-
/// Create a config for document selection.
163-
pub fn documents() -> Self {
146+
#[cfg(test)]
147+
pub fn directory() -> Self {
164148
Self {
165-
title: "Select Documents".to_string(),
166-
multiple: true,
167-
directory: false,
168-
filters: vec![FileFilter::DOCUMENTS, FileFilter::ALL],
149+
title: "Select Folder".to_string(),
150+
multiple: false,
151+
directory: true,
152+
filters: vec![],
169153
start_directory: None,
170154
}
171155
}
172156

173-
/// Builder: set the title.
174-
pub fn with_title(mut self, title: impl Into<String>) -> Self {
175-
self.title = title.into();
176-
self
177-
}
178-
179-
/// Builder: enable multiple selection.
157+
#[cfg(test)]
180158
pub fn with_multiple(mut self, multiple: bool) -> Self {
181159
self.multiple = multiple;
182160
self
183161
}
184162

185-
/// Builder: set starting directory.
163+
#[cfg(test)]
186164
pub fn with_start_directory(mut self, dir: PathBuf) -> Self {
187165
self.start_directory = Some(dir);
188166
self
189167
}
190168

191-
/// Builder: add a file filter.
169+
#[cfg(test)]
192170
pub fn with_filter(mut self, filter: FileFilter) -> Self {
193171
self.filters.push(filter);
194172
self
@@ -327,77 +305,6 @@ pub fn open_file_picker(config: &PickerConfig) -> PickerResult {
327305
}
328306
}
329307

330-
/// Open a save file dialog.
331-
#[allow(dead_code)]
332-
pub fn open_save_picker(title: &str, default_name: &str, filters: &[FileFilter]) -> PickerResult {
333-
let start_dir = get_last_directory()
334-
.or_else(dirs::download_dir)
335-
.or_else(dirs::home_dir);
336-
337-
debug!(
338-
target: "ui.drive.picker",
339-
title = %title,
340-
default_name = %default_name,
341-
"Opening save picker"
342-
);
343-
344-
let mut dialog = FileDialog::new().set_filename(default_name);
345-
346-
if let Some(ref dir) = start_dir {
347-
dialog = dialog.set_location(dir);
348-
}
349-
350-
for filter in filters {
351-
dialog = dialog.add_filter(filter.name, filter.extensions);
352-
}
353-
354-
match dialog.show_save_single_file() {
355-
Ok(Some(path)) => {
356-
info!(target: "ui.drive.picker", path = ?path, "Save location selected");
357-
set_last_directory(&path);
358-
PickerResult::Selected(vec![path])
359-
}
360-
Ok(None) => {
361-
debug!(target: "ui.drive.picker", "Save picker cancelled");
362-
PickerResult::Cancelled
363-
}
364-
Err(e) => {
365-
warn!(target: "ui.drive.picker", error = %e, "Save picker error");
366-
PickerResult::Error(e.to_string())
367-
}
368-
}
369-
}
370-
371-
/// Show an error message dialog.
372-
#[allow(dead_code)]
373-
pub fn show_error_dialog(title: &str, message: &str) {
374-
let _ = MessageDialog::new()
375-
.set_title(title)
376-
.set_text(message)
377-
.set_type(MessageType::Error)
378-
.show_alert();
379-
}
380-
381-
/// Show an info message dialog.
382-
#[allow(dead_code)]
383-
pub fn show_info_dialog(title: &str, message: &str) {
384-
let _ = MessageDialog::new()
385-
.set_title(title)
386-
.set_text(message)
387-
.set_type(MessageType::Info)
388-
.show_alert();
389-
}
390-
391-
/// Show a confirmation dialog. Returns true if confirmed.
392-
#[allow(dead_code)]
393-
pub fn show_confirm_dialog(title: &str, message: &str) -> bool {
394-
MessageDialog::new()
395-
.set_title(title)
396-
.set_text(message)
397-
.set_type(MessageType::Warning)
398-
.show_confirm()
399-
.unwrap_or(false)
400-
}
401308

402309
/// File picker button component props.
403310
#[derive(Props, Clone, PartialEq)]

0 commit comments

Comments
 (0)