Skip to content

Conversation

SiddheshKukade
Copy link
Member

@SiddheshKukade SiddheshKukade commented Jul 21, 2022

This Pull Request is associated with Google Summer of Code 2022 Project link

What kind of change does this PR introduce?

Feature Request #1339

Issue Number:

Fixes #1339

Did you add tests for your changes?
Yes

Snapshots/Videos:
Not Needed

If relevant, did you update the documentation?

Not required

Summary
Plugin are features which can toggled to enable or disable by the talawa-admin application with proper authorization
This project has two parts:

  • The design and development of the plugin architecture

  • Create TalwaPluginProvider widget in flutter which can control visibility of the UI according to the visibility property set by the admin. It can look like this

class TalawaPluginProvider extends StatelessWidget {
  const TalawaPluginProvider(
      {Key? key,
      @required this.child,
      required this.visible,
      required this.pluginName})
      : super(key: key);

  ///child contains the widget for the plugin UI.
  final Widget? child;

  ///visible is the property that decides visibility of the UI.
  final bool visible;

  ///name of plugin preferred with underscores(_) insted of spaces
  final String pluginName;

  ///return `bool` decides the final visibility of the verifying from database and current OrgId
  bool checkFromPluginList() {
    final UserConfig _userConfig = locator<UserConfig>();
    final Box box;
    bool res = false;
    box = Hive.box('pluginBox');
    final pluginList = box.get('plugins');

    ///mapping over the list from the server
    pluginList
        .map((plugin) => {
              if (plugin["pluginName"] == pluginName)
                {
                  if (plugin["pluginInstallStatus"] as bool)
                    {
                      res = plugin["pluginInstallStatus"] as bool ||
                          plugin["installedOrgs"]
                              .contains(_userConfig.currentOrg.id) as bool
                    }
                }
            })
        .toList();
    return res;
  }

  ///build the Plugin combining local `visibility` property and `serverVisible` property
  @override
  Widget build(BuildContext context) {
    var serverVisible = false;
    serverVisible = checkFromPluginList();
    return Visibility(visible: serverVisible || visible, child: child!);
  }
  • fetch_plugin_list function which will load the new list of plugin after the app is restarted
  • Store the plugin data is Hive Box
  • Add the query for 'fetchPlugins' . It can look like this:
  ///`getPluginList` queries all properties of  pluginList from the server
  String getPluginsList() {
    return '''
query  {
  getPlugins {
    _id
    pluginName
    pluginCreatedBy
    pluginDesc 
    pluginInstallStatus
    installedOrgs
  }
}
  ''';

Does this PR introduce a breaking change?

No

Other information
Not Required.

Have you read the contributing guide?

Yes

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

@SiddheshKukade
Copy link
Member Author

@JamaicanFriedChicken
@DMills27
would like to have your thoughts on current changes.

@SiddheshKukade SiddheshKukade marked this pull request as ready for review July 24, 2022 06:31
@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2022

Codecov Report

Merging #1340 (c42eff5) into develop (d87c8db) will decrease coverage by 0.21%.
The diff coverage is 42.74%.

❗ Current head c42eff5 differs from pull request most recent head 7fbc732. Consider uploading reports for the commit 7fbc732 to get more accurate results

@@             Coverage Diff             @@
##           develop    #1340      +/-   ##
===========================================
- Coverage    71.10%   70.89%   -0.22%     
===========================================
  Files          127      131       +4     
  Lines         6379     6589     +210     
===========================================
+ Hits          4536     4671     +135     
- Misses        1843     1918      +75     
Impacted Files Coverage Δ
lib/main.dart 1.49% <0.00%> (-0.07%) ⬇️
lib/models/chats/chat_message.dart 0.00% <ø> (ø)
lib/models/chats/chat_message.g.dart 0.00% <0.00%> (ø)
lib/models/events/event_model.dart 3.03% <0.00%> (-0.20%) ⬇️
lib/plugins/fetch_plugin_list.dart 0.00% <0.00%> (ø)
lib/router.dart 32.22% <0.00%> (-2.72%) ⬇️
lib/services/chat_service.dart 0.00% <0.00%> (ø)
lib/services/database_mutation_functions.dart 6.52% <0.00%> (ø)
lib/services/event_service.dart 15.38% <0.00%> (-2.01%) ⬇️
lib/services/graphql_config.dart 62.06% <ø> (+20.68%) ⬆️
... and 40 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Member

@DMills27 DMills27 left a comment

Choose a reason for hiding this comment

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

Add a couple more tests to get the code coverage higher such that it will pass all the criteria to be merged. Other than that it looks good! Good job!

@SiddheshKukade
Copy link
Member Author

Add a couple more tests to get the code coverage higher such that it will pass all the criteria to be merged. Other than that it looks good! Good job!

Sir I have added some tests now 👍🏻

@SiddheshKukade SiddheshKukade requested a review from DMills27 July 27, 2022 16:52
@SiddheshKukade
Copy link
Member Author

@palisadoes Please provide the workflow approval for this PR
image

Copy link
Member

@DMills27 DMills27 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@palisadoes palisadoes merged commit 4476e78 into PalisadoesFoundation:develop Aug 15, 2022
@SiddheshKukade SiddheshKukade changed the title Feature Request : Plugin Architecture (Features as Plugins) [GSoC] Feature Request : Plugin Architecture (Features as Plugins) Nov 19, 2022
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.

Feature Request : Plugin Architecture (Features as Plugins)
5 participants