-
Notifications
You must be signed in to change notification settings - Fork 36
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 #543 from openSUSE/calculated_tooltip
Tooltip for the autocalculated partition size limits
- Loading branch information
Showing
9 changed files
with
272 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,7 @@ | |
/** END block-size fallbacks **/ | ||
block-size: 95dvh; | ||
} | ||
|
||
.cursor-pointer { | ||
cursor: pointer; | ||
} |
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,43 @@ | ||
/* | ||
* Copyright (c) [2023] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Popover } from "@patternfly/react-core"; | ||
|
||
/** | ||
* Displays details popup after clicking the children elements | ||
* @component | ||
* | ||
* @param {(JSX.Element|null)} description content displayed in a popup | ||
* @param {JSX.Element} children the wrapped content | ||
*/ | ||
export default function Description ({ description, children, ...otherProps }) { | ||
if (description) { | ||
return ( | ||
<Popover showClose={false} bodyContent={description} {...otherProps}> | ||
<span className="cursor-pointer">{children}</span> | ||
</Popover> | ||
); | ||
} | ||
|
||
// none or empty description, just return the children | ||
return children; | ||
} |
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,68 @@ | ||
/* | ||
* Copyright (c) [2023] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { screen } from "@testing-library/react"; | ||
import { plainRender } from "~/test-utils"; | ||
import { Description } from "~/components/core"; | ||
|
||
describe("Description", () => { | ||
const description = "Some great description"; | ||
const item = "Item with description"; | ||
|
||
it("displays the description after clicking the object", async () => { | ||
const { user } = plainRender(<Description description={description}>{item}</Description>); | ||
|
||
// the description is not displayed just after the render | ||
expect(screen.queryByText(description)).not.toBeInTheDocument(); | ||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); | ||
|
||
// click it | ||
const item_node = screen.getByText(item); | ||
await user.click(item_node); | ||
|
||
// then the description is visible in a dialog | ||
screen.getByRole("dialog"); | ||
screen.getByText(description); | ||
}); | ||
|
||
const expectNoPopup = async (content) => { | ||
const { user } = plainRender(content); | ||
|
||
const item_node = screen.getByText(item); | ||
await user.click(item_node); | ||
|
||
// do not display empty popup | ||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); | ||
}; | ||
|
||
it("displays the object without description when it is undefined", async () => { | ||
expectNoPopup(<Description>{item}</Description>); | ||
}); | ||
|
||
it("displays the object without description when it is null", async () => { | ||
expectNoPopup(<Description description={null}>{item}</Description>); | ||
}); | ||
|
||
it("displays the object without description when it is empty", async () => { | ||
expectNoPopup(<Description description="">{item}</Description>); | ||
}); | ||
}); |
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 @@ | ||
/* | ||
* Copyright (c) [2023] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Label } from "@patternfly/react-core"; | ||
|
||
import { Description } from "~/components/core"; | ||
import { Icon } from "~/components/layout"; | ||
|
||
/** | ||
* Display a label with additional details. The details are displayed after | ||
* clicking the label and the "i" icon indicates available details. | ||
* If the label is not defined or is empty it behaves like a plain label. | ||
* @component | ||
* | ||
* @param {JSX.Element} description details displayed after clicking the label | ||
* @param {JSX.Element} children the content of the label | ||
*/ | ||
export default function Tip ({ description, children }) { | ||
if (description) { | ||
return ( | ||
<Description description={description}> | ||
<Label isCompact>{children} <Icon name="info" size="16" /></Label> | ||
</Description> | ||
); | ||
} | ||
|
||
return <Label isCompact>{children}</Label>; | ||
} |
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,67 @@ | ||
/* | ||
* Copyright (c) [2023] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { screen } from "@testing-library/react"; | ||
import { plainRender } from "~/test-utils"; | ||
import { Tip } from "~/components/core"; | ||
|
||
describe("Tip", () => { | ||
const description = "Some great description"; | ||
const label = "Label"; | ||
|
||
describe("The description is not empty", () => { | ||
it("displays the label with the 'info' icon and show the description after click", async () => { | ||
const { user, container } = plainRender(<Tip description={description}>{label}</Tip>); | ||
|
||
// an icon is displayed | ||
expect(container.querySelector("svg")).toBeInTheDocument(); | ||
|
||
// the description is not displayed just after the render | ||
expect(screen.queryByText(description)).not.toBeInTheDocument(); | ||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); | ||
|
||
// click it | ||
const label_node = screen.getByText(label); | ||
await user.click(label_node); | ||
|
||
// then the description is visible in a dialog | ||
screen.getByRole("dialog"); | ||
screen.getByText(description); | ||
}); | ||
}); | ||
|
||
describe("The description is not defined", () => { | ||
it("displays the label without the 'info' icon and clicking does not show any popup", async () => { | ||
const { user, container } = plainRender(<Tip>{label}</Tip>); | ||
|
||
// no icon | ||
expect(container.querySelector("svg")).not.toBeInTheDocument(); | ||
|
||
// click it | ||
const label_node = screen.getByText(label); | ||
await user.click(label_node); | ||
|
||
// no popup | ||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
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