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

fix: description state management in EnvironmentSettingsPage #4917

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

tiagoapolo
Copy link
Contributor

@tiagoapolo tiagoapolo commented Dec 12, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  • Checks for roles empty list
  • Fix description field state management, conflicting value from what comes from the backend and what is stored in the component's state

Before

not_fixed.mov

After

fixed.mov

How did you test this code?

Please describe.

@tiagoapolo tiagoapolo requested a review from a team as a code owner December 12, 2024 15:40
@tiagoapolo tiagoapolo requested review from kyle-ssg and removed request for a team December 12, 2024 15:40
Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 1:06pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 1:06pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Dec 16, 2024 1:06pm

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard fix labels Dec 12, 2024
Copy link
Contributor

github-actions bot commented Dec 12, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-4917 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-4917 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4917 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4917 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4917 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4917 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-4917 Finished ✅ Results

@tiagoapolo tiagoapolo requested review from zachaysan, matthewelwell, a team and kyle-ssg and removed request for kyle-ssg and a team December 12, 2024 15:40
Copy link
Contributor

github-actions bot commented Dec 12, 2024

Uffizzi Preview deployment-59060 was deleted.

@@ -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 ?? "" })
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm interested to know why description has to be handled differently? Shouldn't it just be updated as part of the environment object? 🤔

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 approach here was to make sure we're consistent in how we're getting and updating the data from, previously we were mixing internal states with context one, which in my opinion is more confusing and prone to bugs. So, either using environment object or description internal states is fine.

  value={
    typeof this.state.description === 'string'
      ? this.state.description
      : env.description
  }

Ref: #4841

check for empty roles list

unifies description state management from env state

check roles
Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

This looks good to me now.

The only think that I noticed which might be relevant to think about (in a separate issue) is the fact that there is no warning that any in progress edits will be lost when switching between environments.

So, for example, if you're editing the description of your development environment, then switch to your production environment to check something, your edits from the development environment will be lost. I guess the slightly interesting quirk of the previous (buggy) behaviour is that this wasn't an issue!

@tiagoapolo can you create a separate issue to tackle this? I think we should just add a warning when you navigate away if the environment settings haven't been saved.

@tiagoapolo tiagoapolo merged commit 0223227 into main Dec 16, 2024
31 checks passed
@tiagoapolo tiagoapolo deleted the fix/env-description branch December 16, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants