diff --git a/.changeset/fifty-cars-divide.md b/.changeset/fifty-cars-divide.md new file mode 100644 index 00000000000..6c09cf6869c --- /dev/null +++ b/.changeset/fifty-cars-divide.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixed issue with custom OAuth services' settings not being be fully removed diff --git a/apps/meteor/app/lib/server/methods/removeOAuthService.ts b/apps/meteor/app/lib/server/methods/removeOAuthService.ts index 1be3edeb2ca..6d1bb688979 100644 --- a/apps/meteor/app/lib/server/methods/removeOAuthService.ts +++ b/apps/meteor/app/lib/server/methods/removeOAuthService.ts @@ -61,6 +61,7 @@ Meteor.methods({ Settings.removeById(`Accounts_OAuth_Custom-${name}-channels_admin`), Settings.removeById(`Accounts_OAuth_Custom-${name}-map_channels`), Settings.removeById(`Accounts_OAuth_Custom-${name}-groups_channel_map`), + Settings.removeById(`Accounts_OAuth_Custom-${name}-merge_users_distinct_services`), ]); }, }); diff --git a/apps/meteor/client/views/admin/settings/groups/OAuthGroupPage.tsx b/apps/meteor/client/views/admin/settings/groups/OAuthGroupPage.tsx index edfae92d027..0bd65a3ad53 100644 --- a/apps/meteor/client/views/admin/settings/groups/OAuthGroupPage.tsx +++ b/apps/meteor/client/views/admin/settings/groups/OAuthGroupPage.tsx @@ -1,8 +1,9 @@ import type { ISetting } from '@rocket.chat/core-typings'; import { Button } from '@rocket.chat/fuselage'; +import { capitalize } from '@rocket.chat/string-helpers'; import { useToastMessageDispatch, useAbsoluteUrl, useMethod, useTranslation, useSetModal } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; -import React, { memo } from 'react'; +import React, { memo, useEffect, useState } from 'react'; import { strRight } from '../../../../../lib/utils/stringUtils'; import GenericModal from '../../../../components/GenericModal'; @@ -18,6 +19,8 @@ function OAuthGroupPage({ _id, ...group }: OAuthGroupPageProps): ReactElement { const solo = sections.length === 1; const t = useTranslation(); + const [settingSections, setSettingSections] = useState(sections); + const sectionIsCustomOAuth = (sectionName: string): string | boolean => sectionName && /^Custom OAuth:\s.+/.test(sectionName); const getAbsoluteUrl = useAbsoluteUrl(); @@ -57,6 +60,10 @@ function OAuthGroupPage({ _id, ...group }: OAuthGroupPageProps): ReactElement { setModal( setModal(null)} />); }; + useEffect(() => { + setSettingSections(sections); + }, [sections]); + const removeCustomOauthFactory = (id: string): (() => void) => (): void => { @@ -64,6 +71,7 @@ function OAuthGroupPage({ _id, ...group }: OAuthGroupPageProps): ReactElement { try { await removeOAuthService(id); dispatchToastMessage({ type: 'success', message: t('Custom_OAuth_has_been_removed') }); + setSettingSections(settingSections.filter((section) => section !== `Custom OAuth: ${capitalize(id)}`)); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } finally { @@ -94,7 +102,7 @@ function OAuthGroupPage({ _id, ...group }: OAuthGroupPageProps): ReactElement { } > - {sections.map((sectionName) => { + {settingSections.map((sectionName) => { if (sectionIsCustomOAuth(sectionName)) { const id = strRight(sectionName, 'Custom OAuth: ').toLowerCase();