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: folding code to minimize footprint or distractions #47

Closed
frehov opened this issue Feb 8, 2021 · 2 comments · Fixed by #48
Closed

feature request: folding code to minimize footprint or distractions #47

frehov opened this issue Feb 8, 2021 · 2 comments · Fixed by #48
Assignees

Comments

@frehov
Copy link

frehov commented Feb 8, 2021

I would like to request the addition of code folding inside the rules-file.

I believe it would be beneficial to have such functionality if you have large and/or are implementing a large amount of custom functions to help validate.

We have a case where code folding would come in handy, and be able to collapse the entire match path for a collection.
We have - for now- 3 functions within the scope of the match path of a collection, and we are unit testing our rules, so after our tests pass there's no need to focus on that section anymore and it would be beneficial to be able to collapse it down again.

match /users/{user} {
  function isSelf() {
    return request.auth.uid == resource.id;
  }

  function isAllowedToReadAnotherUser() {
    let user = get(/databases/$(database)/documents/users/$(request.auth.uid));
    return userHasRole(user, ["role_1", "role_2"]);
  }

  function isAllowedToChangeAnotherUser() {
    let user = get(/databases/$(database)/documents/users/$(request.auth.uid));
    return userHasRole(user, ["role_2"]);
  }

  allow read: if isSignedIn() && (isSelf() || isAllowedToReadAnotherUser());
  allow write: if isSignedIn() && isAllowedToChangeAnotherUser();
}

the above is an example block which would have been nice to have to collapse into the following

match /users/{user} { ... }

I believe this reference should be of help. https://plugins.jetbrains.com/docs/intellij/folding-builder.html#define-a-folding-builder

@dalgarins
Copy link
Contributor

Captura de Pantalla 2021-02-14 a la(s) 7 59 53 a  m

@frehov Thanks for comments, the feature will be available for version: 2.4.0

@dalgarins dalgarins linked a pull request Feb 14, 2021 that will close this issue
@frehov
Copy link
Author

frehov commented Feb 16, 2021

thanks for the update, this has really made my day so much easier when dealing with the firebase rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants