Skip to content

Commit 799abfd

Browse files
authored
Merge pull request #93 from back4app/update-app-name
Update app name
2 parents 30a7a47 + 7a1d609 commit 799abfd

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

src/dashboard/Settings/GeneralSettings.react.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ let AppInformationFields = ({
115115
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
116116
label={<Label text='App name' />}
117117
input={<TextInput
118-
value={appName} />
118+
value={appName}
119+
onChange={(newValue) => setAppName(newValue)} />
119120
} />
120121
<Field
121122
labelWidth={58}
@@ -538,20 +539,22 @@ export default class GeneralSettings extends DashboardView {
538539
promiseList.push(this.context.currentApp.setInProduction(changes.inProduction));
539540
}
540541

541-
let addedCollaborators = setDifference(changes.collaborators, initialFields.collaborators, compareCollaborators);
542-
addedCollaborators.forEach(({ userEmail, featuresPermission, classesPermission }) => {
543-
promiseList.push(this.context.currentApp.addCollaborator(userEmail, featuresPermission, classesPermission));
544-
});
545-
546-
let removedCollaborators = setDifference(initialFields.collaborators, changes.collaborators, compareCollaborators);
547-
removedCollaborators.forEach(({ id }) => {
548-
promiseList.push(this.context.currentApp.removeCollaboratorById(id));
549-
});
550-
551-
let editedCollaborators = verifyEditedCollaborators(changes.collaborators);
552-
editedCollaborators.forEach(({ id, featuresPermission, classesPermission }) => {
553-
promiseList.push(this.context.currentApp.editCollaboratorById(id, featuresPermission, classesPermission));
554-
});
542+
if (changes.collaborators !== undefined) {
543+
let addedCollaborators = setDifference(changes.collaborators, initialFields.collaborators, compareCollaborators);
544+
addedCollaborators.forEach(({ userEmail, featuresPermission, classesPermission }) => {
545+
promiseList.push(this.context.currentApp.addCollaborator(userEmail, featuresPermission, classesPermission));
546+
});
547+
548+
let removedCollaborators = setDifference(initialFields.collaborators, changes.collaborators, compareCollaborators);
549+
removedCollaborators.forEach(({ id }) => {
550+
promiseList.push(this.context.currentApp.removeCollaboratorById(id));
551+
});
552+
553+
let editedCollaborators = verifyEditedCollaborators(changes.collaborators);
554+
editedCollaborators.forEach(({ id, featuresPermission, classesPermission }) => {
555+
promiseList.push(this.context.currentApp.editCollaboratorById(id, featuresPermission, classesPermission));
556+
});
557+
}
555558

556559
let urlKeys = {
557560
iTunesURL: 'ios',
@@ -571,7 +574,7 @@ export default class GeneralSettings extends DashboardView {
571574
Parse.Promise.when(promiseList).then(() => {
572575
promise.resolve();
573576
this.forceUpdate(); //Need to forceUpdate to see changes applied to source ParseApp
574-
this.setState({ removedCollaborators: removedCollaborators });
577+
this.setState({ removedCollaborators: removedCollaborators || [] });
575578
}).fail(errors => {
576579
promise.reject({ error: unique(pluck(errors, 'error')).join(' ')});
577580
});

src/lib/AJAX.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ export function put(url, body) {
145145
return request('PUT', url, body);
146146
}
147147

148+
export function patch(url, body) {
149+
return request('PATCH', url, body);
150+
}
151+
148152
// `delete` is a keyword
149153
export function del(url) {
150154
return request('DELETE', url);

src/lib/ParseApp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ export default class ParseApp {
553553
}
554554

555555
setAppName(name) {
556-
let path = '/apps/' + this.slug;
557-
let promise = AJAX.put(path, {'parse_app[name]': name});
556+
let path = `${b4aSettings.BACK4APP_API_PATH}/parse-app/${this.slug}`;
557+
let promise = AJAX.patch(path, {'appName': name});
558558
promise.then(() => {
559559
this.name = name;
560560
});

0 commit comments

Comments
 (0)