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:
Noah Talerman 2025-06-25 09:24:36 -04:00 committed by GitHub
parent b5d58353e7
commit a51f074ecf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 7 deletions

View file

@ -54,9 +54,11 @@ describe("Software table", () => {
expect(screen.getByText("Software inventory disabled")).toBeInTheDocument();
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({
context: {
app: {
@ -102,9 +104,11 @@ describe("Software table", () => {
expect(screen.getByText("0 items")).toBeInTheDocument();
expect(screen.queryByText("Search")).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({
context: {
app: {
@ -146,9 +150,11 @@ describe("Software table", () => {
expect(
screen.getByText("Expecting to see software? Check back later.")
).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({
context: {
app: {
@ -194,9 +200,10 @@ describe("Software table", () => {
"Expecting to see installable software? Check back later."
)
).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({
context: {
app: {
@ -242,5 +249,48 @@ describe("Software table", () => {
"Expecting to see vulnerable software? Check back later."
)
).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();
});
});

View file

@ -281,8 +281,9 @@ const SoftwareTable = ({
};
const renderCustomControls = () => {
// Hidden when viewing versions table
if (showVersions) {
// Hidden when viewing versions table or viewing "All teams"
// or Fleet Free
if (showVersions || teamId === undefined) {
return null;
}
@ -293,7 +294,6 @@ const SoftwareTable = ({
value={softwareFilter}
className={`${baseClass}__software-filter`}
options={SOFTWARE_TITLES_DROPDOWN_OPTIONS}
isDisabled={teamId === undefined}
onChange={(newValue: SingleValue<CustomOptionType>) =>
newValue &&
handleCustomFilterDropdownChange(