Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add site option for default theme #2104

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/defaults.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
require_application: true
application_question: "string"
private_instance: true
default_theme: "string"
}
# the domain name of your instance (mandatory)
hostname: "unset"
Expand Down
2 changes: 2 additions & 0 deletions crates/api_common/src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub struct CreateSite {
pub require_application: Option<bool>,
pub application_question: Option<String>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
pub auth: Sensitive<String>,
}

Expand All @@ -124,6 +125,7 @@ pub struct EditSite {
pub require_application: Option<bool>,
pub application_question: Option<String>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
pub auth: Sensitive<String>,
}

Expand Down
1 change: 1 addition & 0 deletions crates/api_crud/src/site/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl PerformCrud for CreateSite {
inbox_url,
private_key: Some(Some(keypair.private_key)),
public_key: Some(keypair.public_key),
default_theme: data.default_theme.clone(),
..SiteForm::default()
};

Expand Down
1 change: 1 addition & 0 deletions crates/api_crud/src/site/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl PerformCrud for GetSite {
require_application: setup.require_application,
application_question: setup.application_question.to_owned(),
private_instance: setup.private_instance,
default_theme: setup.default_theme.to_owned(),
auth: admin_jwt,
};
create_site.perform(context, websocket_id).await?;
Expand Down
1 change: 1 addition & 0 deletions crates/api_crud/src/site/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl PerformCrud for EditSite {
require_application: data.require_application,
application_question,
private_instance: data.private_instance,
default_theme: data.default_theme.clone(),
..SiteForm::default()
};

Expand Down
1 change: 1 addition & 0 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ table! {
inbox_url -> Text,
private_key -> Nullable<Text>,
public_key -> Text,
default_theme -> Text,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/db_schema/src/source/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Site {
pub inbox_url: DbUrl,
pub private_key: Option<String>,
pub public_key: String,
pub default_theme: String,
}

#[derive(Insertable, AsChangeset, Default)]
Expand All @@ -50,4 +51,5 @@ pub struct SiteForm {
pub inbox_url: Option<DbUrl>,
pub private_key: Option<Option<String>>,
pub public_key: Option<String>,
pub default_theme: Option<String>,
}
2 changes: 2 additions & 0 deletions crates/utils/src/settings/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,6 @@ pub struct SetupConfig {
pub application_question: Option<String>,
#[default(None)]
pub private_instance: Option<bool>,
#[default(None)]
pub default_theme: Option<String>,
}
1 change: 1 addition & 0 deletions migrations/2022-02-18-210946_default_theme/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table site drop column default_theme;
1 change: 1 addition & 0 deletions migrations/2022-02-18-210946_default_theme/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table site add column default_theme text not null default 'browser';