mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Software page: Hide "Available for install / Self-service" dropdown for "All teams" and Fleet Free (#30274)
--------- Co-authored-by: RachelElysia <rachel.elysia.perkins@gmail.com>
This commit is contained in:
parent
b5d58353e7
commit
a51f074ecf
2 changed files with 57 additions and 7 deletions
|
|
@ -54,9 +54,11 @@ describe("Software table", () => {
|
||||||
|
|
||||||
expect(screen.getByText("Software inventory disabled")).toBeInTheDocument();
|
expect(screen.getByText("Software inventory disabled")).toBeInTheDocument();
|
||||||
expect(screen.queryByText("Vulnerability")).toBeNull();
|
expect(screen.queryByText("Vulnerability")).toBeNull();
|
||||||
|
expect(screen.queryByText("All software")).toBeNull();
|
||||||
|
expect(screen.queryByText("Available for install")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Renders the page-wide empty state when no software are present", () => {
|
it("Renders the page-wide empty state when no software are present hiding 'Available for install' filter", () => {
|
||||||
const render = createCustomRenderer({
|
const render = createCustomRenderer({
|
||||||
context: {
|
context: {
|
||||||
app: {
|
app: {
|
||||||
|
|
@ -102,9 +104,11 @@ describe("Software table", () => {
|
||||||
expect(screen.getByText("0 items")).toBeInTheDocument();
|
expect(screen.getByText("0 items")).toBeInTheDocument();
|
||||||
expect(screen.queryByText("Search")).toBeNull();
|
expect(screen.queryByText("Search")).toBeNull();
|
||||||
expect(screen.queryByText("Updated")).toBeNull();
|
expect(screen.queryByText("Updated")).toBeNull();
|
||||||
|
expect(screen.queryByText("All software")).toBeNull();
|
||||||
|
expect(screen.queryByText("Available for install")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Renders the page-wide empty state when search query does not exist but versions toggle is applied", () => {
|
it("Renders the page-wide empty state hiding 'Available for install' filter when search query does not exist but versions toggle is applied", () => {
|
||||||
const render = createCustomRenderer({
|
const render = createCustomRenderer({
|
||||||
context: {
|
context: {
|
||||||
app: {
|
app: {
|
||||||
|
|
@ -146,9 +150,11 @@ describe("Software table", () => {
|
||||||
expect(
|
expect(
|
||||||
screen.getByText("Expecting to see software? Check back later.")
|
screen.getByText("Expecting to see software? Check back later.")
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText("All software")).toBeNull();
|
||||||
|
expect(screen.queryByText("Available for install")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Renders the empty search state when search query does not exist but dropdown is applied", () => {
|
it("Renders the empty search state and 'Available for install' filter when search query does not exist but filter is applied", () => {
|
||||||
const render = createCustomRenderer({
|
const render = createCustomRenderer({
|
||||||
context: {
|
context: {
|
||||||
app: {
|
app: {
|
||||||
|
|
@ -194,9 +200,10 @@ describe("Software table", () => {
|
||||||
"Expecting to see installable software? Check back later."
|
"Expecting to see installable software? Check back later."
|
||||||
)
|
)
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(screen.getByText("Available for install")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Renders the empty search state when search query does not exist but vulnerability filter is applied", () => {
|
it("Renders the empty search state and 'Available for install' filter when search query does not exist but vulnerability filter is applied", () => {
|
||||||
const render = createCustomRenderer({
|
const render = createCustomRenderer({
|
||||||
context: {
|
context: {
|
||||||
app: {
|
app: {
|
||||||
|
|
@ -242,5 +249,48 @@ describe("Software table", () => {
|
||||||
"Expecting to see vulnerable software? Check back later."
|
"Expecting to see vulnerable software? Check back later."
|
||||||
)
|
)
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(screen.getByText("All software")).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not render 'Available for install' filter when team id is undefined (Fleet Free/All teams)", () => {
|
||||||
|
const render = createCustomRenderer({
|
||||||
|
context: {
|
||||||
|
app: {
|
||||||
|
isGlobalAdmin: true,
|
||||||
|
currentUser: createMockUser(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
render(
|
||||||
|
<SoftwareTable
|
||||||
|
router={mockRouter}
|
||||||
|
isSoftwareEnabled
|
||||||
|
showVersions={false}
|
||||||
|
data={createMockSoftwareTitlesResponse({
|
||||||
|
counts_updated_at: null,
|
||||||
|
software_titles: [],
|
||||||
|
})}
|
||||||
|
installableSoftwareExists={false}
|
||||||
|
query=""
|
||||||
|
perPage={20}
|
||||||
|
orderDirection="asc"
|
||||||
|
orderKey="hosts_count"
|
||||||
|
softwareFilter="allSoftware"
|
||||||
|
vulnFilters={{
|
||||||
|
vulnerable: false,
|
||||||
|
exploit: false,
|
||||||
|
minCvssScore: undefined,
|
||||||
|
maxCvssScore: undefined,
|
||||||
|
}}
|
||||||
|
currentPage={0}
|
||||||
|
teamId={undefined} // Undefined for Fleet Free or Fleet Premium "All teams"
|
||||||
|
isLoading={false}
|
||||||
|
onAddFiltersClick={noop}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.queryByText("All software")).toBeNull();
|
||||||
|
expect(screen.queryByText("Available for install")).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -281,8 +281,9 @@ const SoftwareTable = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCustomControls = () => {
|
const renderCustomControls = () => {
|
||||||
// Hidden when viewing versions table
|
// Hidden when viewing versions table or viewing "All teams"
|
||||||
if (showVersions) {
|
// or Fleet Free
|
||||||
|
if (showVersions || teamId === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,7 +294,6 @@ const SoftwareTable = ({
|
||||||
value={softwareFilter}
|
value={softwareFilter}
|
||||||
className={`${baseClass}__software-filter`}
|
className={`${baseClass}__software-filter`}
|
||||||
options={SOFTWARE_TITLES_DROPDOWN_OPTIONS}
|
options={SOFTWARE_TITLES_DROPDOWN_OPTIONS}
|
||||||
isDisabled={teamId === undefined}
|
|
||||||
onChange={(newValue: SingleValue<CustomOptionType>) =>
|
onChange={(newValue: SingleValue<CustomOptionType>) =>
|
||||||
newValue &&
|
newValue &&
|
||||||
handleCustomFilterDropdownChange(
|
handleCustomFilterDropdownChange(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue