-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 💄 Handle reviewNone, labeler account display and sticky note more prominent * 🐛 Change icon for reviewNone * 💄 Handle user badge in dark mode * 💄 Show labels with mod service details * 💄 Color code labels based on blur and hide config * 💄 Add ModerationLabel in record and repo view * 🚧 WIP dynamic labeler * ✨ Cleanup * ✨ Allow removing external labeler * 🐛 Fix import * ✨ Add better details for service config placeholder * ✨ Show config and tweak UI based on config * ⬆️ Upgrade @atproto/api version * ✨ Add permission check for team manager UI
- Loading branch information
Showing
14 changed files
with
276 additions
and
26 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
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
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,159 @@ | ||
import { ActionButton } from '@/common/buttons' | ||
import { Card } from '@/common/Card' | ||
import { CopyButton } from '@/common/CopyButton' | ||
import client, { ClientSession } from '@/lib/client' | ||
import { | ||
CheckCircleIcon, | ||
XCircleIcon, | ||
LinkIcon, | ||
GlobeAltIcon, | ||
CloudIcon, | ||
ChatBubbleLeftIcon, | ||
} from '@heroicons/react/24/solid' | ||
import { useState } from 'react' | ||
|
||
const RefetchConfigButton = () => { | ||
const [isRefetching, setIsRefetching] = useState(false) | ||
return ( | ||
<ActionButton | ||
onClick={async () => { | ||
setIsRefetching(true) | ||
await client.refetchServerConfig() | ||
setIsRefetching(false) | ||
window.location.reload() | ||
}} | ||
size="xs" | ||
disabled={isRefetching} | ||
appearance="outlined" | ||
> | ||
{isRefetching ? 'Refetching...' : 'Refetch'} | ||
</ActionButton> | ||
) | ||
} | ||
|
||
export const ServerConfig = ({ session }: { session: ClientSession }) => { | ||
const config = session.serverConfig | ||
if (!config) { | ||
return ( | ||
<div className="flex flex-row justify-between my-4"> | ||
<h4 className="font-medium text-gray-700 dark:text-gray-100"> | ||
No Server Config Found | ||
</h4> | ||
<RefetchConfigButton /> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-row justify-between my-4"> | ||
<h4 className="font-medium text-gray-700 dark:text-gray-100"> | ||
Server Config | ||
</h4> | ||
<RefetchConfigButton /> | ||
</div> | ||
<Card className="mb-4 pb-4"> | ||
<div className="p-2"> | ||
{config.pds && <UrlDisplay label="PDS" url={config.pds} />} | ||
{config.appview && ( | ||
<UrlDisplay label="App View" url={config.appview} /> | ||
)} | ||
{config.blobDivert && ( | ||
<UrlDisplay label="Blob Divert" url={config.blobDivert} /> | ||
)} | ||
{config.chat && <UrlDisplay label="Chat" url={config.chat} />} | ||
<div className="mt-4"> | ||
<h3 className="font-semibold">Permissions</h3> | ||
<ul className="mt-2 list-disc list-inside text-gray-900 dark:text-gray-100"> | ||
{' '} | ||
<PermissionItem | ||
label="Manage Templates" | ||
enabled={config.permissions.canManageTemplates} | ||
/> | ||
<PermissionItem | ||
label="Takedown" | ||
enabled={config.permissions.canTakedown} | ||
/> | ||
<PermissionItem | ||
label="Takedown Feed Generators" | ||
enabled={config.permissions.canTakedownFeedGenerators} | ||
/> | ||
<PermissionItem | ||
label="Label" | ||
enabled={config.permissions.canLabel} | ||
/> | ||
<PermissionItem | ||
label="Manage Chat" | ||
enabled={config.permissions.canManageChat} | ||
/> | ||
<PermissionItem | ||
label="Manage Team" | ||
enabled={config.permissions.canManageTeam} | ||
/> | ||
</ul> | ||
</div> | ||
</div> | ||
</Card> | ||
</> | ||
) | ||
} | ||
|
||
type PermissionItemProps = { | ||
label: string | ||
enabled: boolean | ||
} | ||
|
||
const PermissionItem: React.FC<PermissionItemProps> = ({ label, enabled }) => { | ||
return ( | ||
<li className="flex items-center"> | ||
{enabled ? ( | ||
<CheckCircleIcon className="h-4 w-4 text-green-600" /> | ||
) : ( | ||
<XCircleIcon className="h-4 w-4 text-red-600" /> | ||
)} | ||
<span className="ml-2">{label}</span> | ||
</li> | ||
) | ||
} | ||
|
||
type UrlDisplayProps = { | ||
label: 'App View' | 'PDS' | 'Blob Divert' | 'Chat' | ||
url?: string | ||
} | ||
|
||
const getIcon = (label: UrlDisplayProps['label'] | string) => { | ||
const classNames = 'h-5 w-5 text-gray-800 dark:text-gray-300' | ||
switch (label) { | ||
case 'PDS': | ||
return <LinkIcon className={classNames} /> | ||
case 'App View': | ||
return <GlobeAltIcon className={classNames} /> | ||
case 'Blob Divert': | ||
return <CloudIcon className={classNames} /> | ||
case 'Chat': | ||
return <ChatBubbleLeftIcon className={classNames} /> | ||
default: | ||
return <LinkIcon className={classNames} /> | ||
} | ||
} | ||
|
||
const UrlDisplay: React.FC<UrlDisplayProps> = ({ label, url }) => { | ||
if (!url) return null | ||
return ( | ||
<div className="mb-2 flex items-center"> | ||
{getIcon(label)} | ||
<span className="font-medium ml-2 text-gray-900 dark:text-gray-200"> | ||
{label}: | ||
</span> | ||
<a | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="ml-2 mr-1 text-blue-500 dark:text-blue-400 underline" | ||
> | ||
{url} | ||
</a> | ||
<CopyButton text={url} label={`Copy ${label} URL to clipboard`} /> | ||
</div> | ||
) | ||
} |
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
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
Oops, something went wrong.