pnp / sp-dev-fx-aces

Repository for the Microsoft Viva Connections Adaptive Card sample solutions from Microsoft and community.
https://aka.ms/viva/connections/extensibility
MIT License
109 stars 92 forks source link

Hide cardview in init method #94

Closed harshdamaniahd closed 2 years ago

harshdamaniahd commented 2 years ago

is it possible to hide cardview i.e hide the entire card based on a condition ?

dcashpeterson commented 2 years ago

@harshdamaniahd You can do that. There are two ways to handle it. 1) you can use audience targeting. Put the users that can see the ACE in a group and the only show it to them. This is set in the properties pane. 2) You can set the isVisible property on the card in the init method. There is an example here. https://github.com/pnp/sp-dev-fx-aces/tree/main/samples/ImageCard-HideACE/src/adaptiveCardExtensions/hideAce

harshdamaniahd commented 2 years ago

Hey thanks @dcashpeterson , i tried the isVisible property, but the card always loads image

So what i want to do is that, if a user profile property is not updated the show card , else do not show card. So i was testing isVisible property, but it doesnt work.

Should i test it by deploying it ?

dcashpeterson commented 2 years ago

@harshdamaniahd as I said, you need to do it in the init method. Look at the example. It works off of local storage but you can substitute your user profile code there.

harshdamaniahd commented 2 years ago

Yes i have written it in init method only @dcashpeterson

  public onInit(): Promise<void> {

    this.state = { };
    debugger;

   this.isVisible=false;

   this.cardNavigator.register(CARD_VIEW_REGISTRY_ID, () => new CardView());
    this.quickViewNavigator.register(QUICK_VIEW_REGISTRY_ID, () => new QuickView());

    return Promise.resolve();
  } 
dcashpeterson commented 2 years ago

@harshdamaniahd I can't speak for the rest of your code but I just tried a new ACE using 1.15.2 and the code you posted works just fine and hides the ACE. I am guessing that it is something else other than the isVisible property and that the init is erroring out before it gets to that line.

harshdamaniahd commented 2 years ago

Hi , it works after deploying , doesnt work on workbench for me

dcashpeterson commented 2 years ago

@harshdamaniahd This repo is for issues related to the different ACE samples. If you are having issues getting your code to work the best place to post would be SP-Dev-Docs. That repo has a lot more eyes on it. That said, it sounds like the graph token isn't working the way you expect to in the workbench.