fix(#9775): UI - Teams owner can only be another user not another team (#9789)

* fix(#9775): UI - Teams owner can only be another user not another team

* fix:cy tests
This commit is contained in:
Sachin Chaurasiya 2023-01-18 19:14:35 +05:30 committed by GitHub
parent 7f111584b8
commit 4bf60bd2f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 12 deletions

View File

@ -805,7 +805,7 @@ export const deleteCreatedProperty = (propertyName) => {
.should('be.visible');
};
export const updateOwner = () => {
export const updateOwner = (isAddingOwnerToTeam = false) => {
cy.get('[data-testid="avatar"]').should('be.visible').click();
cy.get('[data-testid="user-name"]')
.should('exist')
@ -822,12 +822,14 @@ export const updateOwner = () => {
verifyResponseStatusCode('@getTeams', 200);
// Clicking on users tab
cy.get('button[data-testid="dropdown-tab"]')
.should('exist')
.should('be.visible')
.contains('Users')
.click();
if (!isAddingOwnerToTeam) {
// Clicking on users tab
cy.get('button[data-testid="dropdown-tab"]')
.should('exist')
.should('be.visible')
.contains('Users')
.click();
}
cy.get('[data-testid="list-item"]')
.first()

View File

@ -74,7 +74,7 @@ describe('Teams flow should work properly', () => {
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
.contains(TEAM_DETAILS.name)
.click();
updateOwner();
updateOwner(true);
});
it('Add user to created team', () => {

View File

@ -1119,6 +1119,7 @@ const TeamDetailsV1 = ({
{extraInfo.map((info, index) => (
<Fragment key={uniqueId()}>
<EntitySummaryDetails
allowTeamOwner={false}
currentOwner={currentTeam.owner}
data={info}
isGroupType={isGroupType}

View File

@ -45,6 +45,7 @@ export interface GetInfoElementsProps {
currentOwner?: Dashboard['owner'];
removeTier?: () => void;
deleted?: boolean;
allowTeamOwner?: boolean;
}
const EditIcon = ({ iconClasses }: { iconClasses?: string }): JSX.Element => (
@ -80,6 +81,7 @@ const EntitySummaryDetails = ({
removeTier,
currentOwner,
deleted = false,
allowTeamOwner = true,
}: GetInfoElementsProps) => {
let retVal = <></>;
const { t } = useTranslation();
@ -360,6 +362,7 @@ const EntitySummaryDetails = ({
</>
)}
<OwnerWidgetWrapper
allowTeamOwner={allowTeamOwner}
currentUser={currentOwner}
hideWidget={() => setShow(false)}
removeOwner={removeOwner}

View File

@ -204,9 +204,9 @@ const OwnerWidgetWrapper = ({
}
}, [searchText]);
const getOwnerGroup = () => {
const ownerGroupList = useMemo(() => {
return allowTeamOwner ? ['Teams', 'Users'] : ['Users'];
};
}, [allowTeamOwner]);
const handleSearchOwnerDropdown = (text: string) => {
setSearchText(text);
@ -237,9 +237,9 @@ const OwnerWidgetWrapper = ({
controlledSearchStr={searchText}
dropDownList={listOwners}
getTotalCountForGroup={handleTotalCountForGroup}
groupType="tab"
groupType={ownerGroupList.length > 1 ? 'tab' : 'label'}
isLoading={isUserLoading}
listGroups={getOwnerGroup()}
listGroups={ownerGroupList}
removeOwner={handleRemoveOwner}
showSearchBar={isCurrentUserAdmin()}
value={owner?.id || ''}