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

Implement sort by newest and oldest filters on org page #48

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
956c72a
fix: merge conflicts and workflows failures
jordan-ae Jan 31, 2024
ff7c30a
fix(hide-button): fixed hide post bounty button in org page and also …
aliraza556 Jan 31, 2024
17b0033
fix(super-admin-unit-test): fixed the super-admin-header unit test
aliraza556 Jan 31, 2024
b499227
fix(super-admin-unit-test): fixed the super-admin-header unit test an…
aliraza556 Jan 31, 2024
6c8d5c8
fixed superadmin pagination
elraphty Jan 31, 2024
c7d60d3
Tickets.tsx Component Tests
Gaurav-Gaikwad-1 Jan 29, 2024
30e9c51
updated Ticket.spec.tsx
Gaurav-Gaikwad-1 Jan 30, 2024
322fa0a
Update Tickets.spec.tsx
Gaurav-Gaikwad-1 Jan 30, 2024
01c3240
feat: cypress initial setup
tobi-bams Jan 26, 2024
53b481b
feat: cypress login test
tobi-bams Jan 26, 2024
2008a07
update: used dynamic user record from nodes array
tobi-bams Jan 26, 2024
50df515
feat: added a simple function to help post relay users to tribe server
tobi-bams Jan 27, 2024
a2fa728
update: fixed config, jest test was failling
tobi-bams Jan 27, 2024
8bd6e83
update: change details back to normal
tobi-bams Jan 27, 2024
43d71be
update: fixed prettier
tobi-bams Jan 29, 2024
be43659
feat: setup github workflow for cypress test
tobi-bams Jan 29, 2024
d25607f
feat: add script for cypress run
tobi-bams Jan 29, 2024
17f5ee6
update: changed the host port from 5001 to 13000 and change ModeDispa…
tobi-bams Jan 29, 2024
a2fbf66
update: added some steps for docker config
tobi-bams Jan 29, 2024
51d9d79
fix: added write access to sphinx-tribes-frontend cypress folder
tobi-bams Jan 29, 2024
7b9bb0b
getting correct write access
tobi-bams Jan 29, 2024
01a01ef
update: trying to add permissions to cypress
tobi-bams Jan 29, 2024
1cb0d1c
update: changed copy part for fixtures
tobi-bams Jan 29, 2024
59b37ea
fix: trying to get the present working directory
tobi-bams Jan 29, 2024
76b1a7b
fix: trying to know what folders and file we have in our current dire…
tobi-bams Jan 29, 2024
ea30fe7
update: installed dependencies and start the server
tobi-bams Jan 29, 2024
d0822e4
fix: use yarn instead of npm
tobi-bams Jan 29, 2024
388ff11
update: ensured I can run another commad after yarn start
tobi-bams Jan 29, 2024
87e7f8d
update: updated spelling error in flow
tobi-bams Jan 29, 2024
5e6d88d
when testing with cypress host url should be localhost:13007
tobi-bams Jan 29, 2024
2d9eefc
update: changed port cypress test run on
tobi-bams Jan 29, 2024
ceba1e7
update: when frontend is running on 3007 backend host should be 13000
tobi-bams Jan 29, 2024
7bf628f
update: cypress should try to access port 3007 and not 3000 again
tobi-bams Jan 29, 2024
1ac35cc
update: run prettier
tobi-bams Jan 29, 2024
aaf0295
update: cypress screenshot
tobi-bams Jan 29, 2024
5a7c819
update: stop tracking nodes.json file
tobi-bams Jan 30, 2024
b4a736c
correct part
tobi-bams Jan 30, 2024
33da265
update: stop tracking screen shots
tobi-bams Jan 30, 2024
d746682
update: changed localhost mode dispatch back to tribes from community
tobi-bams Jan 31, 2024
3c01ee5
update: handled error while creating user profile
tobi-bams Jan 31, 2024
a1be2b9
org scrolling fix
Vayras Jan 30, 2024
712c7db
test additon
Vayras Jan 30, 2024
b22f13e
update
Vayras Jan 30, 2024
4bb613f
prettier
Vayras Jan 30, 2024
9b27ecb
fixed failing test
elraphty Feb 1, 2024
c7ed37c
fix: merge conflicts and workflows failures
jordan-ae Jan 31, 2024
d5c426f
Squashed commit of the following:
jordan-ae Feb 1, 2024
4b509c1
Squashed commit of the following:
jordan-ae Feb 1, 2024
6fba8a2
Merge branch 'master' into feat/implement-sort-by-filter-on-org-page
jordan-ae Feb 1, 2024
75103c0
Squashed commit of the following:
jordan-ae Feb 3, 2024
83e9520
Added Readme
jordan-ae Feb 3, 2024
0af75ef
Squashed commit of the following:
jordan-ae Feb 3, 2024
57b46b6
Squashed commit of the following:
jordan-ae Feb 3, 2024
66bcb77
Merge branch 'master' into feat/implement-sort-by-filter-on-org-page
jordan-ae Feb 3, 2024
2febbc3
addresed failing filters
jordan-ae Feb 3, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@
"ts-loader": "^9.5.1",
"typescript": "^5.3.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ describe('Header Component', () => {
});

const StartDate30 = today.clone().subtract(30, 'days');
expect(monthElement).toHaveTextContent(
`${StartDate30.format('DD MMM')} - ${expectedEndDate.format('DD MMM YYYY')}`
);
const expectedTextForSameYear = `${StartDate30.format('DD MMM')} - ${expectedEndDate.format(
'DD MMM YYYY'
)}`;
expect(monthElement).toHaveTextContent(expectedTextForSameYear);

act(() => {
rerender(
Expand Down
135 changes: 123 additions & 12 deletions src/pages/tickets/org/orgHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef, useMemo } from 'react';
import { EuiCheckboxGroup, EuiPopover, EuiText } from '@elastic/eui';
import MaterialIcon from '@material/react-material-icon';
import { PostModal } from 'people/widgetViews/postBounty/PostModal';
Expand Down Expand Up @@ -53,6 +53,18 @@ const color = colors['light'];
const Coding_Languages = GetValue(coding_languages);

const Status = ['Open', 'Assigned', 'Completed', 'Paid'];

const sortDirectionOptions = [
{
id: 'desc',
label: 'Newest First'
},
{
id: 'asc',
label: 'Oldest First'
}
];

export const OrgHeader = ({
onChangeLanguage,
checkboxIdToSelectedMapLanguage,
Expand All @@ -67,6 +79,9 @@ export const OrgHeader = ({
const [filterClick, setFilterClick] = useState(false);
const [canPostBounty, setCanPostBounty] = useState(false);
const [isStatusPopoverOpen, setIsStatusPopoverOpen] = useState<boolean>(false);
const [isSortByPopoverOpen, setIsSortByPopoverOpen] = useState(false);
const [sortDirection, setSortDirection] = useState<string>('desc');

const onButtonClick = async () => {
setIsStatusPopoverOpen((isPopoverOpen: any) => !isPopoverOpen);
};
Expand All @@ -85,6 +100,30 @@ export const OrgHeader = ({
}
}, [ui.meInfo, org_uuid, main]);

const sortDirectionLabel = useMemo(
() => (sortDirection === 'asc' ? 'Oldest First' : 'Newest First'),
[sortDirection]
);

const onSortButtonClick = async () => {
setIsSortByPopoverOpen((isPopoverOpen: any) => !isPopoverOpen);
};

const closeSortByPopover = () => setIsSortByPopoverOpen(false);

useEffect(() => {
const checkUserPermissions = async () => {
const isLoggedIn = !!ui.meInfo;
const hasPermission =
isLoggedIn && (await userCanManageBounty(org_uuid, ui.meInfo?.pubkey, main));
setCanPostBounty(hasPermission);
};

if (ui.meInfo && org_uuid) {
checkUserPermissions();
}
}, [ui.meInfo, org_uuid, main]);

const selectedWidget = 'wanted';

const filterRef = useRef<HTMLDivElement | null>(null);
Expand All @@ -109,7 +148,8 @@ export const OrgHeader = ({
page: 1,
resetPage: true,
...checkboxIdToSelectedMap,
languageString
languageString,
direction: sortDirection
});
}
}, [org_uuid, checkboxIdToSelectedMap, main, languageString]);
Expand All @@ -134,12 +174,36 @@ export const OrgHeader = ({
return () => {
window.removeEventListener('click', handleWindowClick);
};
}, [filterClick]);
}, [org_uuid, checkboxIdToSelectedMap, languageString, main, filterClick]);

return (
<>
<FillContainer>
<Header>
<Leftheader>
<ImageContainer src={img} width="72px" height="72px" alt="organization icon" />
<CompanyNameAndLink>
<CompanyLabel>{name}</CompanyLabel>
<UrlButtonContainer data-testid="url-button-container">
{website !== '' ? (
<UrlButton onClick={() => handleWebsiteButton(website ?? '')}>
<img src={websiteIcon} alt="" />
Website
</UrlButton>
) : (
''
)}
{github !== '' ? (
<UrlButton onClick={() => handleGithubButton(github ?? '')}>
<img src={githubIcon} alt="" />
Github
</UrlButton>
) : (
''
)}
</UrlButtonContainer>
</CompanyNameAndLink>
</Leftheader>
<Leftheader>
<ImageContainer src={img} width="72px" height="72px" alt="organization icon" />
<CompanyNameAndLink>
Expand Down Expand Up @@ -222,7 +286,7 @@ export const OrgHeader = ({
<div
style={{
display: 'flex',
flexDirection: 'row'
flex: 'row'
}}
>
<EuiPopOverCheckbox className="CheckboxOuter" color={color}>
Expand Down Expand Up @@ -266,14 +330,61 @@ export const OrgHeader = ({
<Icon src={searchIcon} alt="Search" />
</SearchWrapper>
</FiltersRight>
<FiltersLeft>
<SoryByContainer>
<FilterLabel>Sort by:Newest First</FilterLabel>
<DropDownButton>
<Img src={dropdown} alt="" />
</DropDownButton>
</SoryByContainer>
</FiltersLeft>
<EuiPopover
button={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @okhot,
Please, @okhot, review your previous code changes and also consider examining other files if necessary to ensure everything is aligned and functioning as expected

<StatusContainer onClick={onSortButtonClick} className="CheckboxOuter" color={color}>
<div style={{ minWidth: '145px' }}>
<EuiText
className="statusText"
style={{
color: isSortByPopoverOpen ? color.grayish.G10 : ''
}}
>
Sort By: {sortDirectionLabel}
</EuiText>
</div>

<div className="filterStatusIconContainer">
<MaterialIcon
className="materialStatusIcon"
icon={`${isSortByPopoverOpen ? 'keyboard_arrow_up' : 'keyboard_arrow_down'}`}
style={{
color: isSortByPopoverOpen ? color.grayish.G10 : ''
}}
/>
</div>
</StatusContainer>
}
panelStyle={{
border: 'none',
boxShadow: `0px 1px 20px ${color.black90}`,
background: `${color.pureWhite}`,
borderRadius: '0px 0px 6px 6px',
maxWidth: '140px',
marginTop: '0px',
marginRight: '30px'
}}
isOpen={isSortByPopoverOpen}
closePopover={closeSortByPopover}
panelClassName="yourClassNameHere"
panelPaddingSize="none"
anchorPosition="downLeft"
>
<div
style={{
display: 'flex',
flexDirection: 'row'
}}
>
<EuiPopOverCheckbox className="CheckboxOuter" color={color}>
<EuiCheckboxGroup
options={sortDirectionOptions}
idToSelectedMap={{ [sortDirection]: true }}
onChange={(id: string) => setSortDirection(id)}
/>
</EuiPopOverCheckbox>
</div>
</EuiPopover>
</Filters>
</FillContainer>
<NumberOfBounties>
Expand Down
1 change: 1 addition & 0 deletions src/people/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export interface OrgBountyHeaderProps {
languageString?: string;
org_uuid?: string;
organizationData: Organization;
direction: string
}
export interface PeopleHeaderProps {
onChangeLanguage: (number) => void;
Expand Down
4 changes: 3 additions & 1 deletion src/people/widgetViews/__tests__/OrgHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const MockProps: OrgBountyHeaderProps = {
Completed: false
},
languageString: '',
direction: 'desc',
org_uuid: 'clf6qmo4nncmf23du7ng',
onChangeStatus: jest.fn(),
onChangeLanguage: jest.fn(),
Expand Down Expand Up @@ -122,7 +123,8 @@ describe('OrgHeader Component', () => {

const updatedCheckboxIdToSelectedMap = {
...MockProps.checkboxIdToSelectedMap,
Open: true
Open: true,
direction: 'desc'
};

rerender(
Expand Down
Loading