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

feat: add plugin slot to Footer using FPF #302

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

jsnwesson
Copy link
Contributor

@jsnwesson jsnwesson commented Mar 14, 2024

Description

This PR installs the master branch of Frontend Plugin Framework library into Learner Record. The primary goal of this PR is:

  • confirm FPF can be installed in an MFE and not break anything at Prod level
  • confirm FPF can wrap a Plugin Slot around a React dependency (frontend-component-footer) and insert an arbitrary plugin in the same slot

This PR also includes:

  • update frontend-build patch to remove require statement, which prevented any import in the env.config.js.

To test this locally:

  1. Run npm install
  2. At the root directory, create an env.config.jsx file that includes the following:
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@edx/frontend-plugin-framework/src';

const config = {
  pluginSlots: {
    footer_plugin_slot: {
      keepDefault: true,
      plugins: [
        {
          op: PLUGIN_OPERATIONS.Insert,
          widget: {
            id: 'hidden_plugin',
            type: DIRECT_PLUGIN,
            priority: 60,
            RenderWidget: () => (
              <div className="empty-plugin" />
            ),
          },
        },
      ],
    },
  },
};

export default config;
  1. Run npm run start
  2. Go to https://localhost:1990
  3. An empty <div> should be underneath the <Footer> tag when you inspect the source code.

Ways to play around with this

  1. Add a <p> inside the div that shows some text.
  2. Set keepDefault to false in JS config to hide Footer and still insert empty div
  3. Remove env.config.jsx completely to ensure Footer isn't affected by a missing config (note: keepDefault defaults to true on FPF's side, which is why the Footer is still present without the JS config)

Screenshots

Insert empty div plugin

Screenshot 2024-03-14 at 1 18 49 PM

Remove env.config.jsx entirely

Screenshot 2024-03-14 at 1 21 02 PM

APER-3275

* env.config.jsx won't be able to use 'import' statement for FPF if 'require' statement remains in webpack config
* the 'require' statement was used in dev config to use PORT provided by env.config
* the 'require' statment was used in prod config to assign some env variables if they existed in JS config
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.22%. Comparing base (6fc43c6) to head (58111e0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #302   +/-   ##
=======================================
  Coverage   70.22%   70.22%           
=======================================
  Files          27       27           
  Lines         403      403           
  Branches       85       85           
=======================================
  Hits          283      283           
  Misses        119      119           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@deborahgu deborahgu left a comment

Choose a reason for hiding this comment

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

🎉 🎈 :shipit:

@jsnwesson jsnwesson merged commit fa43c9d into master Mar 18, 2024
8 checks passed
@jsnwesson jsnwesson deleted the jwesson/fpf-component-footer branch March 18, 2024 16:56
+ staticAssetUrl: envConfig.BASE_URL || process.env.BASE_URL,
// upload source maps in prod builds only
noop: typeof process.env.NEW_RELIC_ADMIN_KEY === 'undefined',
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

We're going to have to remove this patch, I think. See openedx/frontend-build#515 (comment).

@MaxFrank13 MaxFrank13 mentioned this pull request May 2, 2024
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.

4 participants