Skip to content

Commit

Permalink
Merge pull request #208 from Enterprise-CMCS/master
Browse files Browse the repository at this point in the history
Release to val
  • Loading branch information
mdial89f authored Nov 28, 2023
2 parents 2517d10 + 430c4de commit 5be1f5f
Show file tree
Hide file tree
Showing 14 changed files with 356 additions and 290 deletions.
24 changes: 16 additions & 8 deletions src/libs/opensearch-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,33 @@ export async function getItem(host:string, index:string, id:string){
}
}

export async function createIndexIfNotExists(host:string, index:string) {
export async function indexExists(host:string, index:string) {
client = client || (await getClient(host));
try {
const indexExists = await client.indices.exists({ index, });
if (!indexExists.body) {
const createResponse = await client.indices.create({
index,
});

console.log('Index created:', createResponse);
if (indexExists.body) {
return true;
} else {
console.log('Index already exists.');
return false;
}
} catch (error) {
console.error('Error creating index:', error);
throw error;
}
}

export async function createIndex(host:string, index:string) {
client = client || (await getClient(host));
try {
const createResponse = await client.indices.create({
index,
});
} catch (error) {
console.error('Error creating index:', error);
throw error;
}
}

export async function updateFieldMapping(host:string, index:string, properties: object) {
client = client || (await getClient(host));
try {
Expand Down
35 changes: 18 additions & 17 deletions src/services/data/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,24 @@ export const handler: Handler = async (event) => {

async function manageIndex() {
try {
const createIndexReponse = await os.createIndexIfNotExists(
process.env.osDomain,
"main"
);
console.log(createIndexReponse);

const updateFieldMappingResponse = await os.updateFieldMapping(
process.env.osDomain,
"main",
{
rais: {
type: "object",
enabled: false,
},
}
);
console.log(updateFieldMappingResponse);
if (!(await os.indexExists(process.env.osDomain, "main"))) {
const createIndexReponse = await os.createIndex(
process.env.osDomain,
"main"
);
console.log(createIndexReponse);
const updateFieldMappingResponse = await os.updateFieldMapping(
process.env.osDomain,
"main",
{
rais: {
type: "object",
enabled: false,
},
}
);
console.log(updateFieldMappingResponse);
}
} catch (error) {
console.log(error);
throw "ERROR: Error occured during index management.";
Expand Down
15 changes: 9 additions & 6 deletions src/services/ui/e2e/tests/home/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ test("has title", async ({ page }) => {
await expect(page).toHaveTitle(/CMS MAKO/);
});

test("see frequently asked questions header when in faq page", async ({ page }) => {
test("see frequently asked questions header when in faq page", async ({
page,
}) => {
await page.goto("/");
const popup = page.waitForEvent("popup");
await page.getByRole("link", { name: "FAQ", exact: true }).click();
const foundFaqHeading = await popup;
await foundFaqHeading.getByRole("heading", { name: "Frequently Asked Questions" })
await foundFaqHeading
.getByRole("heading", { name: "Frequently Asked Questions" })
.isVisible();
expect(foundFaqHeading).toBeTruthy();
});
Expand All @@ -32,8 +35,8 @@ test("see dashboard link when log in", async ({ page }) => {
await page.getByRole("button", { name: "Sign In" }).click();
await page
.getByRole("textbox", { name: "[email protected]" })
.type(testUsers.state);
await page.getByRole("textbox", { name: "Password" }).type(password);
.fill(testUsers.state);
await page.getByRole("textbox", { name: "Password" }).fill(password);
await page.getByRole("button", { name: "submit" }).click();
await page.getByRole("link", { name: "Dashboard" }).click();

Expand All @@ -46,8 +49,8 @@ test("see dashboard link when log in", async ({ page }) => {
test("failed incorrect login username", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Sign In" }).click();
await page.getByRole("textbox", { name: "[email protected]" }).type(".");
await page.getByRole("textbox", { name: "Password" }).type(password);
await page.getByRole("textbox", { name: "[email protected]" }).fill(".");
await page.getByRole("textbox", { name: "Password" }).fill(password);
await page.getByRole("button", { name: "submit" }).click();
await page.locator("#loginErrorMessage").first().isVisible();
});
23 changes: 23 additions & 0 deletions src/services/ui/src/components/Cards/SectionCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FC, ReactNode } from "react";
import { cn } from "@/lib";

interface SectionCardProps {
children: ReactNode;
className?: string;
title: string;
}
export const SectionCard: FC<SectionCardProps> = ({
title,
children,
className,
}: SectionCardProps) => {
return (
<div className={cn("border-2 border-slate-300 w-5/6 p-4", className)}>
<section>
<h1 className="font-bold text-2xl">{title}</h1>
<div className="border-t-2 border-slate-300 w-full mt-2 mb-4" />
<div className="gap-8 flex flex-col">{children}</div>
</section>
</div>
);
};
1 change: 1 addition & 0 deletions src/services/ui/src/components/Cards/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./CardWithTopBorder";
export * from "./SectionCard";
40 changes: 19 additions & 21 deletions src/services/ui/src/components/ExportButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,24 @@ export const ExportButton = <TData extends Record<string, any>>({
};

return (
<>
<Button
variant="ghost"
onClick={async () => {
handleExport(await generateExport());
}}
disabled={loading}
className="hover:bg-transparent h-full flex gap-2"
>
{loading && (
<motion.div
animate={{ rotate: "360deg" }}
transition={{ repeat: Infinity, duration: 0.5 }}
>
<Loader className="w-4 h-4" />
</motion.div>
)}
{!loading && <Download className="w-4 h-4" />}
<span className="prose-sm">Export</span>
</Button>
</>
<Button
variant="outline"
onClick={async () => {
handleExport(await generateExport());
}}
disabled={loading}
className="hover:bg-transparent self-center h-10 flex gap-2"
>
{loading && (
<motion.div
animate={{ rotate: "360deg" }}
transition={{ repeat: Infinity, duration: 0.5 }}
>
<Loader className="w-4 h-4" />
</motion.div>
)}
{!loading && <Download className="w-4 h-4" />}
<span className="prose-sm">Export</span>
</Button>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "../Dialog";
import { Button } from "../Inputs";

type Props = {
export type ConfirmationModalProps = {
open: boolean;
description?: React.ReactNode;
body?: React.ReactNode;
Expand All @@ -21,7 +21,8 @@ type Props = {
acceptButtonVisible?: boolean;
};

export function Modal({
/** A modal with optional Cancel and Accept buttons */
export function ConfirmationModal({
open,
description,
title,
Expand All @@ -32,7 +33,7 @@ export function Modal({
cancelButtonText = "Cancel",
acceptButtonVisible = true,
cancelButtonVisible = true,
}: Props) {
}: ConfirmationModalProps) {
return (
<Dialog open={open} onOpenChange={onCancel}>
<DialogContent className="sm:max-w-[425px]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ export const OsFilterDrawer = () => {
const handleFilterReset = () => resetFilters(params.onSet);
return (
<Sheet open={hook.drawerOpen} onOpenChange={hook.setDrawerState}>
<SheetTrigger>
<div className="flex flex-row gap-2 items-center border-slate-100 px-4">
<SheetTrigger asChild>
<Button
variant="outline"
className="hover:bg-transparent self-center h-10 flex gap-2"
>
<FilterIcon className="w-4 h-4" />
<p className="prose-sm">Filters</p>
</div>
<span className="prose-sm">Filters</span>
</Button>
</SheetTrigger>
<SheetContent className="bg-white overflow-scroll">
<SheetHeader>
Expand Down
Loading

0 comments on commit 5be1f5f

Please sign in to comment.