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

Feature Request : Plugin Architecture (Features as Plugins) #1339

Closed
4 tasks done
SiddheshKukade opened this issue Jul 21, 2022 · 2 comments · Fixed by #1340
Closed
4 tasks done

Feature Request : Plugin Architecture (Features as Plugins) #1339

SiddheshKukade opened this issue Jul 21, 2022 · 2 comments · Fixed by #1340
Assignees
Labels
feature request unapproved Unapproved, needs to be triaged

Comments

@SiddheshKukade
Copy link
Member

SiddheshKukade commented Jul 21, 2022

This issue is associated with Google Summer of Code 2022 Project link

Is your feature request related to a problem? Please describe.
Problem statement taken from Project Ideas Page :

Latent features in the mobile app should be enabled by installing plugins via the Admin web portal. The API would need to detect the existence of a plugin, and automatically query the plugin for authorization to do some action. When authorized, the mobile app will display new capabilities.

Describe the solution you'd like
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
  }
}
  ''';

Describe alternatives you've considered
No. but alternatives can be suggested by the mentors

Approach to be followed (optional)
Above tasks will be carried out one by one.

Additional context
Not required.

@SiddheshKukade
Copy link
Member Author

@palisadoes Sir this issue can be assigned to be

@github-actions github-actions bot added the unapproved Unapproved, needs to be triaged label Jul 21, 2022
@github-actions
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request unapproved Unapproved, needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant