fleet/frontend
Martavis Parker 596a54e781
Urgent bug fixes for Query Experience - v4.3.0 (#2033)
* Step 1 for improving query experience (#1591)

* fake change to create draft PR

* temp routes to work and not modify old query page

* created new API abstraction for query

* refactored App.jsx to prepare react-query

* fixed flow of redirects after page refresh; functional component added

* setup for getting data on edit

* implementing functions for query page

* Old form showing on new setup

* improving and breaking up query form

* no need for the helpers anymore; clean up

* added type for button component variant

* step toward new save modal; have to switch gears to #1619

* creating new query works

* clean up

* linting cleanup

* added default value for new query

* will address dynamic save disabled in edit step

* Step 2 for improving query experience (select targets) (#1732)

* fake change to create draft PR

* temp routes to work and not modify old query page

* created new API abstraction for query

* refactored App.jsx to prepare react-query

* fixed flow of redirects after page refresh; functional component added

* setup for getting data on edit

* implementing functions for query page

* Old form showing on new setup

* improving and breaking up query form

* no need for the helpers anymore; clean up

* added type for button component variant

* step toward new save modal; have to switch gears to #1619

* creating new query works

* clean up

* linting cleanup

* added default value for new query

* split steps into separate files for readability

* components laid out

* new targets picker

* function clean up

* styling tables

* fixing logic

* fixed logic to keep getting related hosts

* formatting targets for API

* fixed default query

* clean up

* styled target selectors; fixed target input styles

* began total count

* forgot to remove debugging code

* lint fixes

* added target count from API

* clean up

* able to remove selected host targets from table

* lint fixes

* Improving query experience - Step 3 (query results) (#1766)

* fake change to create draft PR

* temp routes to work and not modify old query page

* created new API abstraction for query

* refactored App.jsx to prepare react-query

* fixed flow of redirects after page refresh; functional component added

* setup for getting data on edit

* implementing functions for query page

* Old form showing on new setup

* improving and breaking up query form

* no need for the helpers anymore; clean up

* added type for button component variant

* step toward new save modal; have to switch gears to #1619

* creating new query works

* clean up

* linting cleanup

* added default value for new query

* split steps into separate files for readability

* components laid out

* new targets picker

* function clean up

* styling tables

* fixing logic

* fixed logic to keep getting related hosts

* formatting targets for API

* fixed default query

* clean up

* styled target selectors; fixed target input styles

* began total count

* forgot to remove debugging code

* lint fixes

* added target count from API

* clean up

* able to remove selected host targets from table

* lint fixes

* connected run query with modern React/JS; clean up

* linting fixes

* fixed logic to retrieve results from live query

* linting fixes

* created new, simpler query progress

* populating results and errors tables as expected

* syntax fixes

* fixing styles for query results

* more styling for query results

* manual merge from main

* Rename core->free and basic->premium

* Fix lint js

* Comment out portion of test that seems to timeout

* Rename tier  to premium if basic is still loaded

* go sum

* Query Experience Cleanup Tasks (#1807)

* fixes to get merged main branch to build and work

* moved screens for query pages; clean up

* updated and typed react ace for query form; clean up

* using console error instead

* added real types instead of `any` except for errors

* query side panel ts and functional. prep for close task.

* ability to hide, show query table sidebar

* improved live query status warning

* added loading and error state for targets search

* error screen for targets; improved loading display

* now using API-created label for all linux

* missed some files on previous commit

* able to edit query

* clean up

* lint fixes

* query results showing as they come

* remove unused code

* removed old query page. major file cleanup.

* removed selectedTargets redux implementation

* removed unused redux actions and reducers

* removed unused keys in initial state

* selectedOsqueryTable is now using context API

* removed all querypages redux code

* set up context for app and user

* fixed auth with temp fix for wrapper

* completed redux removal from query page

* fixed var names coming from main branch

* fixed var name changes coming from issue 1501

* fixed save popup bug; clean up

* added permissions

* fixed login redirect

* removed unused props

* linting fix

* clean up

* removed unused component, refactor, and clean up

* fixed styles for step 1 as admin

* fixed styles for step 1 as observer

* fixed percentage of online hosts

* added loading progress to query stop button

* reset query status on run again

* added download icon to export button text

* fixed error reset on name input; fixed styles

* fixed bug where query value wasn't saving

* fixed query value when blank

* fixed bug - default query was running every time

* auto adding host from url to targets

* fixed flows for repeating run and save steps

* fleet ace is now TS and functional

* fixed a couple of tests

* fixed issues with query value text inconsistencies

* fixed query side panel not showing

* hiding error count if not > 0

* fixed showing editor for different roles

* using integer for targets

* go sum

* fixed targets param

* catching all errors while running query

* fixed hover state for title and description

* ignore unit test for now; lint fixes

* locking react-ace version

* ignoring tests breaking in github actions

* brought tests back

* fixing file name

* fixing file name again

* fixed e2e test

* have to ignore tests for now

* ignore certain premium tests for now

* one last test to revamp

* another test

* fixed teamflow test

* fixed observer query 403

* lint fixes

* fixed maintainer test

* added changes file

* query sidebar cleanup

* fixed save modal feedback

* reset targets after done button clicked

* using edited query on run

* fixed query modal value conflict

* lint fixes

* fixed running edited saved query

* fixed form prop conflicts with local state

* lint fixes

* remove logs

* have to reset value when query id changes

Co-authored-by: Tomas Touceda <chiiph@gmail.com>
2021-09-13 14:23:24 -07:00
..
__mocks__ add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
app_constants add new permission routes and messaging (#915) 2021-06-04 14:00:14 +01:00
components Urgent bug fixes for Query Experience - v4.3.0 (#2033) 2021-09-13 14:23:24 -07:00
context 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
fleet 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
interfaces Urgent bug fixes for Query Experience - v4.3.0 (#2033) 2021-09-13 14:23:24 -07:00
layouts/CoreLayout Rename core->free and basic->premium (#1870) 2021-09-03 13:05:23 -03:00
pages Urgent bug fixes for Query Experience - v4.3.0 (#2033) 2021-09-13 14:23:24 -07:00
redux 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
router 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
services 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
styles Urgent bug fixes for Query Experience - v4.3.0 (#2033) 2021-09-13 14:23:24 -07:00
templates Add robots noindex to frontend HTML head (#892) 2021-05-28 11:41:24 -07:00
test App Settings Page: Host status webhook UI (#1899) 2021-09-10 10:49:11 -07:00
typings Select all matching hosts (#1226) 2021-07-10 10:29:27 -07:00
utilities 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
index.jsx add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
index.scss 1497 improved query experience (#1998) 2021-09-10 12:06:37 -07:00
osquery_tables.json add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
public-path.js add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
README.md Update documentation structure (#1230) 2021-06-28 11:15:22 -04:00

Fleet Front-End

The Fleet front-end is a Single Page Application using React and Redux.

Running the Fleet web app

For details instruction on building and serving the Fleet web application consult the Contributing documentation.

Directory Structure

Component directories in the Fleet front-end application encapsulate the entire component, including files for the component, helper functions, styles, and tests. The typical directory structure for a component is as follows:

|-- ComponentName
|  |-- _styles.scss
|  |-- ComponentName.jsx
|  |-- ComponentName.tests.jsx
|  |-- helpers.js
|  |-- helpers.tests.js
|  |-- index.js
  • _styles.scss: The component css styles
  • ComponentName.jsx: The React component
  • ComponentName.tests.jsx: The React component tests
  • helpers.js: Helper functions used by the component
  • helpers.tests.js: Tests for the component's helper functions
  • index.js: 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/ComponentName vs. components/ComponentName/ComponentName).

app_constants

The app_constants directory exports the constants used in the app. Examples include the app's URL paths, settings, and http statuses. When building features that require constants, the constants should be added here for accessibility throughout the application.

components

The component directory contains the React components rendered by pages. They are typically not connected to the redux state but receive props from their parent components to render data and handle user interactions.

interfaces

Files in the interfaces directory are used to specify the PropTypes for a reusable Fleet entity. This is designed to DRY up the code and increase re-usability. These interfaces are imported into component files and implemented when defining the component's PropTypes.

fleet

The default export of the fleet directory is the API client. More info can be found at the API client documentation page.

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. These components are connected to redux state and are used to gather data from redux and pass that data to child components (located in the components directory. As connected components, Pages are also used to dispatch actions. Actions dispatched from Pages are intended to update redux state and oftentimes include making a call to the Fleet API.

redux

The redux directory holds all of the application's redux middleware, actions, and reducers. The redux directory also creates the store which is used in the router. More information about the redux configuration can be found at the Redux Documentation page

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.

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. More on test helpers, stubs, and request mocks here.

utilities

The utilities directory contains re-usable functions 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.

Forms

For details on creating a Fleet form visit the Fleet Form Documentation.

API Client

For details on the Fleet API Client visit the Fleet API Client Documentation.