Skip to content
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
27 changes: 27 additions & 0 deletions apps/auth-service/src/web/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ impl NoChange {
}
}

/// The change of an [`AccountPage`] without a form, written in its `impl`: its
/// `Change` is [`NoChange`], so nothing reopens a row or makes a change.
macro_rules! no_change {
() => {
type Change = $crate::web::account::NoChange;

fn reopened(change: &Self::Change) -> Self::Row {
change.absurd()
}

fn apply(
_: &$crate::web::WebApplication,
_: &::topcoat::context::Cx,
_: $crate::account::Owner,
change: Self::Change,
) -> impl Future<
Output = Result<
$crate::web::account::Applied<Self::Row>,
$crate::account::AccountError,
>,
> + Send {
std::future::ready(change.absurd())
}
};
}
pub(super) use no_change;

/// What a change did, which its page answers.
pub(super) enum Applied<R> {
/// The page says the notice, which a cookie carries, so a link can never claim
Expand Down
17 changes: 2 additions & 15 deletions apps/auth-service/src/web/developers/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
},
web::{
Failure, WebApplication,
account::{AccountPage, Applied, NoChange, Reader},
account::{AccountPage, Applied, Reader, no_change},
},
};
use chrono::Utc;
Expand All @@ -33,21 +33,8 @@ impl AccountPage for Overview {
const SECTION: Section = Section::Developers;
const PATH: &'static str = APP;
const TITLE: &'static str = Title::App.as_str();
type Change = NoChange;
type Row = ();

fn reopened(change: &NoChange) {
match *change {}
}

fn apply(
_: &WebApplication,
_: &Cx,
_: Owner,
change: NoChange,
) -> impl Future<Output = Result<Applied<()>, AccountError>> + Send {
std::future::ready(change.absurd())
}
no_change!();

async fn render(
web: &WebApplication,
Expand Down
17 changes: 2 additions & 15 deletions apps/auth-service/src/web/developers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) use app::{AppSecrets, AppSettings, Overview};

use super::{
Failure, WebApplication,
account::{AccountPage, Applied, Framed, NoChange, Reader},
account::{AccountPage, Applied, Framed, Reader, no_change},
};
use crate::{
MAX_OWNED_CLIENTS,
Expand Down Expand Up @@ -53,21 +53,8 @@ impl AccountPage for Apps {
const SECTION: Section = Section::Developers;
const PATH: &'static str = HOME;
const TITLE: &'static str = Title::Developers.as_str();
type Change = NoChange;
type Row = ();

fn reopened(change: &NoChange) {
match *change {}
}

fn apply(
_: &WebApplication,
_: &Cx,
_: Owner,
change: NoChange,
) -> impl Future<Output = Result<Applied<()>, AccountError>> + Send {
std::future::ready(change.absurd())
}
no_change!();

async fn render(
web: &WebApplication,
Expand Down
17 changes: 2 additions & 15 deletions apps/auth-service/src/web/settings/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
security::FETCH_SITE_HEADER,
web::{
Failure, WebApplication,
account::{AccountPage, Applied, Framed, NoChange, Reader},
account::{AccountPage, Applied, Framed, Reader, no_change},
},
};
use sourceorigin_common::{
Expand Down Expand Up @@ -159,21 +159,8 @@ impl AccountPage for NotificationPage {
const SECTION: Section = Section::Account;
const PATH: &'static str = settings::NOTIFICATION;
const TITLE: &'static str = Tab::Notifications.label();
type Change = NoChange;
type Row = NotificationState;

fn reopened(change: &NoChange) -> NotificationState {
change.absurd()
}

fn apply(
_: &WebApplication,
_: &Cx,
_: Owner,
change: NoChange,
) -> impl Future<Output = Result<Applied<NotificationState>, AccountError>> + Send {
std::future::ready(change.absurd())
}
no_change!();

/// Marks the notification read once opened from auth's own pages, unless to
/// report its event, which marks it read once made, then shows it, with its history entry, the recovery's undo page while it can
Expand Down
18 changes: 2 additions & 16 deletions apps/auth-service/src/web/settings/overview.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//! `/settings`: the account at a glance.

use crate::{
account::{AccountError, Owner},
routes::page::settings,
web::{
Failure, WebApplication,
account::{AccountPage, Applied, NoChange, Reader},
account::{AccountPage, Reader, no_change},
},
};
use chrono::{Duration, Utc};
Expand Down Expand Up @@ -34,21 +33,8 @@ impl AccountPage for Overview {
const SECTION: Section = Section::Account;
const PATH: &'static str = settings::HOME;
const TITLE: &'static str = Self::TAB.label();
type Change = NoChange;
type Row = ();

fn reopened(change: &NoChange) {
match *change {}
}

fn apply(
_: &WebApplication,
_: &Cx,
_: Owner,
change: NoChange,
) -> impl Future<Output = Result<Applied<()>, AccountError>> + Send {
std::future::ready(change.absurd())
}
no_change!();

async fn render(
web: &WebApplication,
Expand Down