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

[ACS-3895] ACA - Folder Rules: inherit rule sets toggle #2808

Conversation

nikita-web-ua
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation
  • Other... Please describe:

What is the current behaviour? (You can also link to an open issue here)

Currently in ACA, the user does not have the ability to choose whether a folder should inherit folder rule sets from parent folders or not.

What is the new behaviour?

Each folder has a button to toggle whether it should inherit folder rule sets from its parent folders.
Screenshot 2022-11-23 at 17 53 08

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@pr-triage pr-triage bot added the PR: draft label Nov 23, 2022
@nikita-web-ua nikita-web-ua marked this pull request as ready for review November 23, 2022 17:02
Copy link
Contributor

@TomikaArome TomikaArome left a comment

Choose a reason for hiding this comment

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

Good work!

Your method is fine, and I'm sure works well, but I'll admit it's not what I would have done. I'm not going to request changes due to the short time frame we have but see my review for what I think is a better approach.

Feel free to attempt it this afternoon if you're up to it and don't have anything else to do, otherwise I'm happy enough with this and you can merge it before the end of the day so it's hopefully propagated to the remote environment tomorrow.

@@ -49,6 +50,8 @@ import { RuleSet } from '../model/rule-set.model';
})
export class ManageRulesSmartComponent implements OnInit, OnDestroy {
nodeId = '';
isInheritanceEnabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have this as an observable in FolderRuleSetsService instead?

Comment on lines +98 to +101
this.folderRulesService.getRuleSettings(this.nodeId).then((ruleSettings) => {
this.isInheritanceEnabled = ruleSettings.value;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We should load this at the same time as loadRuleSets(this.nodeId) in the FolderRuleSetsService. Like that it will be part of the initial loading of the page and use the same mat progress bar for everything.

@@ -152,6 +152,16 @@ export class FolderRulesService {
);
}

async getRuleSettings(nodeId: string, key: string = '-isInheritanceEnabled-'): Promise<RuleSettings> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the rule set service handles the node id, this should be in FolderRuleSetsService. We can load it at the same time in the loadRuleSets method by adding it in the combineLatest, here:

switchMap(() => combineLatest(
  this.getMainRuleSet(nodeId),
  loadInheritedRuleSets ? this.getInheritedRuleSets(nodeId) : of([])
))

This could become:

switchMap(() => combineLatest(
  this.getMainRuleSet(nodeId),
  loadInheritedRuleSets ? this.getInheritedRuleSets(nodeId) : of([]),
  this.getFolderInheritance(nodeId)
))

and then using the value in the subscribe to emit to the isFolderInheritanceEnabledSource BehaviourSubject.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made getRuleSettings more generic, so it could be used in future with other parameters. Do you suggest to redesign it to getFolderInheritance for now, so it will only load data for isInheritanceEnabled$?

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering it's likely the only rules / rule sets related setting for folders that we have, I don't think it's necessary to make it generic like this. Is this endpoint one of the new private ones? Did you check if there a generic js-api method that could allow you to call this endpoint and then use the folder rule (sets) service to be more specific about isInheritanceEnabled?

@nikita-web-ua nikita-web-ua force-pushed the feature/dev-mmaliarchuk-ACS-3895-folder-rules-inherit-rule-sets-toggle branch from 731cb33 to 2fd10a0 Compare November 24, 2022 16:56
@nikita-web-ua nikita-web-ua merged commit 60ba8eb into develop Nov 24, 2022
@nikita-web-ua nikita-web-ua deleted the feature/dev-mmaliarchuk-ACS-3895-folder-rules-inherit-rule-sets-toggle branch November 24, 2022 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants