-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Allow dynamically sharding the queue through env var (#30)
* ✨ Use dids in all links instead of handles * 🐛 Maintain search params when redirecting * 🐛 Wait for auth before attempting to resolve handle * ✨ Add language filter to moderation queue * ✨ Move lang filter to use tags * 🐛 Unique key for option * ✨ Shard the moderation queue on the client side * ✨ Add tag display and emit form * ✨ Allow multiple language inclusion and exclusion from the language picker * 💄 Fix style of the lang picker button * ⬆️ Upgrade atproto api version * 💄 Add inline comments and refactor * 💄 Improve the language picker styling and add help text * 🐛 Use tag filters in the query key to refresh after lang selection * 🔨 Refactor queue config to env var
- Loading branch information
Showing
6 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,5 @@ next-env.d.ts | |
|
||
# cypress | ||
cypress/videos | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Dropdown } from '@/common/Dropdown' | ||
import { ChevronDownIcon } from '@heroicons/react/20/solid' | ||
import { usePathname, useRouter, useSearchParams } from 'next/navigation' | ||
|
||
type QueueConfig = Record<string, { name: string }> | ||
|
||
const getQueueConfig = () => { | ||
const config = process.env.NEXT_PUBLIC_QUEUE_CONFIG || '{}' | ||
try { | ||
return JSON.parse(config) as QueueConfig | ||
} catch (err) { | ||
return {} | ||
} | ||
} | ||
|
||
export const QUEUES = getQueueConfig() | ||
export const QUEUE_NAMES = Object.keys(QUEUES) | ||
|
||
export const QueueSelector = () => { | ||
const searchParams = useSearchParams() | ||
const router = useRouter() | ||
const pathname = usePathname() | ||
const queueName = searchParams.get('queueName') | ||
|
||
const selectQueue = (queue: string) => () => { | ||
const nextParams = new URLSearchParams(searchParams) | ||
if (queue) { | ||
nextParams.set('queueName', queue) | ||
} else { | ||
nextParams.delete('queueName') | ||
} | ||
router.push((pathname ?? '') + '?' + nextParams.toString()) | ||
} | ||
|
||
// If no queues are configured, just use a static title | ||
if (!QUEUE_NAMES.length) { | ||
return ( | ||
<h3 className="flex items-center text-lg font-medium leading-6 text-gray-900 dark:text-gray-200"> | ||
Queue | ||
</h3> | ||
) | ||
} | ||
|
||
return ( | ||
<Dropdown | ||
containerClassName="inline-block" | ||
className="inline-flex items-center" | ||
items={[ | ||
{ | ||
text: 'All', | ||
onClick: selectQueue(''), | ||
}, | ||
...QUEUE_NAMES.map((q) => ({ | ||
text: QUEUES[q].name, | ||
onClick: selectQueue(q), | ||
})), | ||
]} | ||
> | ||
<h3 className="flex items-center text-lg font-medium leading-6 text-gray-900 dark:text-gray-200"> | ||
{queueName ? `${QUEUES[queueName].name} Queue` : 'Queue'} | ||
<ChevronDownIcon | ||
className="text-gray-900 dark:text-gray-200 h-4 w-4" | ||
aria-hidden="true" | ||
/> | ||
</h3> | ||
</Dropdown> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Next from 'next' | ||
|
||
declare global { | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
NEXT_PUBLIC_PLC_DIRECTORY_URL?: string | ||
NEXT_PUBLIC_QUEUE_CONFIG?: string | ||
} | ||
} | ||
} |