-
Notifications
You must be signed in to change notification settings - Fork 995
Fleet UI: Update empty states in Controls #44965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c2ca3f9
Fleet UI: Update empty states in Controls
RachelElysia e4fb173
lint
RachelElysia fc0bac3
lint
RachelElysia 9771dbf
lint
RachelElysia ff7546a
Fix add script gate, add tests
RachelElysia 17e47e4
Update tests
RachelElysia 6e272cc
Fix lint
RachelElysia 5270a86
Move secrets over to variables naming
RachelElysia 987ed5c
Variable naming, gitops mode regress fixed
RachelElysia f6b86c6
iserror check for empty state
RachelElysia 96e1d25
Copy change
RachelElysia ea93090
Tweaks
RachelElysia b70445c
meta object, ts vs tsx
RachelElysia 8e8eff1
post ai-review nits and tweaks
RachelElysia 88c9248
update tests
RachelElysia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
4 changes: 2 additions & 2 deletions
4
frontend/interfaces/secrets.ts → frontend/interfaces/variables.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| export interface ISecret { | ||
| export interface IVariable { | ||
| id: number; | ||
| name: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| } | ||
|
|
||
| export interface ISecretPayload { | ||
| export interface IVariablePayload { | ||
| name: string; | ||
| value: string; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
140 changes: 140 additions & 0 deletions
140
frontend/pages/ManageControlsPage/Scripts/cards/ScriptLibrary/ScriptLibrary.tests.tsx
This file contains hidden or 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,140 @@ | ||
| import React from "react"; | ||
| import { screen, waitFor } from "@testing-library/react"; | ||
| import { | ||
| baseUrl, | ||
| createCustomRenderer, | ||
| createMockRouter, | ||
| } from "test/test-utils"; | ||
| import mockServer from "test/mock-server"; | ||
| import { http, HttpResponse } from "msw"; | ||
|
|
||
| import ScriptLibrary from "./ScriptLibrary"; | ||
| import { ScriptsLocation } from "../../Scripts"; | ||
|
|
||
| const mockRouter = createMockRouter(); | ||
|
|
||
| const mockLocation: ScriptsLocation = { | ||
| pathname: "/controls/scripts/library", | ||
| query: {}, | ||
| search: "", | ||
| }; | ||
|
|
||
| const emptyScriptsHandler = http.get(baseUrl("/scripts"), () => | ||
| HttpResponse.json({ | ||
| scripts: [], | ||
| meta: { has_next_results: false, has_previous_results: false }, | ||
| }) | ||
| ); | ||
|
|
||
| const baseProps = { | ||
| router: mockRouter, | ||
| teamId: 1, | ||
| location: mockLocation, | ||
| }; | ||
|
|
||
| describe("ScriptLibrary empty state", () => { | ||
| it("renders Upload CTA and info text for global admin", async () => { | ||
| mockServer.use(emptyScriptsHandler); | ||
|
|
||
| const render = createCustomRenderer({ | ||
| withBackendMock: true, | ||
| context: { | ||
| app: { | ||
| isGlobalAdmin: true, | ||
| config: { | ||
| server_settings: { scripts_disabled: false }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| render(<ScriptLibrary {...baseProps} />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText("No scripts")).toBeInTheDocument(); | ||
| }); | ||
| expect(screen.getByRole("button", { name: /upload/i })).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/Upload shell \(.sh\) or Python \(.py\)/i) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders Upload CTA even when scripts are disabled (managing library is still allowed)", async () => { | ||
| mockServer.use(emptyScriptsHandler); | ||
|
|
||
| const render = createCustomRenderer({ | ||
| withBackendMock: true, | ||
| context: { | ||
| app: { | ||
| isGlobalAdmin: true, | ||
| config: { | ||
| server_settings: { scripts_disabled: true }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| render(<ScriptLibrary {...baseProps} />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText("No scripts")).toBeInTheDocument(); | ||
| }); | ||
| expect(screen.getByRole("button", { name: /upload/i })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("hides Upload CTA and info text for global technician", async () => { | ||
| mockServer.use(emptyScriptsHandler); | ||
|
|
||
| const render = createCustomRenderer({ | ||
| withBackendMock: true, | ||
| context: { | ||
| app: { | ||
| isGlobalTechnician: true, | ||
| config: { | ||
| server_settings: { scripts_disabled: false }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| render(<ScriptLibrary {...baseProps} />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText("No scripts")).toBeInTheDocument(); | ||
| }); | ||
| expect( | ||
| screen.queryByRole("button", { name: /upload/i }) | ||
| ).not.toBeInTheDocument(); | ||
| expect( | ||
| screen.queryByText(/Upload shell \(.sh\) or Python \(.py\)/i) | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("hides Upload CTA and info text for team technician", async () => { | ||
| mockServer.use(emptyScriptsHandler); | ||
|
|
||
| const render = createCustomRenderer({ | ||
| withBackendMock: true, | ||
| context: { | ||
| app: { | ||
| isTeamTechnician: true, | ||
| config: { | ||
| server_settings: { scripts_disabled: false }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| render(<ScriptLibrary {...baseProps} />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText("No scripts")).toBeInTheDocument(); | ||
| }); | ||
| expect( | ||
| screen.queryByRole("button", { name: /upload/i }) | ||
| ).not.toBeInTheDocument(); | ||
| expect( | ||
| screen.queryByText(/Upload shell \(.sh\) or Python \(.py\)/i) | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.