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

🪟🔧 Refactor feature service #14559

Merged
merged 10 commits into from
Jul 15, 2022
Merged

🪟🔧 Refactor feature service #14559

merged 10 commits into from
Jul 15, 2022

Conversation

timroes
Copy link
Contributor

@timroes timroes commented Jul 10, 2022

What

Closes #10974

This refactors the feature service and detaches it from the configService (to unblock #10955). The PR does the following things:

  • Get static features passed into the Provider instead of pulling them from the config.
  • Simplify the syntax a bit, so we don't need to specify features as an empty object with a single id property anymore, but can use a simpler format.
  • Split features into three levels: global features (passed in as a property to the provider), workspace features, user features, feature overwrites, where the latter in that list will overwrite the earlier ones in that list e.g. if globally allow connection creation is on, but it's disabled per workspace feature that will take precedence.
  • Note: user features are currently not used, but I can see how we in the future want to enable/disable specific features based on users as well.
  • Allow overwriting enabled/disabled features via LaunchDarkly for Cloud (this e.g. would allow us to quickly disable all connection creation in Cloud).
  • Simply the consuming syntax a bit and make it a tiny bit more intuitive. hasFeature is now useFeature. It will cause a re-render if a feature changed. Earlier the hasFeature method itself would be recreated (and thus have a changed reference), when a feature changed, which imho isn't the most intuitive to understand.
  • Rename WithFeature component to OnlyWithFeature to make the name express a bit clearer what it does.
  • Adding lots of unit tests for the feature service.

@timroes timroes added area/frontend technical-debt issues to fix code smell area/frontend Related to the Airbyte webapp labels Jul 10, 2022
@timroes timroes requested a review from a team as a code owner July 10, 2022 12:41
@github-actions github-actions bot added the area/platform issues related to the platform label Jul 10, 2022
@timroes timroes changed the title Refactor feature service 🪟🔧 Refactor feature service Jul 10, 2022
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Code looks good. I have some minor feedback.

@@ -38,7 +38,9 @@ const Services: React.FC = ({ children }) => (
<NotificationServiceProvider>
<ConfirmationModalService>
<FormChangeTrackerService>
<FeatureService>
<FeatureService
features={[FeatureItem.AllowOAuthConnector, FeatureItem.AllowCreateConnection, FeatureItem.AllowSync]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Like OSS, maybe this should be moved to a defaultFeatures const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to have it inline, given that we're not needing to import it anywhere else, it would just make the code more fragmented and requires you to follow into other files to see the feature set. I'd also have kept the OSS one inline if we wouldn't have needed to import it for the tests (and even considered just duplicate it into the tests).

return () => {
setWorkspaceFeatures(undefined);
};
}, [cloudWorkspace, setWorkspaceFeatures]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just need the cloudWorkspace.creditStatus as a dep

<FeatureService>{children}</FeatureService>
</ConfigContext.Provider>
</TestWrapper>
<FeatureService features={[FeatureItem.AllowCreateConnection, FeatureItem.AllowSync]}>{children}</FeatureService>
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to have the features in a constant such as defaultFeatures so that it can be referenced later in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally would prefer keeping it that way. Most of the tests tests different combinations of enabling/disabling, why we can't spread that anyway simply into it. Also given that those tests all test whether overwriting etc work, I'd prefer if someone ever adjust this line, manually also needs to adjust the expect cases below, to sanity check that the overwrite logic is really working as expected.

@timroes timroes requested a review from edmundito July 14, 2022 17:11
@timroes timroes merged commit 994f781 into master Jul 15, 2022
@timroes timroes deleted the tim/refactor-feature-service branch July 15, 2022 07:29
jsrcodes added a commit to jsrcodes/airbyte that referenced this pull request Jul 15, 2022
…rbytehq-master

* 'master' of https://github.com/airbytehq/airbyte: (1141 commits)
  pass USE_STREAM_CAPABLE_STATE env var to containers/deployments (airbytehq#14737)
  Bump mqtt connector (airbytehq#14648)
  Add error code to ManualOperationResult (airbytehq#14657)
  Bump elasticsearch version (airbytehq#14640)
  Ryan/sync oracle version number (airbytehq#14736)
  Fixed linter issue with add_fields.py comments (airbytehq#14742)
  🎉Redshift, Databricks, Snowflake, S3 Destinations: Make S3 output filename configurable (airbytehq#14494)
  🐛Source-mssql: aligned regular and cdc syncs and its datatype tests (airbytehq#14379)
  🎉 Source Amazon Seller Partner: Add new streams (airbytehq#13604)
  bump source-file-secure (airbytehq#14704)
  🎉 New source: Timely airbytehq#13292 (airbytehq#14335)
  🪟🔧 Refactor feature service (airbytehq#14559)
  [low code cdk] add a transformation for adding fields into an outgoing record (airbytehq#14638)
  Bump destination-postgres to 0.3.21 (airbytehq#14479)
  Remove `additionalProperties: false` from JDBC destination connectors (airbytehq#14618)
  🎉 Source Notion: add OAuth authorization for source-notion connector (airbytehq#14706)
  Use the configuration diff calculation in the update endpoint (airbytehq#14626)
  🪟 🐛 Fix input validation on blur and cleanup signup error handling (airbytehq#14724)
  lower sleep after wait for successful job (airbytehq#14725)
  Add configuration diff (airbytehq#14603)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform technical-debt issues to fix code smell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split FeatureService from ConfigService
2 participants