forked from gooddata/gooddata-ui-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: config panel and propagating to visualisation
JIRA: F1-277
- Loading branch information
1 parent
d037496
commit 14f317c
Showing
9 changed files
with
349 additions
and
4 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...-ext/src/internal/components/configurationControls/forecast/ForecastConfidenceControl.tsx
This file contains 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,42 @@ | ||
// (C) 2019-2024 GoodData Corporation | ||
import React from "react"; | ||
import { injectIntl, WrappedComponentProps } from "react-intl"; | ||
|
||
import DropdownControl from "../DropdownControl.js"; | ||
import { confidenceDropdownItems } from "../../../constants/dropdowns.js"; | ||
import { getTranslatedDropdownItems } from "../../../utils/translations.js"; | ||
import { IVisualizationProperties } from "../../../interfaces/Visualization.js"; | ||
import { messages } from "../../../../locales.js"; | ||
|
||
export interface IForecastConfidenceControl { | ||
disabled: boolean; | ||
value: string; | ||
showDisabledMessage: boolean; | ||
properties: IVisualizationProperties; | ||
pushData: (data: any) => any; | ||
} | ||
|
||
class ForecastConfidenceControl extends React.PureComponent< | ||
IForecastConfidenceControl & WrappedComponentProps | ||
> { | ||
public render() { | ||
return ( | ||
<DropdownControl | ||
value={this.props.value} | ||
valuePath="forecast.confidence" | ||
labelText={messages.forecastConfidence.id} | ||
disabled={this.props.disabled} | ||
properties={this.props.properties} | ||
pushData={this.props.pushData} | ||
items={this.generateDropdownItems()} | ||
showDisabledMessage={this.props.showDisabledMessage} | ||
/> | ||
); | ||
} | ||
|
||
private generateDropdownItems() { | ||
return getTranslatedDropdownItems(confidenceDropdownItems, this.props.intl); | ||
} | ||
} | ||
|
||
export default injectIntl(ForecastConfidenceControl); |
86 changes: 86 additions & 0 deletions
86
libs/sdk-ui-ext/src/internal/components/configurationControls/forecast/ForecastSection.tsx
This file contains 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,86 @@ | ||
// (C) 2019-2024 GoodData Corporation | ||
import React from "react"; | ||
import ConfigSection from "../ConfigSection.js"; | ||
import ForecastConfidenceControl from "./ForecastConfidenceControl.js"; | ||
import { IVisualizationProperties } from "../../../interfaces/Visualization.js"; | ||
import InputControl from "../InputControl.js"; | ||
import { messages } from "../../../../locales.js"; | ||
import noop from "lodash/noop.js"; | ||
import CheckboxControl from "../CheckboxControl.js"; | ||
|
||
export interface IForecastSection { | ||
controlsDisabled: boolean; | ||
enabled: boolean; | ||
properties: IVisualizationProperties; | ||
propertiesMeta: any; | ||
defaultForecastEnabled?: boolean; | ||
pushData: (data: any) => any; | ||
} | ||
|
||
class ForecastSection extends React.PureComponent<IForecastSection> { | ||
public static defaultProps: IForecastSection = { | ||
controlsDisabled: false, | ||
enabled: false, | ||
properties: {}, | ||
propertiesMeta: {}, | ||
defaultForecastEnabled: true, | ||
pushData: noop, | ||
}; | ||
|
||
public render() { | ||
const { controlsDisabled, properties, pushData, defaultForecastEnabled, enabled } = this.props; | ||
|
||
const forecastEnabled = this.props.properties?.controls?.forecast?.enabled ?? defaultForecastEnabled; | ||
const forecastConfidence = this.props.properties?.controls?.forecast?.confidence ?? "95"; | ||
const forecastPeriod = this.props.properties?.controls?.forecast?.period ?? 3; | ||
const forecastSeasonal = this.props.properties?.controls?.forecast?.seasonal ?? false; | ||
const forecastToggleDisabledByVisualization = !(this.props.propertiesMeta?.forecast_enabled ?? true); | ||
|
||
const toggleDisabled = controlsDisabled || forecastToggleDisabledByVisualization || !enabled; | ||
const forecastControlsDisabled = !forecastEnabled || toggleDisabled; | ||
const showDisabledMessage = controlsDisabled || forecastToggleDisabledByVisualization || !enabled; | ||
|
||
return ( | ||
<ConfigSection | ||
id="forecast_section" | ||
valuePath="forecast.enabled" | ||
title={messages.forecastTitle.id} | ||
propertiesMeta={this.props.propertiesMeta} | ||
properties={properties} | ||
canBeToggled={true} | ||
toggleDisabled={toggleDisabled} | ||
toggledOn={forecastEnabled} | ||
pushData={pushData} | ||
showDisabledMessage={showDisabledMessage} | ||
toggleMessageId={messages.forecastDisabledTooltip.id} | ||
> | ||
<InputControl | ||
value={forecastPeriod} | ||
valuePath="forecast.period" | ||
labelText={messages.forecastPeriod.id} | ||
placeholder={messages.forecastPeriodPlaceholder.id} | ||
disabled={forecastControlsDisabled} | ||
properties={properties} | ||
pushData={pushData} | ||
/> | ||
<ForecastConfidenceControl | ||
disabled={forecastControlsDisabled} | ||
value={forecastConfidence} | ||
showDisabledMessage={showDisabledMessage} | ||
properties={properties} | ||
pushData={pushData} | ||
/> | ||
<CheckboxControl | ||
valuePath="forecast.seasonal" | ||
checked={forecastSeasonal} | ||
labelText={messages.forecastSeasonal.id} | ||
disabled={forecastControlsDisabled} | ||
properties={properties} | ||
pushData={pushData} | ||
/> | ||
</ConfigSection> | ||
); | ||
} | ||
} | ||
|
||
export default ForecastSection; |
This file contains 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 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 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 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 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 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.