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

EZEE-2660: 500 error occurs when publishing form in form on the fly #125

Merged
merged 1 commit into from
Jan 21, 2019

Conversation

sunpietro
Copy link
Contributor

https://jira.ez.no/browse/EZEE-2660

For QA

When the Form Builder app is opened inside the COTF modal, then the Publish button is disabled until an editor closes the Form Builder app.

Requires: https://github.com/ezsystems/ezplatform-form-builder/pull/129

@@ -1062,6 +1062,7 @@ export default class UniversalDiscoveryModule extends Component {
onCancel={this.props.onCancel}
handlePublish={this.handlePublish}
restInfo={this.props.restInfo}
setMainContainerRef={this.setMainContainerRef}
Copy link
Contributor

Choose a reason for hiding this comment

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

I realised, after analysing ContentCreatorComponent, that we have here setMainContainerRef={ and not ref={. It was confusing at first. Maybe cleaner would be to wrap ContentCreatorComponent into forwardRef? But I'm not 100% sure. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to rewrite many files to follow the forwardRef convention. But, you're right in other cases I would go with forwardRef as it's a better approach. Here, I wanted to make it simple without to much rewriting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Later I also realised that, actually, we need two refs to be set - we are also missing setContentContainerRef. So, we even cannot use forwardRef as it only works for one reference.

@@ -140,6 +172,9 @@ ContentCreatorComponent.propTypes = {
handlePublish: PropTypes.func.isRequired,
loadLocation: PropTypes.func,
restInfo: PropTypes.object.isRequired,
enablePublishButton: PropTypes.func.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we passing this function (and other 2 below) via props? It seems to be unused inside component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

iframeDoc.body.addEventListener('fbFormBuilderUnloaded', this.enablePublishButton, false);
}

enablePublishButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could merge enablePublishButton with disablePublishButton into togglePublishButton(isDisabled)? This might be cleaner. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it on purpose. I wanted to have a clear path of function calls without a need to look at function/method params. Simpler for debugging in this case, when we are observing async actions caused by events.

@@ -11,23 +11,32 @@ export default class ContentCreatorComponent extends Component {

this.handleIframeLoad = this.handleIframeLoad.bind(this);
this.handlePublish = this.handlePublish.bind(this);
this.enablePublishButton = this.enablePublishButton.bind(this);
this.disablePublishButton = this.disablePublishButton.bind(this);
this.renderPublishBtn = this.renderPublishBtn.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to bind it to this, as far as I can see.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this. 🙂

type: 'button',
};

if (this.state.publishBtnDisabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, cleaner would be to add disabled: this.state.publishBtnDisabled to attrs above and remove if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I want to set attrs.disabled when needed. I don't want to pass attrs.disabled with undefined value.

Copy link
Contributor

Choose a reason for hiding this comment

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

With approach that I suggested attrs.disabled would never be undefined.

this.renderPublishBtn = this.renderPublishBtn.bind(this);

this._refIframe = null;
this._refContentContainer = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it seems to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

@katarzynazawada katarzynazawada self-assigned this Jan 9, 2019
@@ -11,23 +11,32 @@ export default class ContentCreatorComponent extends Component {

this.handleIframeLoad = this.handleIframeLoad.bind(this);
this.handlePublish = this.handlePublish.bind(this);
this.enablePublishButton = this.enablePublishButton.bind(this);
this.disablePublishButton = this.disablePublishButton.bind(this);
this.renderPublishBtn = this.renderPublishBtn.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this. 🙂

katarzynazawada
katarzynazawada previously approved these changes Jan 9, 2019
@sunpietro sunpietro force-pushed the ezee-2660-fix-cotf-with-form-builder branch from c09785a to 4dd7f64 Compare January 21, 2019 08:00
@sunpietro sunpietro changed the base branch from master to 1.4 January 21, 2019 08:00
@sunpietro
Copy link
Contributor Author

@lserwatka the base branch has just been changed

@lserwatka lserwatka merged commit 7848245 into 1.4 Jan 21, 2019
@lserwatka lserwatka deleted the ezee-2660-fix-cotf-with-form-builder branch January 21, 2019 10:54
@lserwatka
Copy link
Member

You can merge it up.

@sunpietro
Copy link
Contributor Author

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants