Skip to content

Commit

Permalink
wip(web/actionModal): mostly done
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Mar 31, 2024
1 parent 0f4d66b commit 75162f4
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 231 deletions.
1 change: 0 additions & 1 deletion core/webroutes/history/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default async function HistorySearch(ctx: AuthedCtx) {
//filter the actions by the simple filters (lightweight)
const effectiveTypeFilter = typeof filterbyType === 'string' && filterbyType.length ? filterbyType : undefined;
const effectiveAdminFilter = typeof filterbyAdmin === 'string' && filterbyAdmin.length ? filterbyAdmin : undefined;
console.dir({ effectiveTypeFilter, effectiveAdminFilter });
if (effectiveTypeFilter || effectiveAdminFilter) {
chain = chain.filter((a) => {
if (effectiveTypeFilter && a.type !== effectiveTypeFilter) {
Expand Down
22 changes: 8 additions & 14 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [x] NEW PAGE: History
- [ ] Create modal for history actions with full details
- [] modify HistoryTab -> HistoryItem to open the action modal on item click, remove revoke/perms logic
- [ ] Migrate `/database/` routes to `/history` (update panel, nui, web!)
- [ ] Add StatisticsManager tracking for players/actions search duration (QuantileArray)
- [ ] fix disallowed intents message

Expand Down Expand Up @@ -247,6 +248,13 @@ Master Actions:
- clean database - "bulk changes" button at the players page
- revoke whitelists - button to whitelist pages

Admin manager:
- stats on admins
- total count of bans/warns
- counts of bans/warns in the last 7, 14, 28d
- revocation %
- bans/warns %


=======================================================================

Expand Down Expand Up @@ -446,13 +454,11 @@ teste:
apertar f1 e ver se aparece a mensagem de perms

# TODO: sooner than later
- [ ] Add a tracking for % of redm/fivem/libertym servers to txTracker
- [ ] maybe add some debug logging to `AdminVault.checkAdminsFile()`, to find out why so many people are having issues with their logins
- maybe even add to the login failed page something like "admin file was reset or modified XXX time ago"
- [ ] server logger add events/min average
- [ ] no duplicated id type in bans? preparing for the new db migration
- [ ] `cfg cyclical 'exec' command detected to file` should be blocking instead of warning. Beware that this is not trivial without also turning missing exec target read error also being error
- [ ] maybe some sort of lockfile to admins.json file which would disable admin manager?



Expand Down Expand Up @@ -679,18 +685,6 @@ If patch, show update notification immediately (especially important to quick-fi
If minor, randomize a delay between 0~24h.
If patch, randomize a delay 0~72h.

Update event idea (not yet greenlit):
- A box similar to the fxserver update one;
- The major/minor updates will have a discord stage event, patches won't;
- Will get the next event date + type (major/minor) through some api (maybe a regex-able string in the GH releases page);
- The pre-event notifications will have a live "in xx time" type countdown
- 2 days before it will show a yellow warning;
- 1 hour before it will become a glowing green box;
- 1 hour after the event start it will become a red update box with generic message, or blue if it's just a patch;
- Note: regarding the changelog part, bubble asked me to ignore for now (may/13) but will talk again somewhen;



### TP:
https://freesound.org/search/?q=teleport&page=6#sound
https://freesound.org/people/Dpoggioli/sounds/196907/
Expand Down
12 changes: 7 additions & 5 deletions panel/src/layout/ActionModal/ActionIdsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function IdsBlock({ title, emptyMessage, ids, isSmaller }: IdsBlockProps) {
const [hasCopiedIds, setHasCopiedIds] = useState(false);

const handleCopyIds = () => {
if(!ids) return;
if (!ids) return;
copyToClipboard(ids.join('\n')).then((res) => {
if (res !== false) {
setHasCopiedIds(true);
Expand All @@ -29,6 +29,7 @@ function IdsBlock({ title, emptyMessage, ids, isSmaller }: IdsBlockProps) {
});
});
}
const hasIdsAvailable = Array.isArray(ids) && ids.length;

return <div>
<div className="flex justify-between items-center pb-1">
Expand All @@ -45,12 +46,13 @@ function IdsBlock({ title, emptyMessage, ids, isSmaller }: IdsBlockProps) {
</div>
<p className={cn(
"font-mono break-all whitespace-pre-wrap border rounded divide-y divide-border/50 text-muted-foreground",
isSmaller ? "text-2xs leading-5 font-extralight tracking-widest" : "text-xs leading-6 tracking-wider"
hasIdsAvailable && isSmaller ? "text-2xs leading-5 font-extralight tracking-widest" : "text-xs leading-6 tracking-wider"
)}>
{!Array.isArray(ids) || ids.length === 0 && <span className="block px-1 opacity-50 italic">{emptyMessage}</span>}
{ids!.map((id) => (
{hasIdsAvailable ? ids.map((id) => (
<span key={id} className="block px-1 font-semibold">{id}</span>
))}
)) : (
<span className="block px-1 opacity-50 italic">{emptyMessage}</span>
)}
</p>
</div>
}
Expand Down
5 changes: 2 additions & 3 deletions panel/src/layout/ActionModal/ActionInfoTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ function ActionReasonBox({ actionReason }: { actionReason: string }) {
const [textAreaLines, setTextAreaLines] = useState(calcTextAreaLines(actionReason));

return <>
<Label htmlFor="playerNotes">
<Label htmlFor="actionReason">
Reason:
</Label>
<Textarea
ref={textAreaRef}
id="playerNotes"
id="actionReason"
className="w-full mt-1"
readOnly={true}
value={actionReason}
Expand Down Expand Up @@ -82,7 +82,6 @@ export default function ActionInfoTab({ actionId, action, setSelectedTab, refres
<dt className="text-sm font-medium leading-6 text-muted-foreground">Status</dt>
<dd className="text-sm leading-6 col-span-2 mt-0">FIXME:</dd>
</div>

</dl>

<ActionReasonBox actionReason={action.reason} />
Expand Down
30 changes: 14 additions & 16 deletions panel/src/layout/ActionModal/ActionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,36 @@ import {
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { useActionModalStateValue } from "@/hooks/actionModal";
import { InfoIcon, ListIcon, HistoryIcon, GavelIcon, PenLineIcon } from "lucide-react";
import { InfoIcon, ListIcon, Undo2Icon } from "lucide-react";
import { useEffect, useState } from "react";
import { ScrollArea } from "@/components/ui/scroll-area";
import GenericSpinner from "@/components/GenericSpinner";
import { cn } from "@/lib/utils";
import { useBackendApi } from "@/hooks/fetch";
import ActionModalFooter from "./ActionModalFooter";
import ModalCentralMessage from "@/components/ModalCentralMessage";
import { HistoryActionModalResp, HistoryActionModalSuccess } from "@shared/historyApiTypes";
import ActionIdsTab from "./ActionIdsTab";
import ActionInfoTab from "./ActionInfoTab";
import ActionModifyTab from "./ActionModifyTab";


const modalTabs = [
{
title: 'Info',
icon: <InfoIcon className="mr-2 h-5 w-5 hidden xs:block" />,
},
//Maybe in the future for logs of changes?
// {
// title: 'History',
// icon: <HistoryIcon className="mr-2 h-5 w-5 hidden xs:block" />,
// },
{
title: 'IDs',
icon: <ListIcon className="mr-2 h-5 w-5 hidden xs:block" />,
},
// {
// title: 'Edit',
// icon: <PenLineIcon className="mr-2 h-5 w-5 hidden xs:block" />,
// // className: 'hover:bg-destructive hover:text-destructive-foreground',
// }
{
//In the future, when adding "edit" and "remove" to the modal, join with "revoke" in a tab bellow
// title: 'Modify',
// icon: <EraserIcon className="mr-2 h-5 w-5 hidden xs:block" />,
title: 'Revoke',
icon: <Undo2Icon className="mr-2 h-5 w-5 hidden xs:block" />,
className: 'hover:bg-destructive hover:text-destructive-foreground',
},
]


Expand Down Expand Up @@ -164,14 +162,14 @@ export default function ActionModal() {
{selectedTab === 'IDs' && <ActionIdsTab
action={modalData.action}
/>}
{selectedTab === 'Revoke' && <ActionModifyTab
action={modalData.action}
refreshModalData={refreshModalData}
/>}
</>
)}
</ScrollArea>
</div>
<ActionModalFooter
actionRef={actionRef!}
action={modalData?.action}
/>
</DialogContent>
</Dialog>
);
Expand Down
175 changes: 0 additions & 175 deletions panel/src/layout/ActionModal/ActionModalFooter.tsx

This file was deleted.

Loading

0 comments on commit 75162f4

Please sign in to comment.