Skip to content

Commit

Permalink
feat(settings): disable show accounts option if multiple accounts aut…
Browse files Browse the repository at this point in the history
…henticated

Signed-off-by: Adam Setch <adam.setch@outlook.com>
  • Loading branch information
setchy committed Aug 6, 2024
1 parent 1a9920b commit a46fc98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/components/settings/AppearanceSettings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { act, fireEvent, render, screen } from '@testing-library/react';
import { webFrame } from 'electron';
import { MemoryRouter } from 'react-router-dom';
import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
import {
mockAuth,
mockGitHubAppAccount,
mockSettings,
} from '../../__mocks__/state-mocks';
import { AppContext } from '../../context/App';
import { AppearanceSettings } from './AppearanceSettings';

Expand Down Expand Up @@ -200,7 +204,9 @@ describe('routes/components/settings/AppearanceSettings.tsx', () => {
render(
<AppContext.Provider
value={{
auth: mockAuth,
auth: {
accounts: [mockGitHubAppAccount],
},
settings: mockSettings,
updateSetting,
}}
Expand Down
5 changes: 3 additions & 2 deletions src/components/settings/AppearanceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let timeout: NodeJS.Timeout;
const DELAY = 200;

export const AppearanceSettings: FC = () => {
const { settings, updateSetting } = useContext(AppContext);
const { auth, settings, updateSetting } = useContext(AppContext);
const [zoomPercentage, setZoomPercentage] = useState(
zoomLevelToPercentage(webFrame.getZoomLevel()),
);
Expand Down Expand Up @@ -198,7 +198,8 @@ export const AppearanceSettings: FC = () => {
<Checkbox
name="showAccountHostname"
label="Show account hostname"
checked={settings.showAccountHostname}
checked={settings.showAccountHostname || auth.accounts.length > 1}
disabled={auth.accounts.length > 1}
onChange={(evt) =>
updateSetting('showAccountHostname', evt.target.checked)
}
Expand Down
3 changes: 3 additions & 0 deletions src/routes/__snapshots__/Settings.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a46fc98

Please sign in to comment.