Skip to content

Commit

Permalink
added completed and activsated the bounty budget links
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Apr 17, 2024
1 parent 2d9be94 commit 0e88d9f
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 38 deletions.
10 changes: 5 additions & 5 deletions deploy/prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- /home/ec2-user/sphinx-deploy/traefik.yaml:/etc/traefik/traefik.yaml
- /home/ec2-user/letsencrypt:/letsencrypt
environment:
environment:
- AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- AWS_REGION=$AWS_REGION
Expand All @@ -44,7 +44,7 @@ services:
- "traefik.http.routers.auth.tls.certresolver=myresolver"
- "traefik.http.routers.auth.entrypoints=websecure"
restart: on-failure
environment:
environment:
- JWT_KEY=$JWT_KEY
- CLIENT_KEYS=$CLIENT_KEYS
- OAUTH_TIMEOUT=$OAUTH_TIMEOUT
Expand All @@ -64,7 +64,7 @@ services:
- "traefik.http.routers.tribes.tls.certresolver=myresolver"
- "traefik.http.routers.tribes.entrypoints=websecure"
restart: on-failure
environment:
environment:
- DATABASE_URL=$DATABASE_URL
- PODCAST_INDEX_SECRET=$PODCAST_INDEX_SECRET
- PODCAST_INDEX_KEY=$PODCAST_INDEX_KEY
Expand All @@ -73,7 +73,7 @@ services:
- ALERT_SECRET=$ALERT_SECRET
- ALERT_TRIBE_UUID=$ALERT_TRIBE_UUID
- ALERT_BOT_ID=$ALERT_BOT_ID
- ALERT_URL=$ALERT_URL
- ALERT_URL=$ALERT_URL
- RELAY_URL=$RELAY_URL
- RELAY_AUTH_KEY=$RELAY_AUTH_KEY
- RELAY_URL_BACKUP=$RELAY_URL_BACKUP
Expand All @@ -99,7 +99,7 @@ services:
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes.sphinx.chat`) || Host(`people.sphinx.chat`) || Host(`community.sphinx.chat`)|| Host(`bounties.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/org/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes.sphinx.chat`) || Host(`people.sphinx.chat`) || Host(`community.sphinx.chat`)|| Host(`bounties.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/workspace/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.priority=2"
- "traefik.http.services.tribes-frontend.loadbalancer.server.port=80"
- "traefik.http.routers.tribes-frontend.tls=true"
Expand Down
2 changes: 1 addition & 1 deletion deploy/staging/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ services:
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/org/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/workspace/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.priority=2"
- "traefik.http.services.tribes-frontend.loadbalancer.server.port=80"
- "traefik.http.routers.tribes-frontend.tls=true"
Expand Down
2 changes: 1 addition & 1 deletion deploy/staging/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ services:
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/org/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.rule=(Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)) && (Path(`/`) || PathPrefix(`/static`) || Path(`/manifest.json`) || Path(`/favicon.ico`) || Path(`/logo192.png`) || PathPrefix(`/t/`) || Path(`/t`) || PathPrefix(`/p/`) || Path(`/p`) || Path(`/tickets`) || Path(`/bounties`) || Path(`/bounty`) || PathPrefix(`/bounty/`) || Path(`/leaderboard`) || PathPrefix(`/workspace/`) || Path(`/admin`) || PathPrefix(`/b/`) || Path(`/b`))"
- "traefik.http.routers.tribes-frontend.priority=2"
- "traefik.http.services.tribes-frontend.loadbalancer.server.port=80"
- "traefik.http.routers.tribes-frontend.tls=true"
Expand Down
37 changes: 31 additions & 6 deletions src/pages/tickets/Tickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import WidgetSwitchViewer from 'people/widgetViews/WidgetSwitchViewer';
import React, { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router';
import { queryLimit, defaultBountyStatus } from 'store/main';
import { useLocation } from 'react-router-dom';
import { colors } from '../../config/colors';
import { useIsMobile } from '../../hooks';
import { useStores } from '../../store';
import { Body, Backdrop } from './style';

function useQuery() {
const { search } = useLocation();
return React.useMemo(() => new URLSearchParams(search), [search]);
}

// avoid hook within callback warning by renaming hooks
function BodyComponent() {
const { main, ui } = useStores();
Expand All @@ -30,6 +36,30 @@ function BodyComponent() {
const history = useHistory();
const isMobile = useIsMobile();

const searchParams = useQuery();

useEffect(() => {
const status = searchParams.get('status');
if (status === 'completed') {
setCheckboxIdToSelectedMap({
...defaultBountyStatus,
Open: false,
Completed: true
});
} else if (status === 'assigned') {
setCheckboxIdToSelectedMap({
...defaultBountyStatus,
Open: false,
Assigned: true
});
} else if (status === 'open') {
setCheckboxIdToSelectedMap({
...defaultBountyStatus,
Open: true
});
}
}, [searchParams, loading]);

useEffect(() => {
(async () => {
await main.getOpenGithubIssues();
Expand All @@ -43,12 +73,7 @@ function BodyComponent() {
});
setLoading(false);
})();
}, [main, checkboxIdToSelectedMap, languageString]);

useEffect(() => {
setCheckboxIdToSelectedMap({ ...defaultBountyStatus });
main.setBountiesStatus({ ...defaultBountyStatus });
}, [loading]);
}, [main, checkboxIdToSelectedMap, languageString, searchParams]);

useEffect(() => {
if (ui.meInfo) {
Expand Down
15 changes: 15 additions & 0 deletions src/pages/tickets/__tests__/Tickets.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ jest.mock('remark-gfm', () => {});
// eslint-disable-next-line @typescript-eslint/no-empty-function
jest.mock('rehype-raw', () => {});

const mockPush = jest.fn();
const mockGoBack = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => ({
push: mockPush,
goBack: mockGoBack
}),
useLocation: () => ({
pathname: '/bounties',
search: '',
state: {}
})
}));

jest.mock('../../../store', () => ({
useStores: jest.fn(() => ({
main: {
Expand Down
2 changes: 1 addition & 1 deletion src/people/utils/languageLabelStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const coding_languages = [
'Other'
] as const;

export const status = ['Open', 'Assigned', 'Paid'];
export const status = ['Open', 'Assigned', 'Completed', 'Paid'];

export const GetValue = <Item = string>(arr: any): Array<{ id: Item; label: Item; value: Item }> =>
arr.map((val: Item) => ({
Expand Down
2 changes: 2 additions & 0 deletions src/people/widgetViews/BountyHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ const BountyHeader = ({
const [counts, setCounts] = useState({
open: 0,
assigned: 0,
completed: 0,
paid: 0
});

Expand All @@ -367,6 +368,7 @@ const BountyHeader = ({
setCounts({
open: response.open || 0,
assigned: response.assigned || 0,
completed: response.completed || 0,
paid: response.paid || 0
});
} catch (error) {
Expand Down
32 changes: 22 additions & 10 deletions src/people/widgetViews/WorkspaceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ const WorkspaceDetails = (props: {
</NoBudgetWrap>
) : (
<BudgetStatsWrap>
<EuiFlexGrid responsive={true} columns={isMobile ? 2 : 4}>
<EuiFlexGrid responsive={false} columns={isMobile ? 2 : 4}>
<EuiFlexItem>
<BudgetData background="#FAFBFC" borderColor="#DDE1E5">
<BudgetHeaderWrap>
Expand All @@ -461,15 +461,19 @@ const WorkspaceDetails = (props: {
<EuiFlexItem>
<BudgetData background="#9157F612" borderColor="#A76CF34D">
<BudgetBountyLink>
<EuiIcon type="popout" color="#9157F6" />
<Link target="_blank" to={'/bounties?status=completed'}>
<EuiIcon type="popout" color="#9157F6" />
</Link>
</BudgetBountyLink>
<BudgetHeaderWrap>
<BudgetSmallHead color="#9157F6">Completed</BudgetSmallHead>
<BudgetCount color="#9157F6">20</BudgetCount>
<BudgetCount color="#9157F6">
{orgBudget.completed_count ? orgBudget.completed_count.toLocaleString() : 0}
</BudgetCount>
</BudgetHeaderWrap>
<ViewBudgetTextWrap>
<Budget>
{orgBudget.completed_budget ? orgBudget.completed_budget.toLocaleString() : 0}{' '}
{orgBudget.completed_budget ? orgBudget.completed_budget.toLocaleString() : 0}
<Grey>SATS</Grey>
</Budget>
<Budget className="budget-small">
Expand All @@ -482,15 +486,19 @@ const WorkspaceDetails = (props: {
<EuiFlexItem>
<BudgetData background="#49C99812" borderColor="#49C9984D">
<BudgetBountyLink>
<EuiIcon type="popout" color="#2FB379" />
<Link target="_blank" to={'/bounties?status=assigned'}>
<EuiIcon type="popout" color="#2FB379" />
</Link>
</BudgetBountyLink>
<BudgetHeaderWrap>
<BudgetSmallHead color="#2FB379">Assigned</BudgetSmallHead>
<BudgetCount color="#2FB379">20</BudgetCount>
<BudgetCount color="#2FB379">
{orgBudget.assigned_count ? orgBudget.assigned_count.toLocaleString() : 0}
</BudgetCount>
</BudgetHeaderWrap>
<ViewBudgetTextWrap>
<Budget>
{orgBudget.assigned_budget ? orgBudget.assigned_budget.toLocaleString() : 0}{' '}
{orgBudget.assigned_budget ? orgBudget.assigned_budget.toLocaleString() : 0}
<Grey>SATS</Grey>
</Budget>
<Budget className="budget-small">
Expand All @@ -503,15 +511,19 @@ const WorkspaceDetails = (props: {
<EuiFlexItem>
<BudgetData background="#618AFF12" borderColor="#618AFF4D">
<BudgetBountyLink>
<EuiIcon type="popout" color="#5078F2" />
<Link target="_blank" to={'/bounties?status=open'}>
<EuiIcon type="popout" color="#5078F2" />
</Link>
</BudgetBountyLink>
<BudgetHeaderWrap>
<BudgetSmallHead color="#5078F2">Open</BudgetSmallHead>
<BudgetCount color="#5078F2">20</BudgetCount>
<BudgetCount color="#5078F2">
{orgBudget.open_count ? orgBudget.open_count.toLocaleString() : 0}
</BudgetCount>
</BudgetHeaderWrap>
<ViewBudgetTextWrap>
<Budget>
{orgBudget.open_budget ? orgBudget.open_budget.toLocaleString() : 0}{' '}
{orgBudget.open_budget ? orgBudget.open_budget.toLocaleString() : 0}
<Grey>SATS</Grey>
</Budget>
<Budget className="budget-small">
Expand Down
4 changes: 2 additions & 2 deletions src/people/widgetViews/workspace/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ export const BudgetSmallHead = styled.h5<BudgetHeaderProps>`
export const BudgetCount = styled.span<BudgetHeaderProps>`
background: ${(p: any) => p.color};
color: #fff;
padding: 2px 4px;
padding: 1px 4px;
border-radius: 50%;
font-size: 0.66rem;
font-size: 0.65rem;
font-weight: bolder;
display: inline-block;
margin-left: 4px;
Expand Down
26 changes: 14 additions & 12 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,39 +288,40 @@ export interface BountyMetrics {
export interface BountyStatus {
Open: boolean;
Assigned: boolean;
Completed: boolean;
Paid: boolean;
}

export const defaultBountyStatus: BountyStatus = {
Open: true,
Assigned: false,
Completed: false,
Paid: false
};

export interface WorkspaceBountyStatus {
Open: boolean;
Assigned: boolean;
Paid: boolean;
Completed: boolean;
}

export interface WorkspaceBudget {
org_uuid: string;
current_budget: number;
open_budget: number;
open_count: number;
assigned_budget: number;
assigned_count: number;
completed_budget: number;
completed_count: number;
}

export const defaultWorkspaceBudget: WorkspaceBudget = {
org_uuid: '',
current_budget: 0,
open_budget: 0,
open_count: 0,
assigned_budget: 0,
completed_budget: 0
assigned_count: 0,
completed_budget: 0,
completed_count: 0
};

export const defaultWorkspaceBountyStatus: WorkspaceBountyStatus = {
export const defaultWorkspaceBountyStatus: BountyStatus = {
Open: false,
Assigned: false,
Paid: false,
Expand All @@ -330,6 +331,7 @@ export const defaultWorkspaceBountyStatus: WorkspaceBountyStatus = {
export const defaultSuperAdminBountyStatus: BountyStatus = {
Open: false,
Assigned: false,
Completed: false,
Paid: false
};

Expand Down Expand Up @@ -861,7 +863,7 @@ export class MainStore {

workspaceBountiesStatus: BountyStatus = defaultWorkspaceBountyStatus;

@action setWorkspaceBountiesStatus(status: WorkspaceBountyStatus) {
@action setWorkspaceBountiesStatus(status: BountyStatus) {
this.workspaceBountiesStatus = status;
}

Expand Down Expand Up @@ -1922,7 +1924,7 @@ export class MainStore {

// if we don't pass the params, we should use previous params for invalidate query
const query = this.appendQueryParams(
`gobounties/org/next/${org_uuid}/${created}`,
`gobounties/workspace/next/${org_uuid}/${created}`,
queryLimit,
queryParams
);
Expand Down Expand Up @@ -1953,7 +1955,7 @@ export class MainStore {

// if we don't pass the params, we should use previous params for invalidate query
const query = this.appendQueryParams(
`gobounties/org/previous/${org_uuid}/${created}`,
`gobounties/workspace/previous/${org_uuid}/${created}`,
queryLimit,
queryParams
);
Expand Down

0 comments on commit 0e88d9f

Please sign in to comment.