mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: hide ungrouped feature (#3817)
* refactor: remove unused notification and listener * revert: remove hide_ungrouped from group settings * chore: add board layout setting * chore: listen to layout settings on ui * fix: duplicated group controller initialization * chore: add a tooltip to the ungrouped items button * chore: trailing comma
This commit is contained in:
@ -28,23 +28,6 @@ async fn group_init_test() {
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
// #[tokio::test]
|
||||
// async fn group_configuration_setting_test() {
|
||||
// let mut test = DatabaseGroupTest::new().await;
|
||||
// let scripts = vec![
|
||||
// AssertGroupConfiguration {
|
||||
// hide_ungrouped: false,
|
||||
// },
|
||||
// UpdateGroupConfiguration {
|
||||
// hide_ungrouped: Some(true),
|
||||
// },
|
||||
// AssertGroupConfiguration {
|
||||
// hide_ungrouped: true,
|
||||
// },
|
||||
// ];
|
||||
// test.run_scripts(scripts).await;
|
||||
// }
|
||||
|
||||
#[tokio::test]
|
||||
async fn group_move_row_test() {
|
||||
let mut test = DatabaseGroupTest::new().await;
|
||||
|
@ -1,13 +1,15 @@
|
||||
use collab_database::fields::Field;
|
||||
use collab_database::views::DatabaseLayout;
|
||||
|
||||
use flowy_database2::entities::FieldType;
|
||||
use flowy_database2::services::setting::CalendarLayoutSetting;
|
||||
use flowy_database2::entities::{FieldType, LayoutSettingChangeset, LayoutSettingParams};
|
||||
use flowy_database2::services::setting::{BoardLayoutSetting, CalendarLayoutSetting};
|
||||
|
||||
use crate::database::database_editor::DatabaseEditorTest;
|
||||
|
||||
pub enum LayoutScript {
|
||||
AssertBoardLayoutSetting { expected: BoardLayoutSetting },
|
||||
AssertCalendarLayoutSetting { expected: CalendarLayoutSetting },
|
||||
UpdateBoardLayoutSetting { new_setting: BoardLayoutSetting },
|
||||
AssertDefaultAllCalendarEvents,
|
||||
AssertAllCalendarEventsCount { expected: usize },
|
||||
UpdateDatabaseLayout { layout: DatabaseLayout },
|
||||
@ -23,21 +25,39 @@ impl DatabaseLayoutTest {
|
||||
Self { database_test }
|
||||
}
|
||||
|
||||
pub async fn new_board() -> Self {
|
||||
let database_test = DatabaseEditorTest::new_board().await;
|
||||
Self { database_test }
|
||||
}
|
||||
|
||||
pub async fn new_calendar() -> Self {
|
||||
let database_test = DatabaseEditorTest::new_calendar().await;
|
||||
Self { database_test }
|
||||
}
|
||||
|
||||
pub async fn get_first_date_field(&self) -> Field {
|
||||
self.database_test.get_first_field(FieldType::DateTime)
|
||||
}
|
||||
|
||||
async fn get_layout_setting(
|
||||
&self,
|
||||
view_id: &str,
|
||||
layout_ty: DatabaseLayout,
|
||||
) -> LayoutSettingParams {
|
||||
self
|
||||
.database_test
|
||||
.editor
|
||||
.get_layout_setting(view_id, layout_ty)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn run_scripts(&mut self, scripts: Vec<LayoutScript>) {
|
||||
for script in scripts {
|
||||
self.run_script(script).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_first_date_field(&self) -> Field {
|
||||
self.database_test.get_first_field(FieldType::DateTime)
|
||||
}
|
||||
|
||||
pub async fn run_script(&mut self, script: LayoutScript) {
|
||||
match script {
|
||||
LayoutScript::UpdateDatabaseLayout { layout } => {
|
||||
@ -56,19 +76,27 @@ impl DatabaseLayoutTest {
|
||||
.await;
|
||||
assert_eq!(events.len(), expected);
|
||||
},
|
||||
LayoutScript::AssertBoardLayoutSetting { expected } => {
|
||||
let view_id = self.database_test.view_id.clone();
|
||||
let layout_ty = DatabaseLayout::Board;
|
||||
|
||||
let layout_settings = self.get_layout_setting(&view_id, layout_ty).await;
|
||||
|
||||
assert!(layout_settings.calendar.is_none());
|
||||
assert_eq!(
|
||||
layout_settings.board.unwrap().hide_ungrouped_column,
|
||||
expected.hide_ungrouped_column
|
||||
);
|
||||
},
|
||||
LayoutScript::AssertCalendarLayoutSetting { expected } => {
|
||||
let view_id = self.database_test.view_id.clone();
|
||||
let layout_ty = DatabaseLayout::Calendar;
|
||||
|
||||
let calendar_setting = self
|
||||
.database_test
|
||||
.editor
|
||||
.get_layout_setting(&view_id, layout_ty)
|
||||
.await
|
||||
.unwrap()
|
||||
.calendar
|
||||
.unwrap();
|
||||
let layout_settings = self.get_layout_setting(&view_id, layout_ty).await;
|
||||
|
||||
assert!(layout_settings.board.is_none());
|
||||
|
||||
let calendar_setting = layout_settings.calendar.unwrap();
|
||||
assert_eq!(calendar_setting.layout_ty, expected.layout_ty);
|
||||
assert_eq!(
|
||||
calendar_setting.first_day_of_week,
|
||||
@ -76,6 +104,20 @@ impl DatabaseLayoutTest {
|
||||
);
|
||||
assert_eq!(calendar_setting.show_weekends, expected.show_weekends);
|
||||
},
|
||||
LayoutScript::UpdateBoardLayoutSetting { new_setting } => {
|
||||
let changeset = LayoutSettingChangeset {
|
||||
view_id: self.database_test.view_id.clone(),
|
||||
layout_type: DatabaseLayout::Board,
|
||||
board: Some(new_setting),
|
||||
calendar: None,
|
||||
};
|
||||
self
|
||||
.database_test
|
||||
.editor
|
||||
.set_layout_setting(&self.database_test.view_id, changeset)
|
||||
.await
|
||||
.unwrap()
|
||||
},
|
||||
LayoutScript::AssertDefaultAllCalendarEvents => {
|
||||
let events = self
|
||||
.database_test
|
||||
|
@ -1,9 +1,31 @@
|
||||
use collab_database::views::DatabaseLayout;
|
||||
use flowy_database2::services::setting::BoardLayoutSetting;
|
||||
use flowy_database2::services::setting::CalendarLayoutSetting;
|
||||
|
||||
use crate::database::layout_test::script::DatabaseLayoutTest;
|
||||
use crate::database::layout_test::script::LayoutScript::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_layout_setting_test() {
|
||||
let mut test = DatabaseLayoutTest::new_board().await;
|
||||
let default_board_setting = BoardLayoutSetting::new();
|
||||
let new_board_setting = BoardLayoutSetting {
|
||||
hide_ungrouped_column: true,
|
||||
};
|
||||
let scripts = vec![
|
||||
AssertBoardLayoutSetting {
|
||||
expected: default_board_setting,
|
||||
},
|
||||
UpdateBoardLayoutSetting {
|
||||
new_setting: new_board_setting.clone(),
|
||||
},
|
||||
AssertBoardLayoutSetting {
|
||||
expected: new_board_setting,
|
||||
},
|
||||
];
|
||||
test.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn calendar_initial_layout_setting_test() {
|
||||
let mut test = DatabaseLayoutTest::new_calendar().await;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use collab_database::database::{gen_database_id, gen_database_view_id, gen_row_id, DatabaseData};
|
||||
use collab_database::views::{DatabaseLayout, DatabaseView};
|
||||
use collab_database::views::{DatabaseLayout, DatabaseView, LayoutSetting, LayoutSettings};
|
||||
use flowy_database2::services::field_settings::DatabaseFieldSettingsMapBuilder;
|
||||
use flowy_database2::services::setting::BoardLayoutSetting;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use flowy_database2::entities::FieldType;
|
||||
@ -128,6 +129,8 @@ pub fn make_test_board() -> DatabaseData {
|
||||
}
|
||||
}
|
||||
|
||||
let board_setting: LayoutSetting = BoardLayoutSetting::new().into();
|
||||
|
||||
let field_settings =
|
||||
DatabaseFieldSettingsMapBuilder::new(fields.clone(), DatabaseLayout::Board).build();
|
||||
|
||||
@ -238,12 +241,15 @@ pub fn make_test_board() -> DatabaseData {
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
let mut layout_settings = LayoutSettings::new();
|
||||
layout_settings.insert(DatabaseLayout::Board, board_setting);
|
||||
|
||||
let view = DatabaseView {
|
||||
id: gen_database_view_id(),
|
||||
database_id: gen_database_id(),
|
||||
name: "".to_string(),
|
||||
layout: DatabaseLayout::Board,
|
||||
layout_settings: Default::default(),
|
||||
layout_settings,
|
||||
filters: vec![],
|
||||
group_settings: vec![],
|
||||
sorts: vec![],
|
||||
|
Reference in New Issue
Block a user