Skip to content

Commit c6146cb

Browse files
authored
Merge pull request #52 from alexc-MSFT/sharepoint-followsites
SharePoint Follow Sites Sample
2 parents cfbb1bf + 01f8887 commit c6146cb

File tree

61 files changed

+18238
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+18238
-0
lines changed
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# SharePoint 'Follow/Discover Sites'
2+
3+
## Summary
4+
5+
This is a proof of concept Power Apps solution designed to be embedded within a SharePoint site/page as a Web Part. It is designed as an alternative to the out of the box 'Sites' Web Part.
6+
7+
It provides the user the ability to follow/unfollow a site from their currently followed sites (something which the out of the box 'Sites' Web Part does not do).
8+
9+
In addition the user can discover new sites/search their followed sites by using the search box.
10+
11+
The use of a low code/no code Power App means there is no need for custom development.
12+
13+
The look and feel has been designed to replicate that of the out of the box Web Part.
14+
15+
The Power App is fully responsive so can still render on a SharePoint page on a mobile device. The app supports both horizontal and vertical layouts.
16+
17+
The solution is functionally complete but is provided as a POC for you to customise/extend as required.
18+
19+
The SharePoint REST APIs are used to retrieve followed sites, search for sites and follow/unfollow them.
20+
21+
![Preview - Follow sites app horizontal section embed](./assets/followsiteshorizontal.png)
22+
23+
![Preview - Follow sites vertical section embed](./assets/followsitesvertical.png)
24+
25+
![Preview - Follow sites in SPO page](./assets/followsitespage.png)
26+
27+
## Applies to
28+
29+
![Power Apps](https://img.shields.io/badge/Power%20Apps-Yes-green "Yes")
30+
![Power Fx](https://img.shields.io/badge/Power%20Fx-Yes-green "Yes")
31+
![Power Automate](https://img.shields.io/badge/Power%20Automate-Yes-green "Yes")
32+
33+
## Compatibility
34+
35+
![Premium License](https://img.shields.io/badge/Premium%20License-Not%20Required-red.svg "Premium license not required")
36+
![Experimental Features](https://img.shields.io/badge/Experimental%20Features-No-red.svg "Does not on experimental features")
37+
38+
39+
## Contributors
40+
41+
* [Alex Clark - Microsoft](https://github.com/alexc-MSFT)
42+
43+
## Version history
44+
45+
Version|Date|Comments
46+
-------|----|--------
47+
1.0.0.0|Sep 14, 2023|Initial release
48+
49+
## Prerequisites
50+
51+
* Power Apps environment
52+
* Permissions to edit the page you wish to add the Power App to
53+
* SharePoint modern Team Site OR Communication Site
54+
* SharePoint site that ALL users who will use the app has **read** permissions to (this can be the same site where you will embed the app)
55+
56+
## Solution Components
57+
58+
The following solution components are used in this sample:
59+
60+
* Follow Sites (Canvas App)
61+
* Get followed sites (Flow)
62+
* Follow Unfollow site (Flow)
63+
* Find sites (Flow)
64+
65+
## Data Sources
66+
67+
* SharePoint
68+
69+
### Using the sample
70+
71+
Follow the instructions below to deploy this sample to your tenant. Once deployed, the app (Follow Sites) is designed to be embedded within a SharePoint page. It can be embedded in a horizontal or vertical section.
72+
73+
I would recommend using the 'Embed' Web Part and defining your own size. This works much better than the native Power Apps Web Part in terms of how it looks on the page.
74+
75+
The recommended sizing is as follows:
76+
77+
**Horizontal Layout**
78+
79+
Width: 1024px
80+
Height: 170px
81+
82+
**Vertical Layout**
83+
84+
Width: 350px
85+
Height: 500px (reducing the height will display less sites, the user can scroll however)
86+
87+
It is worth noting that the deployment instructions below assume a proficient level of knowledge of Power Apps, Power Automate and SharePoint Online.
88+
89+
## Minimal Path to Awesome
90+
91+
### Import Power Apps solution
92+
93+
1. Download the **[Unmanaged](./solution/FollowSites_1_0_0_0.zip)** solution `.zip` from the **solution** folder.
94+
95+
2. Within **<https://make.powerapps.com>**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded.
96+
97+
3. Click next.
98+
99+
4. When prompted connect the SharePoint data connection and select an appropriate SharePoint site that all users have READ access to (this is used for the REST API calls).
100+
101+
5. Click Import.
102+
103+
6. OPTIONAL - Update the color in the App OnStart event to match your SharePoint branding. Locate the below formula and update the hex codes. This will update the colors in the app.
104+
105+
**colSiteColors**: Collection of Fluent colors that are used for the coloured part of the tiles, colors are selected at random.
106+
107+
**gblFollowSitesColor**: Colors used in the search box.
108+
109+
**gblTileBorderColor**: Border color for the site tiles.
110+
111+
112+
![Colors in App OnStart](./assets/appcolors.png)
113+
114+
`
115+
Set(gblMyToolsColor,"#0078d4");
116+
`
117+
118+
7. Add ALL users who will use the app as 'Run only users' for each Power Automate flow - 'Find sites', 'Get user followed sites', 'Follow Unfollow site'. This is required so they can be triggered by users from the app and will ensure the REST API calls are executed in the context of their accounts. You can use an AD group containing all users in your organization if you wish.
119+
120+
8. Get the unique Id for the **Follow Sites** Power App from your tenant - Navigate to the Power Apps portal, select the app and click **Details** on the menu bar. Copy the **App ID** value.
121+
122+
9. Embed the app in a SharePoint page. You can use the following embed code, replace the GUID after /apps/ with the Id you copied above. Feel free to change the size as you see fit (size below is for a horizontal layout).
123+
124+
`<iframe width="1024px" height="170px" src="https://web.powerapps.com/webplayer/iframeapp?source=iframe&amp;screenColor=rgba(104,101,171,1)&amp;appId=/providers/Microsoft.PowerApps/apps/6cfd9913-5dac-48f8-b096-520fdf9ece6c"></iframe>`
125+
126+
10. Republish your SharePoint page.
127+
128+
11. Share the app with ALL users that have access to/will use your SharePoint site.
129+
130+
131+
## Using the Source Code
132+
133+
You can also use the [Power Apps CLI](https://aka.ms/pac/docs) to pack the source code by following these steps::
134+
135+
* Clone the repository to a local drive.
136+
* Pack the source files back into `.zip` file:
137+
138+
```bash
139+
pac solution pack --folder pathtosourcefolder --zipfile pathtosolution --processCanvasApps
140+
```
141+
142+
Making sure to replace `pathtosourcefolder` to point to the path to this sample's `sourcecode` folder, and `pathtosolution` to point to the path of this solution's `.zip` file (located under the `Solutions` folder).
143+
* Within **<https://make.powerapps.com>**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded.
144+
* Click next.
145+
* Click import.
146+
* Follow the steps above to configure and use the apps.
147+
148+
## Features
149+
150+
This sample app is a great way to learn some fundamental Power Apps and Power Automate concepts like:
151+
152+
* Branding out-of-the-box controls
153+
* Working with SharePoint as a data source
154+
* Power Fx Formulas
155+
* Working with local collections
156+
* Building custom UIs
157+
* Responsive design
158+
* Using containers to build responsive layouts
159+
* Using the SharePoint REST APIs in Power Automate
160+
161+
### How to use the app
162+
163+
Using the app is designed to be fairly self explanatory for users.
164+
165+
When the app first loads, the users' followed sites are retrieved by executing the 'Get user followed sites' flow.
166+
167+
Sites can be followed/unfollowed using the 'star' icon in the tile (executes the 'Follow Unfollow Site' flow).
168+
169+
Users can discover new sites/search their followed sites by using the search box. The search is performed when they tab out of the search box or click the search icon.
170+
171+
Searches are performed using the SharePoint REST API through a Power Automate flow ('Find sites').
172+
173+
The search box must be cleared before the view is reset and the user can see their followed sites again.
174+
175+
## Help
176+
177+
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
178+
179+
If you encounter any issues while using this sample, you can [create a new issue](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=sharepoint-followsitess&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20).
180+
181+
For questions regarding this sample, [create a new question](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=sharepoint-followsites&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20).
182+
183+
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=sharepoint-followsites&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20).
184+
185+
## For more information
186+
187+
* [Overview of creating apps in Power Apps](https://docs.microsoft.com/powerapps/maker/)
188+
* [Power Apps canvas apps documentation](https://docs.microsoft.com/powerapps/maker/canvas-apps/)
189+
190+
## Disclaimer
191+
192+
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
193+
194+
<img src="https://m365-visitor-stats.azurewebsites.net/powerplatform-samples/samples/sharepoint-followsites" />
Loading
Loading
Loading
Loading
Loading
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[
2+
{
3+
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/samples/v1.0/metadata-schema.json",
4+
"name": "pnp-powerapps-samples-sharepoint-followsites",
5+
"version": "1.0.0.0",
6+
"source": "pnp",
7+
"creationDateTime": "2023-01-11T00:00:00.000Z",
8+
"updateDateTime": "2023-01-11T00:00:00.000Z",
9+
"title": "SharePoint Follow/Discover Sites",
10+
"shortDescription": "Power Apps solution designed to be embedded within a SharePoint site/page as a Web Part. It is designed as an alternative to the out of the box 'Sites' Web Part.",
11+
"longDescription": [
12+
"Power Apps solution designed to be embedded within a SharePoint site/page as a Web Part. It is designed as an alternative to the out of the box 'Sites' Web Part."
13+
],
14+
"url": "https://github.com/pnp/powerapps-samples/tree/main/samples/sharepoint-followsites",
15+
"products": [
16+
"Power Apps",
17+
"Power Platform"
18+
],
19+
"tags": [
20+
"POWERAPPS","TEMPALTE"
21+
],
22+
"categories": [
23+
"POWERAPPS"
24+
],
25+
"metadata": [
26+
{
27+
"key": "POWERAPPS-MANIFEST-VERSION",
28+
"value": "0.20"
29+
},
30+
{
31+
"key": "POWERAPPS-TYPE",
32+
"value": "Canvas"
33+
},
34+
{
35+
"key": "POWERAPPS-EXPERIMENTAL",
36+
"value": "No"
37+
},
38+
{
39+
"key": "POWERAPPS-PREMIUM",
40+
"value": "No"
41+
},
42+
{
43+
"key": "POWERAPPS-ONPREM",
44+
"value": "No"
45+
},
46+
{
47+
"key": "POWERAPPS-CUSTOMCONNECTOR",
48+
"value": "No"
49+
}
50+
],
51+
"thumbnails": [
52+
{
53+
"type": "image",
54+
"order": 100,
55+
"url": "https://github.com/pnp/powerapps-samples/blob/main/samples/sharepoint-followsites/assets/preview.png?raw=true",
56+
"alt": "Preview"
57+
}
58+
],
59+
"authors": [
60+
{
61+
"gitHubAccount": "alexc-MSFT",
62+
"name": "Alex Clark",
63+
"pictureUrl": "https://github.com/alexc-MSFT"
64+
}
65+
],
66+
"references": [
67+
{
68+
"name": "Create a component for canvas apps",
69+
"description": "Components are reusable building blocks for canvas apps so that app makers can create custom controls to use inside an app, or across apps using a component library",
70+
"url": "https://docs.microsoft.com/powerapps/maker/canvas-apps/"
71+
},
72+
{
73+
"name": "Overview of creating apps in Power Apps",
74+
"description": "Power Apps is a high-productivity development platform for business apps.",
75+
"url": "https://docs.microsoft.com/powerapps/maker/"
76+
},
77+
{
78+
"name": "Power Apps canvas apps documentation",
79+
"description": "Design and build a business app from a canvas in Microsoft Power Apps with data from a variety of sources without writing any code using traditional programming languages, such as C#.",
80+
"url": "https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/"
81+
}
82+
]
83+
}
84+
]
Loading
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# msbuild output directories
4+
/bin
5+
/obj
6+
7+
# MSBuild Binary and Structured Log
8+
*.binlog
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
8+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props')" />
9+
10+
<PropertyGroup>
11+
<ProjectGuid>06205c32-df76-4826-9983-95e2df7095f5</ProjectGuid>
12+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
13+
<!--Remove TargetFramework when this is available in 16.1-->
14+
<TargetFramework>net462</TargetFramework>
15+
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
16+
<SolutionRootPath>src</SolutionRootPath>
17+
</PropertyGroup>
18+
19+
<!--
20+
Solution Packager overrides, un-comment to use: SolutionPackagerType (Managed, Unmanaged, Both)
21+
Solution Localization Control, if you want to enabled localization of your solution, un-comment SolutionPackageEnableLocalization and set the value to true. - Requires use of -loc flag on Solution Clone or Sync
22+
-->
23+
<!--
24+
<PropertyGroup>
25+
<SolutionPackageType>Managed</SolutionPackageType>
26+
<SolutionPackageEnableLocalization>false</SolutionPackageEnableLocalization>
27+
</PropertyGroup>
28+
-->
29+
30+
<ItemGroup>
31+
<PackageReference Include="Microsoft.PowerApps.MSBuild.Solution" Version="1.*" />
32+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore" />
37+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**" />
38+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**" />
39+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj" />
40+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj.user" />
41+
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln" />
42+
</ItemGroup>
43+
44+
<ItemGroup>
45+
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)" />
46+
<Content Include="$(SolutionPackageZipFilePath)">
47+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
48+
</Content>
49+
</ItemGroup>
50+
51+
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
52+
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets')" />
53+
54+
</Project>

0 commit comments

Comments
 (0)