Skip to content

Commit

Permalink
fix: description state management in EnvironmentSettingsPage
Browse files Browse the repository at this point in the history
Ref: #4841
  • Loading branch information
tiagoapolo committed Dec 12, 2024
1 parent 3434eb7 commit 8fab50b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions frontend/web/components/pages/EnvironmentSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const EnvironmentSettingsPage = class extends Component {
const env = ProjectStore.getEnvs().find(
(v) => v.api_key === this.props.match.params.environmentId,
)
this.setState({ env })
this.setState({ env, description: env.description ?? "" })
getRoles(
getStore(),
{ organisation_id: AccountStore.getOrganisation().id },
Expand All @@ -72,11 +72,10 @@ const EnvironmentSettingsPage = class extends Component {
{
env_id: env.id,
organisation_id: AccountStore.getOrganisation().id,
role_id: roles.data.results[0].id,
role_id: roles?.data?.results[0]?.id,
},
{ forceRefetch: true },
).then((res) => {
debugger
const matchingItems = roles.data.results.filter((item1) =>
res.data.results.some((item2) => item2.role === item1.id),
)
Expand Down Expand Up @@ -166,7 +165,7 @@ const EnvironmentSettingsPage = class extends Component {
allow_client_traits: !!this.state.allow_client_traits,
banner_colour: this.state.banner_colour,
banner_text: this.state.banner_text,
description: description || env.description,
description,
hide_disabled_flags: this.state.hide_disabled_flags,
hide_sensitive_data: !!this.state.hide_sensitive_data,
minimum_change_request_approvals: has4EyesPermission
Expand Down Expand Up @@ -365,11 +364,7 @@ const EnvironmentSettingsPage = class extends Component {
<InputGroup
textarea
ref={(e) => (this.input = e)}
value={
typeof this.state.description === 'string'
? this.state.description
: env.description
}
value={this.state.description}
inputProps={{
className: 'input--wide textarea-lg',
}}
Expand Down

0 comments on commit 8fab50b

Please sign in to comment.