Page MenuHomePhabricator

[native] Refactor out EnumSettingsOption into its own component
ClosedPublic

Authored by rohan on Jun 22 2023, 11:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 2:01 PM
Unknown Object (File)
Sat, Nov 23, 2:01 PM
Unknown Object (File)
Sat, Nov 23, 2:00 PM
Unknown Object (File)
Sat, Nov 23, 2:00 PM
Unknown Object (File)
Sat, Nov 23, 2:00 PM
Unknown Object (File)
Mon, Nov 4, 5:13 AM
Unknown Object (File)
Oct 28 2024, 11:27 AM
Unknown Object (File)
Oct 28 2024, 11:27 AM
Subscribers

Details

Summary

A EnumSettingsOption counterpart is used on native during community creation, however it's built into the community configuration screen directly since we don't use it anywhere else on native. I'm going to need something similar for selecting role permissions, so I just made a pretty clean refactor into its own component. I recall there was some talk about needing to confirm the actual designs for checked / unchecked, but for now I've just copied it straight over without any design changes.

The reason icon is an optional prop is because at the moment, the designs for role permissions don't require an icon so it made more sense to just make it optional entirely.

Test Plan

Ran through the community creation flow and logged into another user to confirm that the 'announcement root' setting actually applied (video below). Also I'll show what it looks like if an icon is not provided.

Simulator Screen Shot - iPhone 14 Pro - 2023-06-22 at 14.36.17.png (2×1 px, 145 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rohan edited the test plan for this revision. (Show Details)
native/community-creation/community-configuration.react.js
144 ↗(On Diff #28013)

This is longer than 80 characters since it's a one-line description

rohan published this revision for review.Jun 22 2023, 11:42 AM

Preemptively requesting review for CI failures

Looks good, thanks for taking care of this. Let's re-run CI before landing.

native/community-creation/community-configuration.react.js
144 ↗(On Diff #28013)

We can still split the string so we don't exceed 80 character width. I think that'd be the preferred style for the codebase.

native/components/enum-settings-option.react.js
22 ↗(On Diff #28013)

We can destructure props once so we don't need to write props.icon, props.enumValue, etc

33–36 ↗(On Diff #28013)

Personally prefer

const checkBoxFill = props.enumValue ? (
  <View style={styles.enumCheckBoxFill} />
) : null;

but totally arbitrary, whatever you prefer

37–47 ↗(On Diff #28013)

Could do something like

const infoContainerStyle = React.useMemo(
  () =>
    props.icon
      ? styles.enumInfoContainer
      : { ...styles.enumInfoContainer, marginLeft: 10 },
  [props.icon, styles.enumInfoContainer],
);

but whatever you prefer

This revision is now accepted and ready to land.Jun 26 2023, 7:18 AM

Rebase for CI & address feedback