Skip to content

Commit

Permalink
Merge pull request #8 from pnp/pkr-add-ace-state-sample
Browse files Browse the repository at this point in the history
adding state sample
  • Loading branch information
patrick-rodgers authored Jan 18, 2022
2 parents c32fcd5 + bbd0d94 commit 99616c1
Show file tree
Hide file tree
Showing 30 changed files with 21,885 additions and 0 deletions.
33 changes: 33 additions & 0 deletions samples/ace-application-state/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
release
solution
temp
*.sppkg

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
16 changes: 16 additions & 0 deletions samples/ace-application-state/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!dist
config

gulpfile.js

release
src
temp

tsconfig.json
tslint.json

*.log

.yo-rc.json
.vscode
5 changes: 5 additions & 0 deletions samples/ace-application-state/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"msjsdiag.debugger-for-chrome"
]
}
27 changes: 27 additions & 0 deletions samples/ace-application-state/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
/**
* Install Chrome Debugger Extension for Visual Studio Code to debug your components with the
* Chrome browser: https://aka.ms/spfx-debugger-extensions
*/
"version": "0.2.0",
"configurations": [
{
"name": "Hosted workbench",
"type": "chrome",
"request": "launch",
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///.././src/*": "${webRoot}/src/*",
"webpack:///../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../../src/*": "${webRoot}/src/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222",
"-incognito"
]
}
]
}
13 changes: 13 additions & 0 deletions samples/ace-application-state/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
// Configure glob patterns for excluding files and folders in the file explorer.
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/bower_components": true,
"**/coverage": true,
"**/lib-amd": true,
"src/**/*.scss.ts": true
},
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
}
14 changes: 14 additions & 0 deletions samples/ace-application-state/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"environment": "spo",
"version": "1.13.1",
"libraryName": "state-sample",
"libraryId": "c9ed6e9f-af25-4509-9b53-a2bd84a4dfe4",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "adaptiveCardExtension",
"aceTemplateType": "PrimaryText"
}
}
63 changes: 63 additions & 0 deletions samples/ace-application-state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# state-sample

## Summary

This sample is setup to illustrate the use of `state` with ACE solutions. Similar but not identical to React state you can use state to manage the data with your ACE. Unlike React each ACE has a shared state used by all hosted cards, either CardViews or QuickViews. During the init method of the ACE you set an initial state, which can later be modified using setState. The behavior of setState mimics what you may be familiar with from React - you can supply all or part of a new state and it will be merged with an existing state.

## Used SharePoint Framework Version

![version](https://img.shields.io/badge/version-1.13-green.svg)

## Applies to

- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)

> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
## Prerequisites

> Any special pre-requisites?
## Solution

Solution|Author(s)
--------|---------
state-sample | Patrick Rodgers (Microsoft)

## Version history

Version|Date|Comments
-------|----|--------
1.0|January 18, 2022|Initial release

## Disclaimer

**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.**

---

## Minimal Path to Awesome

- Clone this repository
- Ensure that you are at the solution folder
- in the command-line run:
- **npm install**
- **gulp serve**

> Include any additional steps as needed.
## Features

State is an in-memory representation of your application's working values. It is important when designing your application to manage performance using a mix of state, local/session storage, network calls, and selectively loading information on-demand. For example this sample loads the list of items and stores them in local storage, but only the top 20, along with title and id. Only when viewed is the full details loaded. In this example the "details" are just another single field, but could include many fields, information from multiple sources, or database calls. Load as little as possible upfront and defer loading expensive data. As well, it is likely not a good idea to cache all of the data in local/session storage as there are per-domain limits. Focus on loading that data which enables a fast load first expience for your ACE.


> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
## References

- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
18 changes: 18 additions & 0 deletions samples/ace-application-state/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"state-sample-adaptive-card-extension": {
"components": [
{
"entrypoint": "./lib/adaptiveCardExtensions/stateSample/StateSampleAdaptiveCardExtension.js",
"manifest": "./src/adaptiveCardExtensions/stateSample/StateSampleAdaptiveCardExtension.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"StateSampleAdaptiveCardExtensionStrings": "lib/adaptiveCardExtensions/stateSample/loc/{locale}.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "state-sample",
"accessKey": "<!-- ACCESS KEY -->"
}
20 changes: 20 additions & 0 deletions samples/ace-application-state/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "state-sample-client-side-solution",
"id": "c9ed6e9f-af25-4509-9b53-a2bd84a4dfe4",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.13.1"
}
},
"paths": {
"zippedPackage": "solution/state-sample.sppkg"
}
}
6 changes: 6 additions & 0 deletions samples/ace-application-state/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}
4 changes: 4 additions & 0 deletions samples/ace-application-state/config/write-manifests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}
21 changes: 21 additions & 0 deletions samples/ace-application-state/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const build = require('@microsoft/sp-build-web');

build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);

result.set('serve', result.get('serve-deprecated'));

return result;
};

// ********* ADDED *******
// disable tslint
build.tslintCmd.enabled = false;
// ********* ADDED *******

build.initialize(require('gulp'));
Loading

0 comments on commit 99616c1

Please sign in to comment.