Skip to content

Commit

Permalink
removes provider check from fetchTeams, instead brings up all repos f…
Browse files Browse the repository at this point in the history
…rom all providers (github and gitlab)
  • Loading branch information
e-for-eshaan committed Sep 8, 2024
1 parent 2eca0dc commit 96b781a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 25 deletions.
6 changes: 4 additions & 2 deletions web-server/pages/api/resources/orgs/[org_id]/teams/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const repoSchema = yup.object().shape({

const getSchema = yup.object().shape({
providers: yup.array(
yup.string().oneOf(Object.values(Integration)).required()
yup.string().oneOf(Object.values(Integration)).optional()
)
});

Expand Down Expand Up @@ -86,7 +86,9 @@ endpoint.handle.GET(getSchema, async (req, res) => {
const teams = await getQuery;
const reposWithWorkflows = await getSelectedReposForOrg(
org_id,
providers as Integration[]
providers?.length
? (providers as Integration[])
: [Integration.GITHUB, Integration.GITLAB]
).then((res) => res.flat());

res.send({
Expand Down
3 changes: 1 addition & 2 deletions web-server/pages/integrations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ const Content = () => {
if (hasCodeProviderLinked && !teamCount) {
dispatch(
fetchTeams({
org_id: orgId,
providers: integrationList
org_id: orgId
})
).finally(loadedTeams.true);
}
Expand Down
5 changes: 2 additions & 3 deletions web-server/pages/teams/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ function Page() {
depFn(loading.true);
await dispatch(
fetchTeams({
org_id: orgId,
providers: integrationList
org_id: orgId
})
);
depFn(loading.false);
}, [dispatch, integrationList, loading.false, loading.true, orgId]);
}, [dispatch, loading.false, loading.true, orgId]);

useEffect(() => {
if (!orgId) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export const useTeamSelectorSetup = ({ mode }: UseTeamSelectorSetupArgs) => {

const fetchAllTeams = useCallback(async () => {
await Promise.all([
dispatch(fetchTeams({ org_id: orgId, providers: integrationList })),
dispatch(fetchTeams({ org_id: orgId })),
dispatch(updateTeamBranchesMap({ orgId }))
]);
}, [dispatch, integrationList, orgId]);
}, [dispatch, orgId]);

const apiTeams = useSelector((state) => state.team.teams);
const loadingTeams = useSelector(
Expand Down
7 changes: 3 additions & 4 deletions web-server/src/components/Teams/useTeamsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const TeamsCRUDProvider: React.FC<{
const dispatch = useDispatch();
const teamReposMaps = useSelector((s) => s.team.teamReposMaps);
const teams = useSelector((s) => s.team.teams);
const { orgId, integrationList } = useAuth();
const { orgId } = useAuth();

const isPageLoading = useSelector(
(s) => s.team.requests?.teams === FetchState.REQUEST
Expand All @@ -97,11 +97,10 @@ export const TeamsCRUDProvider: React.FC<{
dispatch(fetchCurrentOrg());
dispatch(
fetchTeams({
org_id: orgId,
providers: integrationList
org_id: orgId
})
);
}, [dispatch, integrationList, orgId]);
}, [dispatch, orgId]);

// team name logic
const teamName = useEasyState('');
Expand Down
5 changes: 2 additions & 3 deletions web-server/src/components/TeamsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const TeamCard: React.FC<TeamCardProps> = ({ team, onEdit }) => {
const MoreOptions = ({ teamId }: { teamId: ID }) => {
const dispatch = useDispatch();
const { enqueueSnackbar } = useSnackbar();
const { orgId, integrationList } = useAuth();
const { orgId } = useAuth();
const anchorEl = useEasyState();
const loading = useBoolState(false);
const cancelMenu = useBoolState(false);
Expand Down Expand Up @@ -285,7 +285,7 @@ const MoreOptions = ({ teamId }: { teamId: ID }) => {
variant: 'success',
autoHideDuration: 2000
});
dispatch(fetchTeams({ org_id: orgId, providers: integrationList }));
dispatch(fetchTeams({ org_id: orgId }));
handleCloseMenu();
} else {
enqueueSnackbar('Failed to delete team', {
Expand All @@ -301,7 +301,6 @@ const MoreOptions = ({ teamId }: { teamId: ID }) => {
dispatch,
enqueueSnackbar,
handleCloseMenu,
integrationList,
loading.false,
loading.true,
orgId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ConfigureGithubModalBody: FC<{
onClose: () => void;
}> = ({ onClose }) => {
const token = useEasyState('');
const { orgId, integrationList } = useAuth();
const { orgId } = useAuth();
const { enqueueSnackbar } = useSnackbar();
const dispatch = useDispatch();
const isLoading = useBoolState();
Expand Down Expand Up @@ -78,8 +78,7 @@ export const ConfigureGithubModalBody: FC<{
dispatch(fetchCurrentOrg());
dispatch(
fetchTeams({
org_id: orgId,
providers: integrationList
org_id: orgId
})
);
enqueueSnackbar('Github linked successfully', {
Expand All @@ -96,7 +95,6 @@ export const ConfigureGithubModalBody: FC<{
}, [
dispatch,
enqueueSnackbar,
integrationList,
isLoading.false,
isLoading.true,
onClose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ConfigureGitlabModalBody: FC<{
}> = ({ onClose }) => {
const token = useEasyState('');
const customDomain = useEasyState('');
const { orgId, integrationList } = useAuth();
const { orgId } = useAuth();
const { enqueueSnackbar } = useSnackbar();
const dispatch = useDispatch();
const isLoading = useBoolState();
Expand Down Expand Up @@ -105,8 +105,7 @@ export const ConfigureGitlabModalBody: FC<{
dispatch(fetchCurrentOrg());
dispatch(
fetchTeams({
org_id: orgId,
providers: integrationList
org_id: orgId
})
);
enqueueSnackbar('Gitlab linked successfully', {
Expand All @@ -124,7 +123,6 @@ export const ConfigureGitlabModalBody: FC<{
customDomain.value,
dispatch,
enqueueSnackbar,
integrationList,
isLoading.false,
isLoading.true,
onClose,
Expand Down
2 changes: 1 addition & 1 deletion web-server/src/slices/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const teamSlice = createSlice({

export const fetchTeams = createAsyncThunk(
'teams/fetchTeams',
async (params: { org_id: ID; providers: Integration[] }) => {
async (params: { org_id: ID; providers?: Integration[] }) => {
return await handleApi<{
teams: Team[];
teamReposMap: Record<ID, DB_OrgRepo[]>;
Expand Down

0 comments on commit 96b781a

Please sign in to comment.