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

Fix/fix table bugs #34

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 ags-validator-app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default function Page() {
</p>
<RegisterForm />
<div className="flex justify-end">
<Link className="text-xs" href="/privacy">
<Link className="text-xs" href="/privacy" target="_blank">
Privacy Policy
</Link>
</div>
Expand Down
12 changes: 7 additions & 5 deletions ags-validator-app/app/privacy/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export default function Page() {
return (
<div className="flex flex-col gap-10 mx-auto py-10 px-4">
<div className="flex flex-col gap-10 mx-auto py-10 px-4 max-w-prose">
<h1 className="text-3xl font-bold mb-4">Privacy Policy</h1>
<p className="text-sm text-gray-600">Last updated October 25, 2024</p>
<p className="text-sm text-accent-foreground">
Last updated October 25, 2024
</p>

<section className="mt-6">
<p>
Expand All @@ -17,7 +19,7 @@ export default function Page() {
Visit our website at{" "}
<a
href="https://www.validator.groundup.cloud"
className="text-blue-500"
className="text-primary"
>
www.validator.groundup.cloud
</a>
Expand All @@ -33,7 +35,7 @@ export default function Page() {
understand your privacy rights and choices. If you do not agree with
our policies and practices, please do not use our Services. If you
still have any questions or concerns, please contact us at{" "}
<a href="mailto:james@groundup.cloud" className="text-blue-500">
<a href="mailto:james@groundup.cloud" className="text-primary">
james@groundup.cloud
</a>
.
Expand Down Expand Up @@ -81,7 +83,7 @@ export default function Page() {
</li>
<li>
<strong>How do you exercise your rights?</strong> Contact us at{" "}
<a href="mailto:james@groundup.cloud" className="text-blue-500">
<a href="mailto:james@groundup.cloud" className="text-primary">
james@groundup.cloud
</a>
.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { useAppDispatch } from "@/lib/redux/hooks";
import { applySetRawDataEffect, setRawData } from "@/lib/redux/ags";
import { track } from "@vercel/analytics";

export default function AGSUpload() {
interface Props {
setTabsViewValue: React.Dispatch<React.SetStateAction<string>>;
}

export default function AGSUpload({ setTabsViewValue }: Props) {
const dispatch = useAppDispatch();

// Handle file input change
Expand All @@ -17,6 +21,7 @@ export default function AGSUpload() {
if (selectedFile) {
const reader = new FileReader();
reader.onload = (e) => {
setTabsViewValue("text");
const content = e.target?.result;

// get size of file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ const GridView: React.FC<Props> = ({

const onRowAppended = useCallback(() => {
dispatch(addRow({ group: group.name }));
dispatch(applySetRowDataEffect());
}, [dispatch, group.name]);

useEffect(() => {
Expand Down
62 changes: 44 additions & 18 deletions ags-validator-app/components/validator/validator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import ViewToolbar from "./ViewToolbar";
import { track } from "@vercel/analytics";
import { useAppDispatch } from "@/lib/redux/hooks";
import { applySetRowDataEffect, setDictionaryVersion } from "@/lib/redux/ags";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "../ui/tooltip";

const agsDictOptions = [
{ value: "v4_0_3", label: "4.0.3" },
Expand Down Expand Up @@ -68,15 +74,15 @@ export default function Validator() {
setSelectedGroup(firstKey);
}
}
}, [parsedAgs, selectedGroup, setSelectedGroup]);
}, [parsedAgs, selectedGroup, setSelectedGroup, setTabsViewValue]);

return (
<div className="flex justify-center w-full bg-muted rounded-t-xl border shadow-inner">
<div className="flex flex-col p-4 max-w-500 w-full gap-4">
<Card className="p-4">
<CardTitle className="text-lg">AGS Options</CardTitle>
<CardContent className="flex items-start sm:items-end gap-4 py-4 px-0 sm:flex-row flex-col">
<AGSUpload />
<AGSUpload setTabsViewValue={setTabsViewValue} />
<AutoComplete
options={agsDictOptions}
selectedOption={agsDictVersion}
Expand Down Expand Up @@ -114,19 +120,36 @@ export default function Validator() {
>
<TabsTrigger
value="text"
className="data-[state=active]:bg-accent h-full rounded-l-md rounded-r-none w-24 border-r hover:bg-accent"
className="data-[state=active]:bg-accent h-full rounded-tl-md rounded-r-none rounded-b-none w-24 border-r hover:bg-accent"
>
<BsFileEarmarkText className="mr-2 h-4 w-4" />
Text
</TabsTrigger>
<TabsTrigger
disabled={parsedAgs === undefined}
value="tables"
className="data-[state=active]:bg-accent h-full rounded-r-md rounded-l-none w-24 hover:bg-accent"
>
<BsTable className="mr-2 h-4 w-4" />
Tables
</TabsTrigger>

<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
{/* wrapping in div so can have tooltip on hover when disabled */}
<div className=" h-full">
<TabsTrigger
disabled={parsedAgs === undefined}
value="tables"
className="data-[state=active]:bg-accent h-full rounded-tr-md rounded-l-none rounded-b-none w-24 hover:bg-accent "
>
<BsTable className="mr-2 h-4 w-4" />
Tables
</TabsTrigger>
</div>
</TooltipTrigger>

{agsData !== "" && parsedAgs === undefined && (
<TooltipContent>
Current errors must be resolved before viewing as
tables
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
</TabsList>
</div>
<TabsContent value="text" className="min-h-0 grow">
Expand All @@ -143,13 +166,16 @@ export default function Validator() {
selectedGroup={selectedGroup}
setSelection={setSelection}
/>
<GridView
groupName={selectedGroup}
setGoToErrorCallback={setGoToErrorCallback}
setSelectedRows={setSelectedRows}
selection={selection}
setSelection={setSelection}
/>

{parsedAgs && (
<GridView
groupName={selectedGroup}
setGoToErrorCallback={setGoToErrorCallback}
setSelectedRows={setSelectedRows}
selection={selection}
setSelection={setSelection}
/>
)}
</div>
</TabsContent>
</Tabs>
Expand Down
13 changes: 7 additions & 6 deletions ags-validator-app/lib/redux/ags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export const agsSlice = createSlice({

setRawData: (state, action: PayloadAction<string>) => {
state.rawData = action.payload;
// clear the parsed data when the raw data changes
state.parsedAgsNormalized = undefined;
},

deleteRows: (
Expand Down Expand Up @@ -252,12 +254,11 @@ export const agsSlice = createSlice({
state.future = [];
}

const lineNumberLast =
Math.max(
...Object.keys(
state.parsedAgsNormalized[action.payload.group].rows
).map((lineNumber) => parseInt(lineNumber))
) + 1;
const lineNumberLast = Math.max(
...Object.keys(
state.parsedAgsNormalized[action.payload.group].rows
).map((lineNumber) => parseInt(lineNumber))
);

const newRow = {
data: Object.fromEntries(headings.map((heading) => [heading, ""])),
Expand Down
Loading