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
6 changes: 6 additions & 0 deletions deepwell/src/services/view/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ use crate::models::session::Model as SessionModel;
use crate::models::site::Model as SiteModel;
use crate::models::user::Model as UserModel;

// NOTE: Any changes to the output structures here, including the variant names,
// MUST be reflected in framerail!

// TODO replace with actual user permissions type
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
pub struct UserPermissions;
Expand All @@ -51,6 +54,7 @@ pub struct PageRoute {
pub extra: String,
}

// See also framerail src/lib/server/load/page.ts and src/routes/+error.svelte
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum GetPageViewOutput {
Expand Down Expand Up @@ -92,6 +96,7 @@ pub struct GetUserView<'a> {
pub locales: Vec<String>,
}

// See also framerail src/lib/server/load/admin.ts and src/routes/[x+2d]/admin/+error.svelte
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum GetUserViewOutput {
Expand All @@ -114,6 +119,7 @@ pub struct GetAdminView {
pub locales: Vec<String>,
}

// See also framerail src/lib/server/load/admin.ts and src/routes/[x+2d]/user/+error.svelte
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum GetAdminViewOutput {
Expand Down
5 changes: 5 additions & 0 deletions framerail/src/lib/server/load/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export async function loadAdminPage(request, cookies) {
break
case "site_missing":
errorStatus = 404
break
default:
// Unexpected response type!
// There is an inconsistency between here / DEEPWELL
errorStatus = 500
}

if (errorStatus !== null) {
Expand Down
13 changes: 7 additions & 6 deletions framerail/src/lib/server/load/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,20 @@ export async function loadPage(
let errorStatus = null

switch (response.type) {
case "page_found":
case "found":
break
case "page_missing":
case "missing":
viewData.page = null
viewData.page_revision = null
errorStatus = 404
break
case "page_permissions":
case "permissions":
errorStatus = 403
break
case "site_missing":
checkRedirect = false
errorStatus = 404
default:
// Unexpected response type!
// There is an inconsistency between here / DEEPWELL
errorStatus = 500
}

let translateKeys: TranslateKeys = {
Expand Down
5 changes: 5 additions & 0 deletions framerail/src/lib/server/load/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export async function loadUser(username?: string, request, cookies) {
break
case "site_missing":
errorStatus = 404
break
default:
// Unexpected response type!
// There is an inconsistency between here / DEEPWELL
errorStatus = 500
}

if (errorStatus === null && username && viewData.user.slug !== username) {
Expand Down
9 changes: 3 additions & 6 deletions framerail/src/routes/+error.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
Use svelte-switch-case package with {#switch data.view}
as soon as we can figure out prettier support for it.
-->
{#if $page.error.view === "page_missing"}
{#if $page.error.view === "missing"}
UNTRANSLATED:Page not found

{#if $page.error.options?.edit}
Expand Down Expand Up @@ -214,14 +214,11 @@ as soon as we can figure out prettier support for it.
</form>
{/if}
{/if}
{:else if $page.error.view === "page_permissions"}
{:else if $page.error.view === "permissions"}
UNTRANSLATED:Lacks permissions for page
{@html $page.error.compiled_html}
{:else if $page.error.view === "site_missing"}
UNTRANSLATED:No such site
{@html $page.error.html}
{:else}
UNTRANSLATED:Fallback error, something really went wrong
UNTRANSLATED:Fatal error: Unable to display view
{/if}

<style global lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion framerail/src/routes/[x+2d]/admin/+error.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ as soon as we can figure out prettier support for it.
UNTRANSLATED:No such site
{@html $page.error.html}
{:else}
UNTRANSLATED:Fallback error, something really went wrong
UNTRANSLATED:Fatal error: Unable to display view
{/if}

<style global lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion framerail/src/routes/[x+2d]/user/+error.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ as soon as we can figure out prettier support for it.
UNTRANSLATED:No such site
{@html $page.error.html}
{:else}
UNTRANSLATED:Fallback error, something really went wrong
UNTRANSLATED:Fatal error: Unable to display view
{/if}

<style global lang="scss">
Expand Down
Loading