Skip to content
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

Add: A new toggle button for advanced settings #5290

Merged
merged 10 commits into from
Feb 1, 2025
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
43 changes: 31 additions & 12 deletions app/routes/users/components/UserSettings/UserSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Flex, Icon, LoadingIndicator } from '@webkom/lego-bricks';
import { Accordion, Flex, Icon, LoadingIndicator } from '@webkom/lego-bricks';
import { usePreparedEffect } from '@webkom/react-prepare';
import { Github, Linkedin, Mail } from 'lucide-react';
import { ChevronRight, Github, Linkedin, Mail } from 'lucide-react';
import { Field } from 'react-final-form';
import { useNavigate, useParams } from 'react-router-dom';
import { fetchUser, updateUser } from 'app/actions/UserActions';
Expand Down Expand Up @@ -243,16 +243,35 @@ const UserSettings = () => {
</TypedLegoForm>

{isCurrentUser && (
ch0rizo marked this conversation as resolved.
Show resolved Hide resolved
<>
<div>
<h2>Endre passord</h2>
<ChangePassword />
</div>
<div>
<h2 className={styles.deleteUser}>Slett bruker</h2>
<DeleteUser />
</div>
</>
<Flex column gap="var(--spacing-md)">
<Accordion
triggerComponent={({ onClick, disabled, rotateClassName }) => (
<div className={styles.advancedSettings} onClick={onClick}>
<Flex gap="var(--spacing-sm)" alignItems="center">
<h2>Avansert</h2>
{!disabled && (
<Icon
onPress={onClick}
iconNode={<ChevronRight />}
className={rotateClassName}
/>
)}
</Flex>
</div>
)}
>
<Flex column gap="var(--spacing-md)">
<div>
<h2>Endre passord</h2>
<ChangePassword />
</div>
<div>
<h2 className={styles.deleteUser}>Slett bruker</h2>
<DeleteUser />
</div>
</Flex>
</Accordion>
</Flex>
)}
</ContentMain>
);
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/password_change_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Change password', () => {

it('can change password', () => {
cy.visit('/users/me/settings/profile');
cy.get('h2').contains('Avansert').click();

button('Endre passord').should('be.disabled');
field('password').type(password).blur();
Expand All @@ -27,6 +28,7 @@ describe('Change password', () => {

it('should require certain password strength', () => {
cy.visit('/users/me/settings/profile');
cy.get('h2').contains('Avansert').click();

field('password').type(password).blur();
fieldError('newPassword').should('not.exist');
Expand Down