Skip to content

Commit

Permalink
Convert Dashboard to functional component
Browse files Browse the repository at this point in the history
it would be shorter to list what didn't change.

Everything changes?

useEffect replacing compnentDidMount
No more weird handling of filter values, let API filtering do it's job
Cleaned up small behaviors around button enabling

State use makes way more sense now
  • Loading branch information
mshriver committed Dec 9, 2024
1 parent c746e2c commit c2d3e1e
Show file tree
Hide file tree
Showing 5 changed files with 486 additions and 551 deletions.
6 changes: 3 additions & 3 deletions frontend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ElementWrapper from './components/elementWrapper';

import { Navigate, Route, Routes } from 'react-router-dom';

import { Dashboard } from './dashboard';
import Dashboard from './dashboard';
import { ReportBuilder } from './report-builder';
import { RunList } from './run-list';
import { Run } from './run';
Expand Down Expand Up @@ -47,12 +47,12 @@ export class App extends React.Component {
<Route
path="dashboard/:dashboard_id"
element={
<ElementWrapper routeElement={Dashboard} eventEmitter={this.eventEmitter} />
<Dashboard />
}
/>
<Route
path="dashboard/*"
element={<ElementWrapper routeElement={Dashboard} eventEmitter={this.eventEmitter} />}
element={<Dashboard />}
/>


Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/edit-widget-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class EditWidgetModal extends React.Component {
</HelperText>
</FormHelperText>
</FormGroup>
{componentLoaded ? widgetType.params.map(param => {
{componentLoaded ? widgetType?.params.map(param => {
return (
<React.Fragment key={param.name}>
<FormGroup
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/components/ibutsu-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ export class IbutsuHeader extends React.Component {
}

onProjectSelect = (_event, value) => {
const { primaryObject, setPrimaryObject, setPrimaryType } = this.context;
const {
primaryObject,
setPrimaryObject,
setPrimaryType,
setDefaultDashboard,
} = this.context;
if (primaryObject?.id === value?.id) {
this.setState({
isProjectSelectorOpen: false,
Expand All @@ -227,8 +232,11 @@ export class IbutsuHeader extends React.Component {
return;
}
// update context
setPrimaryObject(value)
setPrimaryType('project')
setPrimaryObject(value);
setPrimaryType('project');
console.log('project selected: ' + value.default_dashboard_id)
setDefaultDashboard(value.default_dashboard_id);

// update state
this.setState({
selectedProject: value,
Expand Down
Loading

0 comments on commit c2d3e1e

Please sign in to comment.