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

View File

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

View File

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

View File

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

View File

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