Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Info panel not showing when some apps miss infoPanel config #2627

Open
wants to merge 3 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/BrowserCell/BrowserCell.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default class BrowserCell extends Component {
this.props.setShowAggregatedData(true);
this.props.setSelectedObjectId(this.props.objectId);
if (this.props.isPanelVisible) {
this.props.callCloudFunction(this.props.objectId, this.props.className);
this.props.callCloudFunction(this.props.objectId, this.props.className, this.props.appId);
}
}

Expand Down Expand Up @@ -649,7 +649,7 @@ export default class BrowserCell extends Component {
isPanelVisible &&
((e.shiftKey && !this.props.firstSelectedCell) || !e.shiftKey)
) {
callCloudFunction(this.props.objectId, this.props.className);
callCloudFunction(this.props.objectId, this.props.className, this.props.appId);
}
}
handleCellClick(e, row, col);
Expand Down
8 changes: 4 additions & 4 deletions src/components/Toolbar/Toolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useNavigate, useNavigationType, NavigationType } from 'react-router-dom

const POPOVER_CONTENT_ID = 'toolbarStatsPopover';

const Stats = ({ data, classwiseCloudFunctions, className }) => {
const Stats = ({ data, classwiseCloudFunctions, className, appId }) => {
const [selected, setSelected] = React.useState(null);
const [open, setOpen] = React.useState(false);
const buttonRef = React.useRef();
Expand Down Expand Up @@ -98,7 +98,7 @@ const Stats = ({ data, classwiseCloudFunctions, className }) => {
setSelected(statsOptions[0]);
}, []);

const rightMarginStyle = classwiseCloudFunctions && classwiseCloudFunctions[className] ? '120px' : 'initial';
const rightMarginStyle = classwiseCloudFunctions && classwiseCloudFunctions[appId] && classwiseCloudFunctions[appId][className] ? '120px' : 'initial';

return (
<>
Expand Down Expand Up @@ -140,9 +140,9 @@ const Toolbar = props => {
</div>
</div>
</div>
{props?.selectedData?.length ? <Stats data={props.selectedData} classwiseCloudFunctions={props.classwiseCloudFunctions} className={props.className} /> : null}
{props?.selectedData?.length ? <Stats data={props.selectedData} classwiseCloudFunctions={props.classwiseCloudFunctions} className={props.className} appId={props.appId} /> : null}
<div className={styles.actions}>{props.children}</div>
{props.classwiseCloudFunctions && props.classwiseCloudFunctions[props.className] && (
{props.classwiseCloudFunctions && props.classwiseCloudFunctions[props.appId] && props.classwiseCloudFunctions[props.appId][props.className] && (
<button
onClick={props.togglePanel}
className={styles.btn}
Expand Down
13 changes: 7 additions & 6 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ class Browser extends DashboardView {
});
}

fetchAggregationPanelData(objectId, className) {
fetchAggregationPanelData(objectId, className, appId) {
this.setState({
isLoading: true,
});
const params = {
objectId: objectId,
};
const cloudCodeFunction = this.state.classwiseCloudFunctions[className][0].cloudCodeFunction;
const cloudCodeFunction = this.state.classwiseCloudFunctions[appId][className][0].cloudCodeFunction;

Parse.Cloud.run(cloudCodeFunction, params).then(
result => {
Expand Down Expand Up @@ -328,12 +328,13 @@ class Browser extends DashboardView {
classAndCloudFuntionMap(data) {
const classMap = {};
data.apps.forEach(app => {
app.infoPanel.forEach(panel => {
classMap[app.appId] = {};
app.infoPanel && app.infoPanel.forEach(panel => {
panel.classes.forEach(className => {
if (!classMap[className]) {
classMap[className] = [];
if (!classMap[app.appId][className]) {
classMap[app.appId][className] = [];
}
classMap[className].push({
classMap[app.appId][className].push({
title: panel.title,
cloudCodeFunction: panel.cloudCodeFunction,
classes: panel.classes,
Expand Down
4 changes: 3 additions & 1 deletion src/dashboard/Data/Browser/BrowserToolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const BrowserToolbar = ({

togglePanel,
isPanelVisible,
classwiseCloudFunctions
classwiseCloudFunctions,
appId
}) => {
const selectionLength = Object.keys(selection).length;
const isPendingEditCloneRows = editCloneRows && editCloneRows.length > 0;
Expand Down Expand Up @@ -276,6 +277,7 @@ const BrowserToolbar = ({
togglePanel={togglePanel}
isPanelVisible={isPanelVisible}
classwiseCloudFunctions={classwiseCloudFunctions}
appId={appId}
>
{onAddRow && (
<a className={classes.join(' ')} onClick={onClick}>
Expand Down
9 changes: 5 additions & 4 deletions src/dashboard/Data/Browser/DataBrowser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class DataBrowser extends React.Component {
this.setState({ order });
}
if (props && props.className) {
if (!props.classwiseCloudFunctions[props.className]) {
if (!props.classwiseCloudFunctions?.[props.app.applicationId]?.[props.className]) {
this.setState({ isPanelVisible: false });
this.setState({ selectedObjectId: undefined });
}
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class DataBrowser extends React.Component {
if(this.props.errorAggregatedData != {}){
this.props.setErrorAggregatedData({});
}
this.props.callCloudFunction(this.state.selectedObjectId, this.props.className);
this.props.callCloudFunction(this.state.selectedObjectId, this.props.className,this.props.app.applicationId);
}
}

Expand Down Expand Up @@ -364,7 +364,7 @@ export default class DataBrowser extends React.Component {
showAggregatedData:true
})
if(prevObjectID !== this.state.selectedObjectId && this.state.isPanelVisible){
this.props.callCloudFunction(this.state.selectedObjectId,this.props.className)
this.props.callCloudFunction(this.state.selectedObjectId,this.props.className,this.props.app.applicationId)
}
e.preventDefault();
break;
Expand Down Expand Up @@ -405,7 +405,7 @@ export default class DataBrowser extends React.Component {
showAggregatedData: true,
});
if (prevObjectID !== this.state.selectedObjectId && this.state.isPanelVisible) {
this.props.callCloudFunction(this.state.selectedObjectId, this.props.className);
this.props.callCloudFunction(this.state.selectedObjectId, this.props.className,this.props.app.applicationId);
}

e.preventDefault();
Expand Down Expand Up @@ -642,6 +642,7 @@ export default class DataBrowser extends React.Component {
allClassesSchema={this.state.allClassesSchema}
togglePanel={this.togglePanelVisibility}
isPanelVisible={this.state.isPanelVisible}
appId={this.props.app.applicationId}
{...other}
/>

Expand Down
Loading