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

Development #199

Merged
merged 17 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6e44d11
style(subplebbits): replace edit button with settings
plebeius-eth Jan 25, 2024
8216994
feat(subplebbit settings): allow to define custom challenges in defau…
plebeius-eth Jan 25, 2024
052aad9
feat(sidebar): add dev version commit ref with link to the commit
plebeius-eth Jan 25, 2024
9c67880
Update subplebbit-settings.module.css
plebeius-eth Jan 25, 2024
c2c68be
feat(subplebbit settings): allow to define exceptions for each challe…
plebeius-eth Jan 25, 2024
a5c9793
fix undefined
plebeius-eth Jan 25, 2024
7dfc053
feat(subplebbits): add filtering by user role in 'my communities' tab…
plebeius-eth Jan 25, 2024
2899ae7
Merge pull request #198 from plebbit/master
plebeius-eth Jan 25, 2024
df427e7
chore(package.json): upgrade plebbit-react-hooks
plebeius-eth Jan 26, 2024
fcc3220
style(subplebbits): improve design with expanded description, online …
plebeius-eth Jan 26, 2024
8f941c1
fix(time utils): show 1 minute if 1.x minutes
plebeius-eth Jan 26, 2024
c9c67fd
style(subplebbits): show description by default on desktop
plebeius-eth Jan 26, 2024
4aed92f
chore(submit): remove custom error message for pubsub providers, does…
plebeius-eth Jan 26, 2024
1083540
refactor(header): change routing, tabs and links to communities page
plebeius-eth Jan 26, 2024
e35e215
refactor(view utils): remove unnecessary function
plebeius-eth Jan 26, 2024
fcdb478
feat(subplebbits): add 'passed' and 'rejected' tabs to vote page
plebeius-eth Jan 26, 2024
c44a352
prevent linking to unfinished pages
plebeius-eth Jan 26, 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 @@ -6,7 +6,7 @@
"private": true,
"dependencies": {
"@floating-ui/react": "0.26.1",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#57f8891697134e8aa65f286ffd8bdbda9a6bd512",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#80f19b488013cf386f4926fefb5790c79a3b9b96",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "13.0.0",
"@testing-library/user-event": "13.2.1",
Expand Down
11 changes: 7 additions & 4 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ function App() {
<Route path='/inbox/postreplies' element={<Inbox />} />

<Route path='/communities' element={<Subplebbits />} />
<Route path='/communities/mine' element={<Subplebbits />} />
<Route path='/communities/mine/subscriber' element={<Subplebbits />} />
<Route path='/communities/mine/contributor' element={<Subplebbits />} />
<Route path='/communities/mine/moderator' element={<Subplebbits />} />
<Route path='/communities/subscriber' element={<Subplebbits />} />
<Route path='/communities/moderator' element={<Subplebbits />} />
<Route path='/communities/admin' element={<Subplebbits />} />
<Route path='/communities/owner' element={<Subplebbits />} />
<Route path='/communities/vote' element={<Subplebbits />} />
<Route path='/communities/vote/passed' element={<Subplebbits />} />
<Route path='/communities/vote/rejected' element={<Subplebbits />} />
</Route>
</Route>
</Routes>
Expand Down
32 changes: 16 additions & 16 deletions src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import {
isSubplebbitSettingsView,
isSubplebbitSubmitView,
isSubplebbitsView,
isSubplebbitsMineView,
isSubplebbitsMineSubscriberView,
isSubplebbitsMineModeratorView,
isSubplebbitsSubscriberView,
isSubplebbitsModeratorView,
isSubplebbitsAdminView,
isSubplebbitsOwnerView,
isProfileUpvotedView,
} from '../../lib/utils/view-utils';
import useTheme from '../../hooks/use-theme';
Expand Down Expand Up @@ -202,27 +203,26 @@ const InboxHeaderTabs = () => {
const SubplebbitsHeaderTabs = () => {
const { t } = useTranslation();
const location = useLocation();
const isInSubplebbitsMineSubscriberView = isSubplebbitsMineSubscriberView(location.pathname);
const isInSubplebbitsMineModeratorView = isSubplebbitsMineModeratorView(location.pathname);
const isInSubplebbitsView = isSubplebbitsView(location.pathname) && !isInSubplebbitsMineSubscriberView && !isInSubplebbitsMineModeratorView;
const isInSubplebbitsMineView = isSubplebbitsMineView(location.pathname);
const isInSubplebbitsSubscriberView = isSubplebbitsSubscriberView(location.pathname);
const isInSubplebbitsModeratorView = isSubplebbitsModeratorView(location.pathname);
const isInSubplebbitsAdminView = isSubplebbitsAdminView(location.pathname);
const isInSubplebbitsOwnerView = isSubplebbitsOwnerView(location.pathname);
const isInSubplebbitsView =
isSubplebbitsView(location.pathname) && !isInSubplebbitsSubscriberView && !isInSubplebbitsModeratorView && !isInSubplebbitsAdminView && !isInSubplebbitsOwnerView;

return (
<>
<li>
<Link to={'/communities'} className={`${isInSubplebbitsView ? styles.selected : styles.choice}`}>
{t('approved')}
</Link>
</li>
<li>
<Link to={'/communities'} className={styles.choice} onClick={(e) => e.preventDefault()}>
{t('proposed')}
<Link to={'/communities/vote'} className={`${isInSubplebbitsView ? styles.selected : styles.choice}`}>
{t('vote')}
</Link>
</li>
<li>
<Link
to={'/communities/mine'}
className={isInSubplebbitsMineView || isInSubplebbitsMineModeratorView || isInSubplebbitsMineSubscriberView ? styles.selected : styles.choice}
to={'/communities/subscriber'}
className={
isInSubplebbitsSubscriberView || isInSubplebbitsModeratorView || isInSubplebbitsAdminView || isInSubplebbitsOwnerView ? styles.selected : styles.choice
}
>
{t('my_communities')}
</Link>
Expand Down
9 changes: 9 additions & 0 deletions src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SearchBar from '../search-bar';
import SubscribeButton from '../subscribe-button';
import packageJson from '../../../package.json';
const { version } = packageJson;
const commitRef = process.env.REACT_APP_COMMIT_REF;

interface sidebarProps {
address?: string | undefined;
Expand Down Expand Up @@ -267,6 +268,14 @@ const Sidebar = ({ address, cid, createdAt, description, downvoteCount = 0, role
<a href={`https://github.com/plebbit/seedit/releases/tag/v${version}`} target='_blank' rel='noopener noreferrer'>
v{version}
</a>
{commitRef && (
<>
{' '}
<a href={`https://github.com/plebbit/seedit/commit/${commitRef}`} target='_blank' rel='noopener noreferrer'>
({commitRef.slice(0, 7)})
</a>
</>
)}
</li>
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/topbar/topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const TopBar = () => {
</Link>
))}
{subscriptions?.length > 0 && (
<Link to='/communities' className={`${styles.dropdownChoice} ${styles.editSubscriptions}`}>
<Link to='/communities/subscriber' className={`${styles.dropdownChoice} ${styles.editSubscriptions}`}>
{t('edit_subscriptions')}
</Link>
)}
Expand Down Expand Up @@ -169,7 +169,7 @@ const TopBar = () => {
))}
</ul>
</div>
<Link to='/communities' className={styles.moreLink}>
<Link to='/communities/vote' className={styles.moreLink}>
{t('edit')} »
</Link>
</div>
Expand Down
19 changes: 19 additions & 0 deletions src/lib/utils/challenge-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ export const getDefaultExclude = () => {
];
};

export const getDefaultChallengeDescription = (challengeType: string) => {
switch (challengeType) {
case 'text-math':
return 'Ask a plain text math question, insecure, use ONLY for testing.';
case 'captcha-canvas-v3':
return 'Make a custom image captcha';
case 'fail':
return 'A challenge that automatically fails with a custom error message.';
case 'blacklist':
return 'Blacklist author addresses.';
case 'question':
return "Ask a question, like 'What is the password?'";
case 'evm-contract-call':
return 'The response from an EVM contract call passes a condition, e.g. a token balance challenge.';
default:
return '';
}
};

export const getDefaultOptionInputs = (challengeType: string) => {
switch (challengeType) {
case 'text-math':
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/time-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const getFormattedTimeAgo = (unixTimestamp: number): string => {
const timeDifference = currentTime - unixTimestamp;
const t = i18next.t;

if (timeDifference < 60) {
if (timeDifference < 120) {
return t('time_1_minute_ago');
}
if (timeDifference < 3600) {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const getFormattedTimeDuration = (unixTimestamp: number): string => {
const timeDifference = currentTime - unixTimestamp;
const t = i18next.t;

if (timeDifference < 60) {
if (timeDifference < 120) {
return t('time_1_minute');
}
if (timeDifference < 3600) {
Expand Down
40 changes: 26 additions & 14 deletions src/lib/utils/view-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export const isAuthorSubmittedView = (pathname: string, params: ParamsType): boo
return pathname === `/u/${params.authorAddress}/c/${params.commentCid}/submitted`;
};

export const isProfileDownvotedView = (pathname: string): boolean => {
return pathname === '/profile/downvoted';
};

export const isHomeView = (pathname: string, params: ParamsType): boolean => {
return pathname === '/' || sortTypes.includes(pathname) || (timeFilterNames.includes(params.timeFilterName as TimeFilterKey) && !pathname.startsWith('/p/'));
};
Expand Down Expand Up @@ -100,6 +96,14 @@ export const isProfileSubmittedView = (pathname: string): boolean => {
return pathname.startsWith('/profile/submitted');
};

export const isProfileDownvotedView = (pathname: string): boolean => {
return pathname === '/profile/downvoted';
};

export const isProfileUpvotedView = (pathname: string): boolean => {
return pathname === '/profile/upvoted';
};

export const isSettingsView = (pathname: string): boolean => {
return pathname === '/settings';
};
Expand All @@ -124,22 +128,30 @@ export const isSubplebbitsView = (pathname: string): boolean => {
return pathname.startsWith('/communities');
};

export const isSubplebbitsMineView = (pathname: string): boolean => {
return pathname === '/communities/mine';
export const isSubplebbitsSubscriberView = (pathname: string): boolean => {
return pathname === '/communities/subscriber';
};

export const isSubplebbitsMineSubscriberView = (pathname: string): boolean => {
return pathname === '/communities/mine' || pathname === '/communities/mine/subscriber';
export const isSubplebbitsModeratorView = (pathname: string): boolean => {
return pathname === '/communities/moderator';
};

export const isSubplebbitsMineContributorView = (pathname: string): boolean => {
return pathname === '/communities/mine/contributor';
export const isSubplebbitsAdminView = (pathname: string): boolean => {
return pathname === '/communities/admin';
};

export const isSubplebbitsMineModeratorView = (pathname: string): boolean => {
return pathname === '/communities/mine/moderator';
export const isSubplebbitsOwnerView = (pathname: string): boolean => {
return pathname === '/communities/owner';
};

export const isProfileUpvotedView = (pathname: string): boolean => {
return pathname === '/profile/upvoted';
export const isSubplebbitsVoteView = (pathname: string): boolean => {
return pathname === '/communities/vote';
};

export const isSubplebbitsVotePassedView = (pathname: string): boolean => {
return pathname === '/communities/vote/passed';
};

export const isSubplebbitsVoteRejectedView = (pathname: string): boolean => {
return pathname === '/communities/vote/rejected';
};
5 changes: 0 additions & 5 deletions src/views/submit/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ const useSubmitStore = create<SubmitState>((set) => ({
onChallengeVerification: alertChallengeVerificationFailed,
onError: (error: Error) => {
console.error(error);
// TODO: remove this explanation when pubsub providers uptime is fixed:
let errorMessage = error.message;
if (errorMessage === 'The challenge request has been published over the pubsub topic but no response was received') {
errorMessage +=
'. This means seedit web is currently offline, download seedit desktop which is fully peer-to-peer: https://github.com/plebbit/seedit/releases/latest';
}
alert(errorMessage);
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
}

.box, .boxInput {
width: calc(100vw - 35px);
width: calc(100vw - 20px);
}

.boxInput input, .boxInput textarea {
Expand Down
Loading