-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAT-7790: add function tab to cql builder (#378)
* MAT-7790: add function tab to cql builder * MAT-7790: add test for function tab
- Loading branch information
1 parent
473f55f
commit 5ac33f6
Showing
14 changed files
with
586 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import { MadieDialog } from "@madie/madie-design-system/dist/react"; | ||
import ErrorIcon from "@mui/icons-material/Error"; | ||
|
||
const ConfirmationDialog = ({ open, onClose, onSubmit }) => { | ||
return ( | ||
<MadieDialog | ||
title="Are you sure?" | ||
dialogProps={{ | ||
onClose, | ||
open, | ||
}} | ||
cancelButtonProps={{ | ||
variant: "secondary", | ||
cancelText: "Cancel", | ||
"data-testid": "confirmation-cancel-button", | ||
}} | ||
continueButtonProps={{ | ||
variant: "cyan", | ||
type: "submit", | ||
"data-testid": "confirmation-clear-button", | ||
continueText: "Clear", | ||
onClick: onSubmit, | ||
}} | ||
> | ||
<div id="discard-changes-dialog-body"> | ||
<section className="dialog-warning-body"> | ||
<p>You are about to clear this function, including all arguments.</p> | ||
</section> | ||
<section className="dialog-warning-action"> | ||
<ErrorIcon /> | ||
<p>This action cannot be undone!</p> | ||
</section> | ||
</div> | ||
</MadieDialog> | ||
); | ||
}; | ||
|
||
export default ConfirmationDialog; |
46 changes: 46 additions & 0 deletions
46
src/CqlBuilderPanel/functionsSection/FunctionSectionNavTabs.tsx
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,46 @@ | ||
import React from "react"; | ||
import { Tabs, Tab } from "@madie/madie-design-system/dist/react"; | ||
|
||
export interface NavTabProps { | ||
activeTab: string; | ||
setActiveTab: (value: string) => void; | ||
functionCount: number; | ||
loading: boolean; | ||
} | ||
|
||
export default function FunctionSectionNavTabs(props: NavTabProps) { | ||
const { activeTab, setActiveTab, functionCount, loading } = props; | ||
|
||
return ( | ||
<div style={{ borderBottom: "1px solid #b0b0b0" }} tw="flex flex-row"> | ||
<Tabs | ||
id="function-tabs" | ||
value={activeTab} | ||
onChange={(e, v) => { | ||
setActiveTab(v); | ||
}} | ||
type="B" | ||
visibleScrollbar | ||
variant="scrollable" | ||
scrollButtons={false} | ||
> | ||
<Tab | ||
tabIndex={0} | ||
aria-label="Function" | ||
type="B" | ||
label="Function" | ||
data-testid="function-tab" | ||
value="function" | ||
/> | ||
<Tab | ||
tabIndex={0} | ||
aria-label="Saved Functions" | ||
type="B" | ||
label={`Saved Functions ${!loading ? "(" + functionCount + ")" : ""}`} | ||
data-testid="saved-functions-tab" | ||
value="saved-functions" | ||
/> | ||
</Tabs> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#function-form { | ||
font-family: Rubik, sans-serif; | ||
grid-column: span 5 / span 14; | ||
display: flex; | ||
flex-direction: column; | ||
padding-top: 32px; | ||
textArea { | ||
box-sizing: border-box; | ||
border-radius: 3px; | ||
border: solid 1px #8c8c8c; | ||
background-color: #fff; | ||
opacity: 1; | ||
height: 100%; | ||
font-size: 14px; | ||
font-weight: 400; | ||
resize: both; | ||
color: #333; | ||
&::placeholder { | ||
color: #717171; | ||
opacity: 1; | ||
} | ||
} | ||
> .content { | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
position: relative; | ||
.subTitle { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: baseline; | ||
padding-bottom: 8px; | ||
margin-bottom: 33px; | ||
border-bottom: solid 1px; | ||
position: relative; | ||
h2 { | ||
font-size: 24px; | ||
border: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
} | ||
h3 { | ||
font-weight: 400; | ||
font-size: 32px; | ||
line-height: 48px; | ||
display: flex; | ||
flex-direction: row; | ||
padding-bottom: 8px; | ||
border-bottom: solid 1px #8c8c8c; | ||
} | ||
label:not(.Mui-disabled) { | ||
font-weight: 500; | ||
font-size: 14px; | ||
line-height: 17px; | ||
color: #333333; | ||
text-transform: none; | ||
margin-bottom: 7px; | ||
} | ||
} | ||
.form-actions { | ||
display: flex; | ||
flex-direction: row; | ||
min-width: 100%; | ||
justify-content: end; | ||
> .cancel-button { | ||
margin-top: 1rem; | ||
margin-right: 32px; | ||
} | ||
> button[type="submit"] { | ||
margin-top: 0; | ||
} | ||
} | ||
.left-box { | ||
width: 40%; | ||
float: left; | ||
} | ||
.right-box { | ||
width: 55%; | ||
font-family: Rubik, sans-serif; | ||
margin-left: 30px; | ||
height: 80%; | ||
float: right; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/CqlBuilderPanel/functionsSection/FunctionsSection.test.tsx
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,44 @@ | ||
import * as React from "react"; | ||
import { render, screen, waitFor, act } from "@testing-library/react"; | ||
import FunctionsSection from "./FunctionsSection"; | ||
import userEvent from "@testing-library/user-event"; | ||
|
||
const props = { | ||
canEdit: true, | ||
loading: false, | ||
handleApplyFunction: jest.fn(), | ||
}; | ||
|
||
describe("FunctionsSection", () => { | ||
it("Should display function section", async () => { | ||
render(<FunctionsSection {...props} />); | ||
const funct = await screen.findByTestId("function-tab"); | ||
const savedfunctions = await screen.findByText("Saved Functions (0)"); | ||
expect(funct).toBeInTheDocument(); | ||
expect(savedfunctions).toBeInTheDocument(); | ||
await waitFor(() => { | ||
expect(funct).toHaveAttribute("aria-selected", "true"); | ||
}); | ||
await waitFor(() => { | ||
expect(savedfunctions).toHaveAttribute("aria-selected", "false"); | ||
}); | ||
}); | ||
|
||
it("Should display saved function section", async () => { | ||
render(<FunctionsSection {...props} />); | ||
const funct = await screen.findByTestId("function-tab"); | ||
const savedfunctions = await screen.findByText("Saved Functions (0)"); | ||
expect(funct).toBeInTheDocument(); | ||
expect(savedfunctions).toBeInTheDocument(); | ||
await waitFor(() => { | ||
expect(funct).toHaveAttribute("aria-selected", "true"); | ||
}); | ||
await waitFor(() => { | ||
expect(savedfunctions).toHaveAttribute("aria-selected", "false"); | ||
}); | ||
userEvent.click(savedfunctions); | ||
await waitFor(() => { | ||
expect(savedfunctions).toHaveAttribute("aria-selected", "true"); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.