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

Bare bones feature flags app. Human edits, reads over API #170

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jackie-pc
Copy link
Contributor

TODO: add README

Spell out DB migrations... plus DB_URL for "production" (lol) use.

Comment on lines 43 to 44
if self.feature_flags_as_loaded_from_db is None:
self.load_feature_flags_from_db()
Copy link
Collaborator

Choose a reason for hiding this comment

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

side effects not advised in computed var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent is a "cached property". I.e. load stuff from DB if never loaded before. What would be a better pattern?

E.g. is there logic I can attach to "initialization" of the state?

feature-flags-tmp/feature_flags/feature_flags.py Outdated Show resolved Hide resolved
feature-flags-tmp/feature_flags/feature_flags.py Outdated Show resolved Hide resolved
Comment on lines 22 to 26
new_flag_modal_is_open: bool = False
new_flag_modal_error: Optional[str] = None

new_flag_modal_flag_name: Optional[str] = ""
new_flag_modal_flag_value: Optional[str] = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think the modal-related stuff should go into a substate, then you also wouldn't need reset_new_flag_modal_state, since you could just call self.reset() and use the builtin method if the substate only contained items related to the modal.

Comment on lines 143 to 161
rx.modal_body(
"Add a new feature flag",
rx.hstack(
rx.input(value=FeatureFlagsState.new_flag_modal_flag_name, width='30%',
on_change=FeatureFlagsState.set_new_flag_modal_flag_name),
rx.input(value=FeatureFlagsState.new_flag_modal_flag_value,
on_change=FeatureFlagsState.set_new_flag_modal_flag_value,
width='70%')),
rx.cond(FeatureFlagsState.new_flag_modal_error,
rx.text(FeatureFlagsState.new_flag_modal_error, color="red"))
),
rx.modal_footer(
rx.button(
"Stage", on_click=FeatureFlagsState.new_flag_modal_stage,
),
rx.button(
"Cancel", on_click=FeatureFlagsState.new_flag_modal_cancel,
)
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

possibly a bit nicer to use an rx.form here as then you get <enter> key functionality automatically and don't need to use controlled inputs

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

Successfully merging this pull request may close these issues.

2 participants