## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text  - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com> |
||
|---|---|---|
| .. | ||
| __mocks__ | ||
| components | ||
| context | ||
| docs | ||
| hooks | ||
| interfaces | ||
| layouts | ||
| pages | ||
| router | ||
| services | ||
| styles | ||
| templates | ||
| test | ||
| typings | ||
| utilities | ||
| index.jsx | ||
| index.scss | ||
| public-path.js | ||
| README.md | ||
Fleet frontend
The Fleet frontend is a Single Page Application using React with Typescript and Hooks.
Table of contents
Running the Fleet web app
For details instruction on building and serving the Fleet web application consult the Contributing documentation.
Testing
Visit the overview of Fleet UI testing for more information on our testing strategy, philosophies, and tools.
To run unit or integration tests in ComponentName.tests.tsx, run yarn test -- ComponentName.tests.tsx. To test all Javascript components run yarn test.
QA Wolf manages our E2E test and will maintain the tests as well as raise any issues found from these tests. Engineers should not have to worry about working with E2E testing code or raising issues themselves.
For more information on how our front-end tests work, visit our frontend test directory.
Directory structure
Component directories in the Fleet front-end application encapsulate the entire component, including files for the component and its styles. The typical directory structure for a component is as follows:
└── ComponentName
├── _styles.scss
├── ComponentName.tsx
|-- ComponentName.tests.tsx
├── index.ts
_styles.scss: The component css stylesComponentName.tsx: The React componentComponentName.tests.tsx: The React component unit/integration testsindex.ts: Exports the React component- This file is helpful as it allows other components to import the component
by it's directory name. Without this file the component name would have to
be duplicated during imports (
components/ComponentNamevs.components/ComponentName/ComponentName).
- This file is helpful as it allows other components to import the component
by it's directory name. Without this file the component name would have to
be duplicated during imports (
components
The component directory contains global React components rendered by pages, receiving props from their parent components to render data and handle user interactions.
context
The context directory contains the React Context API pattern for various entities.
Only entities that are needed across the app has a global context. For example,
the logged in user (currentUser) has multiple pages and components
where its information is pulled.
interfaces
Files in the interfaces directory are used to specify the Typescript interface for a reusable Fleet entity. This is designed to DRY up the code and increase re-usability. These interfaces are imported in to component files and implemented when defining the component's props.
Additionally, local interfaces are used for props of local components.
layouts
The Fleet application has only 1 layout, the Core Layout. The Layout is rendered from the router and are used to set up the general app UI (header, sidebar) and render child components. The child components rendered by the layout are typically page components.
pages
Page components are React components typically rendered from the router.
React Router passed props to these pages in case they are needed. Examples include
the router, location, and params objects.
router
The router directory is where the react router lives. The router decides which
component will render at a given URL. Components rendered from the router are
typically located in the pages directory. The router directory also holds a paths
file which holds the application paths as string constants for reference
throughout the app. These paths are typically referenced from the App
Constants object.
services
CRUD functions for all Fleet entities (e.g. query) that link directly to the Fleet API.
styles
The styles directory contains the general app style setup and variables. It includes variables for the app color hex codes, fonts (families, weights and sizes), and padding.
templates
The templates directory contains the HTML file that renders the React application via including the bundle.js
and bundle.css files. The HTML page also includes the HTML element in which the React application is mounted.
test
The test directory includes test helpers, API request mocks, and stubbed data entities for use in test files. See the UI testing documentation for more on test helpers, stubs, and request mocks.
utilities
The utilities directory contains re-usable functions and constants for use throughout the application. The functions include helpers to convert an array of objects to CSV, debounce functions to prevent multiple form submissions, format API errors, etc.
Patterns
The list of patterns used in the Fleet UI codebase can be found in patterns.md.
Storybook
Storybook is a tool to document and visualize components, and we
use it to capture our global components used across Fleet. Storybook is key when developing new
features and testing components before release. It runs a separate server exposed on port 6006.
To run this server, do the following:
- Go to your root fleet project directory
- Run
make deps - Run
yarn storybook
The URL localhost:6006 should automatically show in your browser. If not, visit it manually.
Running Storybook before implementing new UI elements can clarify if new components need to be created or already exist. When creating a component, you can create a new file, component.stories.tsx, within its directory. Then, fill it with the appropriate Storybook code to create a new Storybook entry. You will be able to visualize the component within Storybook to determine if it looks and behaves as expected.