Skip to content

Commit

Permalink
fix: description state management in EnvironmentSettingsPage (#4917)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoapolo authored Dec 16, 2024
1 parent e94e5c6 commit 0223227
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions frontend/web/components/pages/EnvironmentSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const EnvironmentSettingsPage = class extends Component {
{ organisation_id: AccountStore.getOrganisation().id },
{ forceRefetch: true },
).then((roles) => {
if (!roles?.data?.results?.length) return

getRoleEnvironmentPermissions(
getStore(),
{
Expand All @@ -76,7 +78,6 @@ const EnvironmentSettingsPage = class extends Component {
},
{ 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 @@ -156,7 +157,7 @@ const EnvironmentSettingsPage = class extends Component {
api_key: this.props.match.params.environmentId,
})

const { description, name } = this.state
const { name } = this.state
if (ProjectStore.isSaving || !name) {
return
}
Expand All @@ -166,7 +167,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: this.state?.env?.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,17 +366,16 @@ 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?.env?.description ?? ''}
inputProps={{
className: 'input--wide textarea-lg',
}}
onChange={(e) =>
this.setState({
description: Utils.safeParseEventValue(e),
env: {
...this.state.env,
description: Utils.safeParseEventValue(e),
},
})
}
isValid={name && name.length}
Expand Down
2 changes: 2 additions & 0 deletions frontend/web/components/pages/ProjectSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const ProjectSettingsPage = class extends Component {
{ organisation_id: AccountStore.getOrganisation().id },
{ forceRefetch: true },
).then((roles) => {
if (!roles?.data?.results?.length) return

getRoleProjectPermissions(
getStore(),
{
Expand Down

0 comments on commit 0223227

Please sign in to comment.