-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2223 from nulib/deploy/staging
Deploy Meadow v1.7.1 to production
- Loading branch information
Showing
60 changed files
with
1,741 additions
and
1,146 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
18 changes: 13 additions & 5 deletions
18
assets/js/components/BatchEdit/Administrative/ProjectMetadata.jsx
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,58 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { IconArrowDown } from "@js/components/Icon"; | ||
import classNames from "classnames"; | ||
|
||
function UIDropdown({ | ||
id = "ui-dropdown", | ||
isRight, | ||
label = "Actions", | ||
children, | ||
...restProps | ||
}) { | ||
const [isActive, setIsActive] = React.useState(); | ||
|
||
return ( | ||
<div | ||
className={classNames(["dropdown"], { | ||
"is-active": isActive, | ||
"is-right": isRight, | ||
})} | ||
{...restProps} | ||
> | ||
<div className="dropdown-trigger" data-testid="dropdown-trigger"> | ||
<button | ||
onClick={() => setIsActive(!isActive)} | ||
className="button" | ||
aria-haspopup="true" | ||
aria-controls={id} | ||
data-testid="dropdown-trigger-button" | ||
> | ||
<span>{label}</span> | ||
<span className="icon is-small"> | ||
<IconArrowDown aria-hidden="true" /> | ||
</span> | ||
</button> | ||
</div> | ||
<div | ||
className="dropdown-menu" | ||
id={id} | ||
data-testid="dropdown-menu" | ||
role="menu" | ||
> | ||
<div className="dropdown-content" data-testid="dropdown-content"> | ||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
UIDropdown.propTypes = { | ||
id: PropTypes.string, | ||
isRight: PropTypes.bool, | ||
label: PropTypes.string, | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default UIDropdown; |
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,36 @@ | ||
import { screen, render } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import React from "react"; | ||
import UIDropdown from "./Dropdown"; | ||
|
||
describe("UIDropdown component", () => { | ||
beforeEach(() => { | ||
render( | ||
<UIDropdown data-testid="test-dropdown" id="dropdown1"> | ||
<a href="#">Option 1</a> | ||
<a href="#">Option 2</a> | ||
</UIDropdown> | ||
); | ||
}); | ||
|
||
it("renders the component ", async () => { | ||
expect(screen.getByTestId("test-dropdown")); | ||
expect(screen.getByTestId("dropdown-trigger")); | ||
}); | ||
|
||
it("renders the id attribute for accessibility", () => { | ||
const el = screen.getByTestId("dropdown-menu"); | ||
expect(el.id).toEqual("dropdown1"); | ||
}); | ||
|
||
it("renders dropdown content", () => { | ||
const dropdownEl = screen.getByTestId("test-dropdown"); | ||
const el = screen.getByTestId("dropdown-content"); | ||
|
||
expect(el.childElementCount).toEqual(2); | ||
expect(dropdownEl).not.toHaveClass("is-active"); | ||
|
||
userEvent.click(screen.getByTestId("dropdown-trigger-button")); | ||
expect(dropdownEl).toHaveClass("is-active"); | ||
}); | ||
}); |
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,28 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classNames from "classnames"; | ||
|
||
function UIDropdownItem({ as = "a", isActive, children, ...restProps }) { | ||
const Tag = as; | ||
const aProps = { | ||
href: "#", | ||
}; | ||
return ( | ||
<Tag | ||
{...(as === "a" && { ...aProps })} | ||
className={classNames(["dropdown-item"], { | ||
"is-active": isActive, | ||
})} | ||
{...restProps} | ||
> | ||
{children} | ||
</Tag> | ||
); | ||
} | ||
|
||
UIDropdownItem.propTypes = { | ||
isActive: PropTypes.bool, | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default UIDropdownItem; |
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,47 @@ | ||
import { screen, render } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import React from "react"; | ||
import UIDropdownItem from "./DropdownItem"; | ||
|
||
const mockHandleClick = jest.fn(); | ||
|
||
describe("UIDropdownItem component", () => { | ||
describe("default implementation", () => { | ||
beforeEach(() => { | ||
render( | ||
<UIDropdownItem | ||
data-testid="test-dropdown-item" | ||
onClick={mockHandleClick} | ||
> | ||
Option 1 | ||
</UIDropdownItem> | ||
); | ||
}); | ||
|
||
it("renders the component", async () => { | ||
expect(screen.getByTestId("test-dropdown-item")); | ||
expect(screen.getByText("Option 1")); | ||
}); | ||
|
||
it("handles click event", () => { | ||
userEvent.click(screen.getByTestId("test-dropdown-item")); | ||
expect(mockHandleClick).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe("custom implementation", () => { | ||
it("renders as dynamic HTML element", async () => { | ||
render( | ||
<UIDropdownItem | ||
as="div" | ||
data-testid="test-dropdown-item" | ||
onClick={mockHandleClick} | ||
> | ||
Option 1 | ||
</UIDropdownItem> | ||
); | ||
const el = screen.getByTestId("test-dropdown-item"); | ||
expect(el.tagName).toEqual("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
6 changes: 3 additions & 3 deletions
6
...ponents/Work/Tabs/Administrative.test.jsx → ...bs/Administrative/Administrative.test.jsx
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.