Skip to content

Commit

Permalink
Remove user profile additions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Dec 6, 2024
1 parent 136c868 commit 7681d11
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
1 change: 0 additions & 1 deletion packages/kbn-user-profile-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type {
export type {
UserProfileData,
UserSettingsData,
ContrastModeValue,
DarkModeValue,
UserProfileAvatarData,
} from './src/types';
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-user-profile-components/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ export interface UserProfileAvatarData {

export type DarkModeValue = '' | 'dark' | 'light';

export type ContrastModeValue = '' | 'standard' | 'high';

/**
* User settings stored in the data object of the User Profile
*/
export interface UserSettingsData {
darkMode?: DarkModeValue;
contrastMode?: ContrastModeValue;
solutionNavOptOut?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ describe('useUserProfileForm', () => {
"initials": "fn",
},
"userSettings": Object {
"contrastMode": "standard",
"darkMode": "",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
EuiKeyPadMenuItem,
EuiPopover,
EuiSpacer,
EuiSwitch,
EuiText,
EuiToolTip,
useEuiTheme,
Expand All @@ -50,11 +49,7 @@ import {
useFormChangesContext,
} from '@kbn/security-form-components';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import type {
ContrastModeValue,
DarkModeValue,
UserProfileData,
} from '@kbn/user-profile-components';
import type { DarkModeValue, UserProfileData } from '@kbn/user-profile-components';
import { UserAvatar, useUpdateUserProfile } from '@kbn/user-profile-components';

import { createImageHandler, getRandomColor, VALID_HEX_COLOR } from './utils';
Expand Down Expand Up @@ -109,7 +104,6 @@ export interface UserProfileFormValues {
};
userSettings: {
darkMode: DarkModeValue;
contrastMode: ContrastModeValue;
};
};
avatarType: 'initials' | 'image';
Expand Down Expand Up @@ -236,7 +230,7 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
<FormLabel for="data.userSettings.darkMode">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.userSettings.theme"
defaultMessage="Color mode"
defaultMessage="Mode"
/>
</FormLabel>
),
Expand Down Expand Up @@ -282,24 +276,6 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
);
};

const idSelectedContrast = formik.values.data.userSettings.contrastMode;
const contrastModeMenu = () => {
return (
<EuiSwitch
id="contrastMode"
label={i18n.translate(
'xpack.security.accountManagement.userProfile.highContrastModeButton',
{ defaultMessage: 'High contrast' }
)}
checked={idSelectedContrast === 'high'}
onChange={({ target }) => {
const value = target.checked ? 'high' : 'standard';
return formik.setFieldValue('data.userSettings.contrastMode', value);
}}
/>
);
};

return (
<EuiDescribedFormGroup
fullWidth
Expand All @@ -308,7 +284,7 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
<h2>
<FormattedMessage
id="xpack.security.accountManagement.userProfile.userSettingsTitle"
defaultMessage="Appearance"
defaultMessage="Theme"
/>
</h2>
}
Expand All @@ -322,22 +298,6 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
<FormRow name="data.userSettings.darkMode" fullWidth>
{themeMenu(isThemeOverridden)}
</FormRow>

<FormRow
name="data.userSettings.contrastMode"
fullWidth
label={
<FormLabel for="data.userSettings.contrastMode">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.userSettings.contrastMode"
defaultMessage="Accessibility"
/>
</FormLabel>
}
hasChildLabel={false}
>
{contrastModeMenu()}
</FormRow>
</EuiDescribedFormGroup>
);
};
Expand Down Expand Up @@ -916,7 +876,6 @@ export function useUserProfileForm({ user, data }: UserProfileProps) {
},
userSettings: {
darkMode: data.userSettings?.darkMode || '',
contrastMode: data.userSettings?.contrastMode || 'standard',
},
}
: undefined,
Expand Down Expand Up @@ -969,10 +928,7 @@ export function useUserProfileForm({ user, data }: UserProfileProps) {
resetInitialValues(values);

let isRefreshRequired = false;
if (
initialValues.data?.userSettings.darkMode !== values.data?.userSettings.darkMode ||
initialValues.data?.userSettings.contrastMode !== values.data?.userSettings.contrastMode
) {
if (initialValues.data?.userSettings.darkMode !== values.data?.userSettings.darkMode) {
isRefreshRequired = true;
}
showSuccessNotification({ isRefreshRequired });
Expand Down

0 comments on commit 7681d11

Please sign in to comment.