-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Have base to be release20 * Nitpick change on index
- Loading branch information
1 parent
acf4157
commit 5eed248
Showing
9 changed files
with
140 additions
and
105 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import "./checkout/example"; | ||
import "./settings/example"; | ||
import "./settings/templates/example"; |
41 changes: 41 additions & 0 deletions
41
imports/plugins/included/payments-example/client/settings/components/exampleSettingsForm.js
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,41 @@ | ||
import React, { Component, PropTypes } from "react"; | ||
import { FieldGroup, Translation } from "/imports/plugins/core/ui/client/components"; | ||
|
||
class ExampleSettingsForm extends Component { | ||
render() { | ||
const { packageData } = this.props; | ||
|
||
return ( | ||
<div> | ||
{ !packageData.settings.apiKey && | ||
<div className="alert alert-info"> | ||
<Translation defaultValue="Example Credentials" i18nKey="admin.paymentSettings.exampleCredentials"/> | ||
</div> | ||
} | ||
|
||
<form onSubmit={this.props.onSubmit}> | ||
<FieldGroup | ||
label="API Key" | ||
name="apiKey" | ||
type="text" | ||
onChange={this.props.onChange} | ||
/> | ||
|
||
<button className="btn btn-primary pull-right" type="submit"> | ||
<Translation defaultValue="Save Changes" i18nKey="app.saveChanges"/> | ||
</button> | ||
</form> | ||
|
||
</div> | ||
); | ||
} | ||
} | ||
|
||
ExampleSettingsForm.propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
onSubmit: PropTypes.func.isRequired, | ||
packageData: PropTypes.object | ||
}; | ||
|
||
export default ExampleSettingsForm; | ||
|
1 change: 1 addition & 0 deletions
1
imports/plugins/included/payments-example/client/settings/components/index.js
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 @@ | ||
export { default as ExampleSettingsForm } from "./exampleSettingsForm.js"; |
80 changes: 80 additions & 0 deletions
80
...gins/included/payments-example/client/settings/containers/exampleSettingsFormContainer.js
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,80 @@ | ||
import React, { Component, PropTypes } from "react"; | ||
import { Meteor } from "meteor/meteor"; | ||
import { composeWithTracker } from "/lib/api/compose"; | ||
import { Packages } from "/lib/collections"; | ||
import { Loading } from "/imports/plugins/core/ui/client/components"; | ||
import { TranslationProvider } from "/imports/plugins/core/ui/client/providers"; | ||
import { Reaction, i18next } from "/client/api"; | ||
import { ExampleSettingsForm } from "../components"; | ||
|
||
class ExampleSettingsFormContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
apiKey: "" | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
this.saveUpdate = this.saveUpdate.bind(this); | ||
} | ||
|
||
handleChange(e) { | ||
e.preventDefault(); | ||
this.setState({ apiKey: e.target.value }); | ||
} | ||
|
||
handleSubmit(e) { | ||
e.preventDefault(); | ||
|
||
const packageId = this.props.packageData._id; | ||
const settingsKey = this.props.packageData.registry[0].settingsKey; | ||
const apiKey = this.state.apiKey; | ||
|
||
const fields = [{ | ||
property: "apiKey", | ||
value: apiKey | ||
}]; | ||
|
||
this.saveUpdate(fields, packageId, settingsKey); | ||
} | ||
|
||
saveUpdate(fields, id, settingsKey) { | ||
Meteor.call("registry/update", id, settingsKey, fields, (err) => { | ||
if (err) { | ||
return Alerts.toast(i18next.t("admin.settings.saveFailed"), "error"); | ||
} | ||
return Alerts.toast(i18next.t("admin.settings.saveSuccess"), "success"); | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<TranslationProvider> | ||
<ExampleSettingsForm | ||
onChange={this.handleChange} | ||
onSubmit={this.handleSubmit} | ||
packageData={this.props.packageData} | ||
/> | ||
</TranslationProvider> | ||
); | ||
} | ||
} | ||
|
||
ExampleSettingsFormContainer.propTypes = { | ||
packageData: PropTypes.object | ||
}; | ||
|
||
const composer = ({}, onData) => { | ||
const subscription = Meteor.subscribe("Packages"); | ||
if (subscription.ready()) { | ||
const packageData = Packages.findOne({ | ||
name: "example-paymentmethod", | ||
shopId: Reaction.getShopId() | ||
}); | ||
onData(null, { packageData }); | ||
} | ||
}; | ||
|
||
export default composeWithTracker(composer, Loading)(ExampleSettingsFormContainer); |
1 change: 1 addition & 0 deletions
1
imports/plugins/included/payments-example/client/settings/containers/index.js
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 @@ | ||
export { default as ExampleSettingsFormContainer } from "./exampleSettingsFormContainer"; |
58 changes: 0 additions & 58 deletions
58
imports/plugins/included/payments-example/client/settings/example.html
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
imports/plugins/included/payments-example/client/settings/example.js
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
imports/plugins/included/payments-example/client/settings/templates/example.html
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,5 @@ | ||
<template name="exampleSettings"> | ||
<div> | ||
{{> React ExampleSettings}} | ||
</div> | ||
</template> |
11 changes: 11 additions & 0 deletions
11
imports/plugins/included/payments-example/client/settings/templates/example.js
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,11 @@ | ||
import { ExampleSettingsFormContainer } from "../containers"; | ||
import { Template } from "meteor/templating"; | ||
import "./example.html"; | ||
|
||
Template.exampleSettings.helpers({ | ||
ExampleSettings() { | ||
return { | ||
component: ExampleSettingsFormContainer | ||
}; | ||
} | ||
}); |