Repository navigation
feat(mobile): Settings, Personas and Playbooks are an Owner's #848
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { useRoute } from "@react-navigation/native"; | ||
| import type { ComponentType } from "react"; | ||
|
|
||
| import { SettingsScreen } from "../../features/settings/components/SettingsScreen"; | ||
| import { useOwnerSomewhere } from "./guestAccess"; | ||
| import { settingsPageShown } from "./settingsAccess.logic"; | ||
|
|
||
| /** | ||
| * A Settings route whose page is drawn without upstream's `SettingsScreen` (Archive): for someone | ||
| * who owns no connected server it draws an empty `SettingsScreen`, whose gate puts the notice | ||
| * under the page's own header, and the page itself, with its reads, is never mounted. | ||
| */ | ||
| export function ownerOnlySettingsRoute(Screen: ComponentType, title: string): ComponentType { | ||
| function OwnerOnlySettingsRoute() { | ||
| const routeName = useRoute().name; | ||
| return settingsPageShown(routeName, useOwnerSomewhere()) ? ( | ||
| <Screen /> | ||
| ) : ( | ||
| <SettingsScreen title={title}>{null}</SettingsScreen> | ||
| ); | ||
| } | ||
| return OwnerOnlySettingsRoute; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { settingsPageShown } from "./settingsAccess.logic"; | ||
|
|
||
| describe("which Settings pages someone who owns no connected server sees", () => { | ||
| it("shows the pages about the device itself", () => { | ||
| for (const page of [ | ||
| "Settings", | ||
| "SettingsAppearance", | ||
| "SettingsEnvironments", | ||
| "SettingsAbout", | ||
| ]) { | ||
| expect(settingsPageShown(page, false), page).toBe(true); | ||
| } | ||
| }); | ||
|
|
||
| it("withholds a server's pages, and any Settings page not listed as the device's", () => { | ||
| for (const page of ["SettingsProviderAccounts", "SettingsScheduledTasks", "SettingsAgents"]) { | ||
| expect(settingsPageShown(page, false), page).toBe(false); | ||
| } | ||
| expect(settingsPageShown("SettingsSomethingNew", false)).toBe(false); | ||
| }); | ||
|
|
||
| it("withholds nothing from an Owner, or while the servers are still answering", () => { | ||
| expect(settingsPageShown("SettingsProviderAccounts", true)).toBe(true); | ||
| expect(settingsPageShown("SettingsProviderAccounts", "loading")).toBe(true); | ||
| }); | ||
|
|
||
| it("leaves screens outside Settings alone", () => { | ||
| expect(settingsPageShown("Thread", false)).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * Mobile's Settings pages about the device itself, shown to everyone (People and access AC28): | ||
| * its look and input, its saved servers and notifications, and About. Every other Settings page | ||
| * is an Owner's, so a page upstream adds later is shown to Owners only until someone decides | ||
| * otherwise, as on web. | ||
| */ | ||
| const PAGES_FOR_EVERYONE: ReadonlySet<string> = new Set([ | ||
| "Settings", | ||
| "SettingsOrganization", | ||
| "SettingsProjectGrouping", | ||
| "SettingsAppearance", | ||
| "SettingsFollowUp", | ||
| "SettingsNavigation", | ||
| "SettingsKeyboard", | ||
| "SettingsMicrophone", | ||
| "SettingsNotifications", | ||
| "SettingsEnvironments", | ||
| "SettingsEnvironmentDetail", | ||
| "SettingsEnvironmentNew", | ||
| "SettingsAuth", | ||
| "SettingsWaitlist", | ||
| "SettingsAbout", | ||
| "SettingsClientStorage", | ||
| "SettingsDiagnostics", | ||
| "SettingsOpenSourceLicenses", | ||
| "SettingsOpenSourceLicense", | ||
| "SettingsLegal", | ||
| ]); | ||
|
|
||
| /** | ||
| * Whether a screen is shown, by its route name. Only an answer withholds one: while servers are | ||
| * still answering, an Owner's page stays, and the server refuses what is not theirs to read. | ||
| */ | ||
| export const settingsPageShown = (routeName: string, ownerSomewhere: boolean | "loading") => | ||
| ownerSomewhere !== false || | ||
| !routeName.startsWith("Settings") || | ||
| PAGES_FOR_EVERYONE.has(routeName); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Jacksondr5/j5code
Length of output: 15464
Script executed:
Repository: Jacksondr5/j5code
Length of output: 41848
Script executed:
Repository: Jacksondr5/j5code
Length of output: 33337
Script executed:
Repository: Jacksondr5/j5code
Length of output: 17539
Script executed:
Repository: Jacksondr5/j5code
Length of output: 21239
Script executed:
Repository: Jacksondr5/j5code
Length of output: 12694
Stop the scheduled-task editor from using a target after ownership is lost.
When the sharing ownership state removes the current target,
useSettingsEnvironmentFilterremoves it fromavailableTargets, but an existing editor session keeps itsenvironmentId.TaskFormthen displays the retained target and callsserverEnvironment.scheduledTasksLive({ environmentId, input: {} })for it. The save guard blocks writes, but it does not prevent this stale Settings read and display.Guard the editor before rendering
TaskForm, or reset it without discarding unsaved changes.Suggested fix