fixes duplicate calls on teams page (#16325)

* fixes duplicate calls on teams page

* fix delete user loading
This commit is contained in:
Karan Hotchandani 2024-05-17 19:09:18 +05:30 committed by GitHub
parent 311243a828
commit a3bc276165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 61 additions and 41 deletions

View File

@ -84,6 +84,7 @@ const ActivityFeedCardV2 = ({
avatarType="outlined"
name={post.from}
size={isPost ? 28 : 30}
width={isPost ? '28' : '30'}
/>
</div>
<Row className="w-full" gutter={[0, 10]}>

View File

@ -50,10 +50,16 @@
}
}
.domain-form-container .toastui-editor,
.add-data-product-modal .toastui-editor {
min-height: 150px !important; // overriding inline style
.ProseMirror {
.domain-form-container,
.add-data-product-modal {
.toastui-editor {
min-height: 150px !important; // overriding inline style
.ProseMirror {
min-height: 150px;
}
}
.toastui-editor-md-preview {
min-height: 150px;
}
}

View File

@ -38,7 +38,7 @@ export const confirmStateInitialValue = {
isThread: false,
};
export const MENTION_ALLOWED_CHARS = /^[A-Za-z0-9_.]*$/;
export const MENTION_ALLOWED_CHARS = /^[A-Za-z0-9_.-]*$/;
export const MENTION_DENOTATION_CHARS = ['@', '#'];
export const TOOLBAR_ITEMS = [

View File

@ -10,9 +10,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AxiosError } from 'axios';
import { isUndefined } from 'lodash';
import { useCallback, useEffect, useState } from 'react';
import IconTeams from '../../assets/svg/teams-grey.svg';
import { ClientErrors } from '../../enums/Axios.enum';
import { User } from '../../generated/entity/teams/user';
import { getUserByName } from '../../rest/userAPI';
import {
@ -78,7 +80,18 @@ export const useUserProfile = ({
userProfilePicsLoading = userProfilePicsLoading.filter((p) => p !== name);
} catch (error) {
// Error
if ((error as AxiosError)?.response?.status === ClientErrors.NOT_FOUND) {
// If user not found, add empty user to prevent further requests and infinite loading
updateUserProfilePics({
id: name,
user: {
name,
id: name,
email: '',
},
});
}
userProfilePicsLoading = userProfilePicsLoading.filter((p) => p !== name);
}
}, [

View File

@ -14,7 +14,7 @@
import { AxiosError } from 'axios';
import { compare, Operation } from 'fast-json-patch';
import { cloneDeep, filter, isEmpty, isUndefined } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
@ -57,7 +57,6 @@ const TeamsPage = () => {
const { t } = useTranslation();
const { getEntityPermissionByFqn } = usePermissionProvider();
const { fqn } = useFqn();
const [currentFqn, setCurrentFqn] = useState<string>('');
const [childTeams, setChildTeams] = useState<Team[]>([]);
const [selectedTeam, setSelectedTeam] = useState<Team>({} as Team);
@ -91,21 +90,6 @@ const TeamsPage = () => {
[entityPermissions]
);
const fetchPermissions = async (entityFqn: string) => {
setIsPageLoading(true);
try {
const perms = await getEntityPermissionByFqn(
ResourceEntity.TEAM,
entityFqn
);
setEntityPermissions(perms);
} catch (error) {
showErrorToast(error as AxiosError);
} finally {
setIsPageLoading(false);
}
};
const descriptionHandler = (value: boolean) => {
setIsDescriptionEditable(value);
};
@ -265,6 +249,11 @@ const TeamsPage = () => {
}
};
const loadAdvancedDetails = useCallback(() => {
fetchTeamAdvancedDetails(fqn);
fetchAllTeamsBasicDetails(fqn);
}, [fqn]);
/**
* Take Team data as input and create the team
* @param data - Team Data
@ -284,6 +273,7 @@ const TeamsPage = () => {
if (res) {
fetchTeamBasicDetails(selectedTeam.name, true);
handleAddTeam(false);
loadAdvancedDetails();
}
} catch (error) {
if (
@ -470,25 +460,28 @@ const TeamsPage = () => {
setShowDeletedTeam((pre) => !pre);
};
useEffect(() => {
if (hasViewPermission && currentFqn !== fqn) {
if (fqn) {
fetchTeamBasicDetails(fqn, true);
const init = useCallback(async () => {
setIsPageLoading(true);
try {
const teamPermissions = await getEntityPermissionByFqn(
ResourceEntity.TEAM,
fqn
);
setEntityPermissions(teamPermissions);
if (teamPermissions.ViewAll || teamPermissions.ViewBasic) {
await fetchTeamBasicDetails(fqn, true);
loadAdvancedDetails();
}
setCurrentFqn(fqn);
} catch (error) {
showErrorToast(error as AxiosError);
} finally {
setIsPageLoading(false);
}
}, [entityPermissions, fqn]);
useEffect(() => {
fetchPermissions(fqn);
}, [fqn]);
useEffect(() => {
if (!isPageLoading && hasViewPermission && fqn) {
fetchTeamAdvancedDetails(fqn);
fetchAllTeamsBasicDetails(fqn);
}
}, [isPageLoading, entityPermissions, fqn]);
init();
}, [fqn]);
useEffect(() => {
if (isFetchAllTeamAdvancedDetails && fqn) {

View File

@ -176,10 +176,17 @@
overflow-y: auto;
}
.glossary-richtext-editor .toastui-editor,
.edit-glossary-modal .toastui-editor {
min-height: 150px !important; // overriding inline style
.ProseMirror {
.glossary-richtext-editor,
.edit-glossary-modal {
.toastui-editor {
min-height: 150px !important; // overriding inline style
.ProseMirror {
min-height: 150px;
}
}
.toastui-editor-md-preview {
min-height: 150px;
}
}