Allow features to be disabled at build time (#143)
* Add framework for built-time feature selection * Allow MQTT, NTP, OTA features to be disabled at build time * Allow Project screens to be disabled at build time * Allow security features to be disabled at build time * Switch to std::function for StatefulService function aliases for greater flexibility * Bump various UI lib versions * Update docs
This commit is contained in:
		@@ -8,8 +8,9 @@ import { MenuAppBar } from '../components';
 | 
			
		||||
 | 
			
		||||
import SystemStatusController from './SystemStatusController';
 | 
			
		||||
import OTASettingsController from './OTASettingsController';
 | 
			
		||||
import { WithFeaturesProps, withFeatures } from '../features/FeaturesContext';
 | 
			
		||||
 | 
			
		||||
type SystemProps = AuthenticatedContextProps & RouteComponentProps;
 | 
			
		||||
type SystemProps = AuthenticatedContextProps & RouteComponentProps & WithFeaturesProps;
 | 
			
		||||
 | 
			
		||||
class System extends Component<SystemProps> {
 | 
			
		||||
 | 
			
		||||
@@ -18,16 +19,20 @@ class System extends Component<SystemProps> {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  render() {
 | 
			
		||||
    const { authenticatedContext } = this.props;
 | 
			
		||||
    const { authenticatedContext, features } = this.props;
 | 
			
		||||
    return (
 | 
			
		||||
      <MenuAppBar sectionTitle="System">
 | 
			
		||||
        <Tabs value={this.props.match.url} onChange={this.handleTabChange} variant="fullWidth">
 | 
			
		||||
          <Tab value="/system/status" label="System Status" />
 | 
			
		||||
          <Tab value="/system/ota" label="OTA Settings" disabled={!authenticatedContext.me.admin} />
 | 
			
		||||
          {features.ota && (
 | 
			
		||||
            <Tab value="/system/ota" label="OTA Settings" disabled={!authenticatedContext.me.admin} />
 | 
			
		||||
          )}
 | 
			
		||||
        </Tabs>
 | 
			
		||||
        <Switch>
 | 
			
		||||
          <AuthenticatedRoute exact path="/system/status" component={SystemStatusController} />
 | 
			
		||||
          <AuthenticatedRoute exact path="/system/ota" component={OTASettingsController} />
 | 
			
		||||
          {features.ota && (
 | 
			
		||||
            <AuthenticatedRoute exact path="/system/ota" component={OTASettingsController} />
 | 
			
		||||
          )}
 | 
			
		||||
          <Redirect to="/system/status" />
 | 
			
		||||
        </Switch>
 | 
			
		||||
      </MenuAppBar>
 | 
			
		||||
@@ -35,4 +40,4 @@ class System extends Component<SystemProps> {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default withAuthenticatedContext(System);
 | 
			
		||||
export default withFeatures(withAuthenticatedContext(System));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user