8000 feat(settings): support an optional account footer by redoh · Pull Request #20 · inkspect-code-review/inkspect-ui · GitHub
[go: up one dir, main page]

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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ as appropriate. The package's `0.1.0` version is not a claim of a tagged release

## Unreleased

- 2026-11-27 — Allow dashboard editions to place actions after the account security settings.
- 2026-11-27 — Keep paginated review history current and preserve repository and selection when opening linked reviews.

- 2026-11-27 — Include additional authorized repositories in the workspace chat picker.
- 2026-11-27 — Show additional findings and saved reviews in the standard timeline, report tabs, and SARIF export.
- 2026-11-27 — Render published review diagrams in the behavior map.
Expand Down
14 changes: 7 additions & 7 deletions src/components/settings-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import shared from "./dashboard.module.css";
import styles from "./settings.module.css";

export type SettingsSection = { id: string; label: string; description: string; icon: LucideIcon; content: ReactNode };
type SettingsExtensions = { additionalSections?: readonly SettingsSection[]; defaultSection?: string; accountFields?: ReactNode };
type SettingsExtensions = { additionalSections?: readonly SettingsSection[]; defaultSection?: string; accountFields?: ReactNode; accountFooter?: ReactNode };
type SettingsWorkspaceProps = SettingsExtensions & {
organization: DashboardOrganization;
canManage: boolean;
Expand All @@ -33,7 +33,7 @@ export function SettingsWorkspace(props: SettingsWorkspaceProps) {
return <WorkspaceSettings {...props} />;
}

function WorkspaceSettings({ organization, canManage, user, signInMethods, logoUploadsEnabled, workspaceFooter, additionalSections, defaultSection, accountFields }: SettingsWorkspaceProps) {
function WorkspaceSettings({ organization, canManage, user, signInMethods, logoUploadsEnabled, workspaceFooter, additionalSections, defaultSection, accountFields, accountFooter }: SettingsWorkspaceProps) {
const router = useRouter();
const { notify, clearToast } = useNotifications();
const [name, setName] = useState(organization.name);
Expand Down Expand Up @@ -71,7 +71,7 @@ function WorkspaceSettings({ organization, canManage, user, signInMethods, logoU
} finally { setSaving(false); }
}

return <SettingsTabs user={user} signInMethods={signInMethods} additionalSections={additionalSections} defaultSection={defaultSection} accountFields={accountFields} workspace={<>
return <SettingsTabs user={user} signInMethods={signInMethods} additionalSections={additionalSections} defaultSection={defaultSection} accountFields={accountFields} accountFooter={accountFooter} workspace={<>
<section className={styles.section} aria-labelledby="workspace-settings-heading">
<header className={styles.sectionHeader}>
<div><h2 id="workspace-settings-heading">Workspace</h2><p>The shared home for your repositories and reviews.</p></div>
Expand Down Expand Up @@ -105,7 +105,7 @@ type AccountSettingsProps = SettingsExtensions & {
signInMethods?: SignInMethod[];
};

function AccountSettings({ user, signInMethods, accountFields }: AccountSettingsProps) {
function AccountSettings({ user, signInMethods, accountFields, accountFooter }: AccountSettingsProps) {
return <div className={styles.accountCards}><section className={`${styles.section} ${styles.accountCard}`} aria-labelledby="account-settings-heading">
<header className={styles.sectionHeader}>
<div><h2 id="account-settings-heading">Your account</h2><p>Your identity and sign-in methods across all workspaces.</p></div>
Expand All @@ -120,7 +120,7 @@ function AccountSettings({ user, signInMethods, accountFields }: AccountSettings
<section className={`${styles.section} ${styles.accountCard}`} aria-labelledby="security-settings-heading">
<header className={styles.sectionHeader}><div><h2 id="security-settings-heading">Security</h2><p>Protect your account with two-factor authentication and passkeys.</p></div></header>
<AccountSecurity />
</section></div>;
</section>{accountFooter}</div>;
}

// The label stays the accessible name (it is the only visible text on narrow screens); the summary is its description.
Expand All @@ -132,7 +132,7 @@ function SettingsTab({ value, label, description, icon: Icon }: { value: string;
</Tabs.Trigger>;
}

function SettingsTabs({ workspace, reviewProvider, user, signInMethods, additionalSections = [], defaultSection, accountFields }: AccountSettingsProps & { workspace?: ReactNode; reviewProvider?: ReactNode }) {
function SettingsTabs({ workspace, reviewProvider, user, signInMethods, additionalSections = [], defaultSection, accountFields, accountFooter }: AccountSettingsProps & { workspace?: ReactNode; reviewProvider?: ReactNode }) {
const sections = additionalSections.filter(section => !["workspace", "review-provider", "account", "appearance"].includes(section.id));
const available = ["account", "appearance", ...(workspace ? ["workspace"] : []), ...(reviewProvider ? ["review-provider"] : []), ...sections.map(section => section.id)];
const initialSection = defaultSection && available.includes(defaultSection) ? defaultSection : workspace ? "workspace" : "account";
Expand All @@ -146,7 +146,7 @@ function SettingsTabs({ workspace, reviewProvider, user, signInMethods, addition
</Tabs.List>
{workspace && <Tabs.Content className={styles.tabPanel} value="workspace" forceMount>{workspace}</Tabs.Content>}
{reviewProvider && <Tabs.Content className={styles.tabPanel} value="review-provider" forceMount>{reviewProvider}</Tabs.Content>}
<Tabs.Content className={`${styles.tabPanel} ${styles.accountPanel}`} value="account" forceMount><AccountSettings user={user} signInMethods={signInMethods} accountFields={accountFields} /></Tabs.Content>
<Tabs.Content className={`${styles.tabPanel} ${styles.accountPanel}`} value="account" forceMount><AccountSettings user={user} signInMethods={signInMethods} accountFields={accountFields} accountFooter={accountFooter} /></Tabs.Content>
{sections.map(section => <Tabs.Content key={section.id} className={styles.tabPanel} value={section.id} forceMount>{section.content}</Tabs.Content>)}
<Tabs.Content className={styles.tabPanel} value="appearance" forceMount><ThemePicker /></Tabs.Content>
</Tabs.Root>;
Expand Down
6 changes: 6 additions & 0 deletions tests/app/fixtures/settings-tabs-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ test("registered account tab is selectable with its own accessible content",()=>
const html=renderToStaticMarkup(<PersonalSettings user={user} additionalSections={[section]} defaultSection="alerts"/>);
assert.ok(selected(html,"Alerts"));assert.match(html,/Custom preferences/);assert.ok(!selected(html,"Your account"));
});
test("the account footer follows security settings", () => {
const html = renderToStaticMarkup(<PersonalSettings user={user} accountFooter={<button>Example action</button>} />);
const security = html.indexOf('id="security-settings-heading"');
assert.ok(security >= 0);
assert.ok(html.indexOf("Example action") > security);
});
test("unknown defaults and reserved extension IDs cannot hide account settings",()=>{
const html=renderToStaticMarkup(<PersonalSettings user={user} additionalSections={[{...section,id:"account"}]} defaultSection="missing"/>);
assert.ok(selected(html,"Your account"));assert.ok(!html.includes('aria-label="Alerts"'));
Expand Down
Loading
0