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

Feature/new oauth server name #108

Merged
merged 6 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
138 changes: 138 additions & 0 deletions src/configurations/oAuthServerSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand All @@ -16,6 +39,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand All @@ -27,6 +73,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand All @@ -38,6 +107,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand All @@ -51,6 +143,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand All @@ -61,6 +176,29 @@ const oAuthServerSchema = {
preserve_host: false,
listen_path: '',
upstream_url: '',
upstreams: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all upstreams schemas has the same structure we could declare one and reuse over the code, so we don't repeat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally agree, but here is one but:

in future, this schema, probably, will come from the server side...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha!

balancing: '',
targets: [],
options: [
{
balancing: 'roundrobin',
targets: [
{
target: '',
},
],
},
{
balancing: 'weight',
targets: [
{
target: '',
weight: 0,
},
],
}
],
},
insecure_skip_verify: false,
strip_path: false,
append_path: false,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/forms/plugins/Cors/CorsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class CorsPlugin extends PureComponent {
render() {
const { apiSchema, className, edit, name, handlePluginExclude, plugin, pluginName } = this.props;
const b = block(className);
console.error('nem_____', name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad 🥊


const optionsTransformer = config => {
return config.map(item => ({
label: item,
Expand Down
4 changes: 3 additions & 1 deletion src/modules/pages/NewOAuthServerPage/NewOAuthServerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class NewOAuthServerItem extends PureComponent {
}

submit = values => {
this.props.saveOAuthServer(this.props.location.pathname, values);
const transformedValues = transformFormValues(values, true);

this.props.saveOAuthServer(this.props.location.pathname, transformedValues);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function composition would be possible here too, if parameter order does not fit we could reorder it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it would be a bit harder then it looks like at first. I'll investigate and make separate PR related to this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: #110

}

renderForm = () => {
Expand Down
27 changes: 21 additions & 6 deletions src/modules/pages/NewOAuthServerPage/OAuthServerForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,22 @@ class OAuthServerForm extends PureComponent {
<div className={b('tab', { hidden: this.state.activeTab !== 0 })}>
<div className={b('section')}>
<OAuthEndpoints
endpoints={schema.oauth_endpoints}
endpoints={initialValues.oauth_endpoints}
schema={schema}
change={this.props.change}
category={'oauth_endpoints'}
initialValues={initialValues}
/>
</div>
</div>
<div className={b('tab', {hidden: this.state.activeTab !== 1})}>
<div className={b('tab', { hidden: this.state.activeTab !== 1 })}>
<div className={b('section')}>
<OAuthClientEndpoints
endpoints={schema.oauth_client_endpoints}
endpoints={initialValues.oauth_client_endpoints}
schema={schema}
change={this.props.change}
category={'oauth_client_endpoints'}
initialValues={initialValues}
/>
</div>
</div>
Expand Down Expand Up @@ -279,8 +285,10 @@ class OAuthServerForm extends PureComponent {
<Field
name="cors_meta.domains"
type="text"
placeholder={PLACEHOLDER.DOMAINS}
component={Input}
edit={false}
value="cors_meta.domains"
options={optionsTransformer(schema.cors_meta.domains)}
component={TagSelect}
/>
<Hint>A list of all domains from which the endpoint will accept requests</Hint>
</div>
Expand Down Expand Up @@ -432,4 +440,11 @@ const form = reduxForm({
enableReinitialize: true, // this is needed!!
})(OAuthServerForm);

export default form;
export default connect(
state => {
return {
keepDirtyOnReinitialize: false,
};
},
null,
)(form);
Loading