Skip to content

Commit 85a2856

Browse files
committed
unique history per app
1 parent 571d8f6 commit 85a2856

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/dashboard/Data/Config/Config.react.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,26 @@ class Config extends TableView {
254254
.then(
255255
() => {
256256
this.setState({ modalOpen: false });
257-
const limit = this.context.historylimit;
257+
const limit = this.context.cloudConfigHistoryLimit;
258+
const applicationId = this.context.applicationId;
258259
let transformedValue = value;
259260
if(type === 'Date') {
260261
transformedValue = {__type: 'Date', iso: value};
261262
}
262263
if(type === 'File') {
263264
transformedValue = {name: value._name, url: value._url};
264265
}
265-
const configHistory = localStorage.getItem('configHistory');
266+
const configHistory = localStorage.getItem(`${applicationId}_configHistory`);
266267
if(!configHistory) {
267-
localStorage.setItem('configHistory', JSON.stringify({
268+
localStorage.setItem(`${applicationId}_configHistory`, JSON.stringify({
268269
[name]: [{
269270
time: new Date(),
270271
value: transformedValue
271272
}]
272273
}));
273274
} else {
274275
const oldConfigHistory = JSON.parse(configHistory);
275-
localStorage.setItem('configHistory', JSON.stringify({
276+
localStorage.setItem(`${applicationId}_configHistory`, JSON.stringify({
276277
...oldConfigHistory,
277278
[name]: !oldConfigHistory[name] ?
278279
[{time: new Date(), value: transformedValue}]

src/dashboard/Data/Config/ConfigDialog.react.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import validateNumeric from 'lib/validateNumeric';
2121
import styles from 'dashboard/Data/Browser/Browser.scss';
2222
import semver from 'semver/preload.js';
2323
import { dateStringUTC } from 'lib/DateUtils';
24+
import { CurrentApp } from 'context/currentApp';
2425

2526
const PARAM_TYPES = ['Boolean', 'String', 'Number', 'Date', 'Object', 'Array', 'GeoPoint', 'File'];
2627

@@ -91,6 +92,7 @@ const GET_VALUE = {
9192
};
9293

9394
export default class ConfigDialog extends React.Component {
95+
static contextType = CurrentApp;
9496
constructor(props) {
9597
super();
9698
this.state = {
@@ -194,7 +196,7 @@ export default class ConfigDialog extends React.Component {
194196
))}
195197
</Dropdown>
196198
);
197-
const configHistory = localStorage.getItem('configHistory') && JSON.parse(localStorage.getItem('configHistory'))[this.state.name];
199+
const configHistory = localStorage.getItem(`${this.context.applicationId}_configHistory`) && JSON.parse(localStorage.getItem(`${this.context.applicationId}_configHistory`))[this.state.name];
198200
const handleIndexChange = index => {
199201
if(this.state.type === 'Date'){
200202
return;

src/lib/ParseApp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class ParseApp {
4949
scripts,
5050
classPreference,
5151
enableSecurityChecks,
52-
historylimit
52+
cloudConfigHistoryLimit
5353
}) {
5454
this.name = appName;
5555
this.createdAt = created_at ? new Date(created_at) : new Date();
@@ -78,7 +78,7 @@ export default class ParseApp {
7878
this.columnPreference = columnPreference;
7979
this.scripts = scripts;
8080
this.enableSecurityChecks = !!enableSecurityChecks;
81-
this.historylimit = historylimit;
81+
this.cloudConfigHistoryLimit = cloudConfigHistoryLimit;
8282

8383
if (!supportedPushLocales) {
8484
console.warn(

0 commit comments

Comments
 (0)