From 2df50b833edb3d65ba7252c52b056ebd87107f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 19 Dec 2018 09:30:36 +0100 Subject: [PATCH] Add constructor --- .../src/main/js/RepositoryConfig.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.js b/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.js index 4fa6c09930..ecb3281ec2 100644 --- a/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.js +++ b/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.js @@ -15,15 +15,28 @@ type State = { loadingBranches: boolean, loadingDefaultBranch: boolean, submitPending: boolean, - error: Error, + error?: Error, branches: Branch[], - selectedBranchName: string, + selectedBranchName?: string, defaultBranchChanged: boolean }; const GIT_CONFIG_CONTENT_TYPE = "application/vnd.scmm-gitConfig+json"; class RepositoryConfig extends React.Component { + + constructor(props: Props) { + super(props); + + this.state = { + loadingBranches: true, + loadingDefaultBranch: true, + submitPending: false, + branches: [], + defaultBranchChanged: false + }; + } + componentDidMount() { const { repository } = this.props; this.setState({ ...this.state, loadingBranches: true }); @@ -53,10 +66,10 @@ class RepositoryConfig extends React.Component { branchSelected = (branch: Branch) => { if (!branch) { - this.setState({ ...this.state, selectedBranchName: null }); + this.setState({ ...this.state, selectedBranchName: null , defaultBranchChanged: false}); return; } - this.setState({ ...this.state, selectedBranchName: branch.name }); + this.setState({ ...this.state, selectedBranchName: branch.name, defaultBranchChanged: false }); }; submit = (event: Event) => {