portagenetwork / roadmap

Developed by the the Alliance in collaboration with University of Alberta, DMP Assistant a data management planning tool, forking the DMP Roadmap codebase
MIT License
6 stars 1 forks source link

Add feature flag for sandbox environment #159

Open lagoan opened 2 years ago

lagoan commented 2 years ago

Add feature flags beyond configuration values in order to control available behaviour in the sandbox environment. Initially, we will only need this to:

At this point, we can do something very simple as outlined here which can include simple logic.

In essence, we will be adding a class like

class Feature
  def self.enabled?(feature_name)
    case feature_name.to_sym
    when :sandbox
      # Should we allow super users to make changes in sandbox?
      Rails.env.sandbox? 
    else
      true
    end
  end
end

We can use simple if statements to block off code

if Feature.enabled?(:sandbox)
   # Code to be shown only in the sandbox environment
end

We can add different logic to provide super users Current.user.can_super_admin? different access in the application.

pengyin-shan commented 2 years ago

Pending task now:

pengyin-shan commented 1 year ago

@lagoan unfortunately, I don't think I can work on this in my last few hours with U of A...However, I think this could be a good first-time issue to assign to the new developer. I also suggest that the new developer contribute this back to the main codebase since the feature_flag_helper.rb file and our flag feature differentiate our code from the main codebase.