Skip to content

Commit

Permalink
Merge pull request #9854 from hicommonwealth/kaleemNeslit.9501.merge_…
Browse files Browse the repository at this point in the history
…all_oveview

Kaleem neslit.9501.merge all oveview
  • Loading branch information
KaleemNeslit authored Nov 13, 2024
2 parents 7a893c8 + 0f68e25 commit ad30a2a
Show file tree
Hide file tree
Showing 8 changed files with 561 additions and 524 deletions.
5 changes: 5 additions & 0 deletions packages/commonwealth/client/scripts/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export enum ThreadFeaturedFilterTypes {
LatestActivity = 'latestActivity',
}

export enum ThreadViewFilterTypes {
All = 'all',
Overview = 'overview',
}

export enum CommentsFeaturedFilterTypes {
Newest = 'newest',
Oldest = 'oldest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
Check,
CheckCircle,
CircleNotch,
CirclesFour,
CirclesThreePlus,
Clipboard,
ClockCounterClockwise,
Expand Down Expand Up @@ -292,6 +293,8 @@ export const iconLookup = {
download: withPhosphorIcon(Download),
downloadSimple: withPhosphorIcon(DownloadSimple),
copySimple: withPhosphorIcon(CopySimple),
viewAll: withPhosphorIcon(Rows),
viewOverView: withPhosphorIcon(CirclesFour),
};

export const customIconLookup = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { matchRoutes, useLocation } from 'react-router-dom';

import 'components/sidebar/index.scss';
import { useCommonNavigate } from 'navigation/helpers';
import { matchRoutes, useLocation } from 'react-router-dom';
import app from 'state';
import { useFetchTopicsQuery } from 'state/api/topics';
import { sidebarStore } from 'state/ui/sidebar';
Expand All @@ -17,14 +16,15 @@ import type {
ToggleTree,
} from './types';

import 'components/sidebar/index.scss';

const resetSidebarState = () => {
if (isWindowSmallInclusive(window.innerWidth)) {
sidebarStore.getState().setMenu({ name: 'default', isVisible: false });
} else {
sidebarStore.getState().setMenu({ name: 'default', isVisible: true });
}
};

function setDiscussionsToggleTree(path: string, toggle: boolean) {
let currentTree = JSON.parse(
localStorage[`${app.activeChainId()}-discussions-toggle-tree`],
Expand All @@ -42,27 +42,20 @@ function setDiscussionsToggleTree(path: string, toggle: boolean) {
localStorage[`${app.activeChainId()}-discussions-toggle-tree`] =
JSON.stringify(newTree);
}

interface DiscussionSectionProps {
isContestAvailable: boolean;
topicIdsIncludedInContest: number[];
}

export const DiscussionSection = ({
isContestAvailable,
topicIdsIncludedInContest,
}: DiscussionSectionProps) => {
const navigate = useCommonNavigate();
const location = useLocation();

const matchesDiscussionsRoute = matchRoutes(
[{ path: '/discussions' }, { path: ':scope/discussions' }],
location,
);
const matchesOverviewRoute = matchRoutes(
[{ path: '/overview' }, { path: ':scope/overview' }],
location,
);
const matchesContestsRoute = matchRoutes(
[{ path: '/contests' }, { path: ':scope/contests' }],
location,
Expand Down Expand Up @@ -124,7 +117,6 @@ export const DiscussionSection = ({
const toggleTreeState = JSON.parse(
localStorage[`${app.activeChainId()}-discussions-toggle-tree`],
);

const discussionsGroupData: SectionGroupAttrs[] = [
{
title: 'All',
Expand Down Expand Up @@ -171,22 +163,6 @@ export const DiscussionSection = ({
},
]
: []),
{
title: 'Overview',
containsChildren: false,
hasDefaultToggle: false,
isVisible: true,
isUpdated: true,
isActive: !!matchesOverviewRoute,
onClick: (e, toggle: boolean) => {
e.preventDefault();
resetSidebarState();
handleRedirectClicks(navigate, e, `/overview`, communityId, () => {
setDiscussionsToggleTree(`children.Overview.toggledState`, toggle);
});
},
displayData: null,
},
];

for (const topic of topics) {
Expand Down
Loading

0 comments on commit ad30a2a

Please sign in to comment.