Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix Assign Hunter dialogue issue and inconsistent bounty list loading #805

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/people/utils/AssignedUnassignedBounties.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useMemo, useState } from 'react';
import styled from 'styled-components';
import { observer } from 'mobx-react-lite';
import { BountiesProps } from 'people/interfaces';
Expand Down Expand Up @@ -137,22 +137,19 @@ const Bounties = (props: BountiesProps) => {
const [openConnectModal, setConnectModal] = useState<boolean>(false);
const closeConnectModal = () => setConnectModal(false);
const showConnectModal = () => setConnectModal(true);
const [canAssignHunter, setCanAssignHunter] = useState(false);

const { ui, main } = useStores();
const userPubkey = ui.meInfo?.owner_pubkey;

const checkUserRoles = useCallback(async () => {
const canAssignHunter = await userCanManageBounty(org_uuid, userPubkey, main);
const bountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey;
const canAssignHunter = useMemo(() => {
if (!org_uuid || !userPubkey) return false;

const canAssign = canAssignHunter || bountyOwner;
setCanAssignHunter(canAssign);
}, [main, org_uuid, userPubkey]);
const isBountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey;

useEffect(() => {
checkUserRoles();
}, [checkUserRoles]);
const canManage = userCanManageBounty(org_uuid, userPubkey, main);

return isBountyOwner || canManage;
}, [org_uuid, userPubkey, person.owner_pubkey, main]);

return (
<>
Expand Down
21 changes: 13 additions & 8 deletions src/people/widgetViews/workspace/WorkspacePhase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
setIsPostBountyModalOpen(true);
};

const onPanelClick = () => {
history.push(`/feature/${props.workspace_uuid}`);
const onPanelClick = (activeWorkspace?: string, bounty?: any) => {
if (bounty?.id) {
history.push(`/bounty/${bounty.id}`);
} else {
history.push(`/feature/${props.workspace_uuid}`);
}
};

const handlePhasePlannerClick = () => {
Expand Down Expand Up @@ -260,12 +264,10 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
);

useEffect(() => {
getTotalBounties(checkboxIdToSelectedMap);
}, [getTotalBounties, checkboxIdToSelectedMap]);

useEffect(() => {
if (page === 1 && phases[selectedIndex]) {
if (phases[selectedIndex]) {
(async () => {
setLoading(true);

await main.getPhaseBounties(
phases[selectedIndex].feature_uuid,
phases[selectedIndex].uuid,
Expand All @@ -276,10 +278,13 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
languages: languageString
}
);

await getTotalBounties(checkboxIdToSelectedMap);

setLoading(false);
})();
}
}, [languageString, phases, selectedIndex, main, page, checkboxIdToSelectedMap]);
}, [phases, selectedIndex, main, checkboxIdToSelectedMap, languageString, getTotalBounties]);

useEffect(() => {
const checkUserPermissions = async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export class MainStore {
sortBy: 'created',
search: uiStore.searchText ?? '',
page: 1,
resetPage: false,
resetPage: true,
...params
};

Expand All @@ -752,7 +752,7 @@ export class MainStore {
const query2 = this.appendQueryParams(
`features/${feature_uuid}/phase/${phase_uuid}/bounty`,
queryLimit,
params ? queryParams : this.getWantedsPrevParams
queryParams
);

try {
Expand Down
Loading