Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ss-form-js-sdk into develop
  • Loading branch information
Linh Hoang committed Oct 4, 2024
2 parents 0eaae58 + a560edc commit 2274dda
Show file tree
Hide file tree
Showing 37 changed files with 626 additions and 282 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ on:
branches:
- master
- develop
- feature/*
- bugfix/*
- release/**
pull_request:
branches: [ "develop" ]
branches:
- "*"
- master
- feature/**
- release/**

permissions:
contents: write
Expand All @@ -18,9 +21,11 @@ permissions:
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
JIRA_USERNAME: ${{ secrets.JIRA_BOT_USERNAME }}
JIRA_PASSWORD: ${{ secrets.JIRA_BOT_PASSWORD }}

jobs:
build:
build_test_pack:
name: Build, test, and publish
runs-on: windows-latest
env:
Expand All @@ -33,13 +38,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: "npm"

- name: Setup dependencies
run: npm ci

Expand All @@ -55,5 +60,27 @@ jobs:
${{ github.workspace}}/build/get-versionSuffix.ps1 ${{env.BRANCH_NAME}} ${{github.RUN_NUMBER}}
- name: Publish
if: ${{ github.ref == 'refs/heads/master' }}
run: npm run publish
if: ${{ contains(github.ref,'release/') || github.ref == 'refs/heads/master'}}
run: npm run publish

jira-release:
if: ${{ contains(github.ref,'release/') }}
runs-on: windows-latest
name: Get release version & create JIRA release
needs: build_test_pack
steps:
- name: Checkout repository
uses: actions/checkout@v1

- name: Get release version
uses: episerver/addons-jira-automation/releaseversion@v1
id: branchVersion

- name: Create JIRA release
uses: episerver/addons-jira-automation/release@v1
with:
jira-project: AFORM
jira-package: Optimizely.Forms.Headless.Js.Sdk
jira-host: jira.sso.episerver.net
version: ${{ steps.branchVersion.outputs.manifestSafeVersionString }}
versionSuffix: ${{needs.build_test_pack.outputs.versionSuffix}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ coverage/
/samples/epiCloud/
/samples/musicfestival-frontend-react/build/
/samples/musicfestival-backend-dotnet/App_Data/

.env.local
appsettings.development.json
8 changes: 4 additions & 4 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@episerver:registry=https://pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/
always-auth=true
; begin auth token
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/:username=Phu.nguyen
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/:username=${AZURE_USERNAME}
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/:_password=${AZURE_TOKEN}
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/:email=[email protected]
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/:username=Phu.nguyen
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/registry/:email=${AZURE_EMAIL}
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/:username=${AZURE_USERNAME}
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/:_password=${AZURE_TOKEN}
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/:email=[email protected]
//pkgs.dev.azure.com/EpiserverEngineering/netCore/_packaging/HeadlessForms/npm/:email=${AZURE_EMAIL}
; end auth token
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ref: https://docs.developers.optimizely.com/content-management-system/v1.2.0-for
### Installation
**From Azure Artifacts**

Source https://dev.azure.com/EpiserverEngineering/netCore/_artifacts/feed/HeadlessForms
Source https://dev.azure.com/EpiserverEngineering/netCore/_artifacts/feed/HeadlessForms

To use packages from Azure Artifacts, configure your project to reference this feed. Create a new text file called .npmrc in the same directory as your package.json, then copy the snippet below.
```
Expand All @@ -28,7 +28,16 @@ Install from the command line
```

**OR** clone source code and install dependencies, then build and view the site on the browser.

#### Sample site structures
This repository contains two sample sites
* Site render using Headless Form Api
- `/samples/ManagementSite` Backend decouples site that hosts the Headless Form API
- `/samples/sample-react-app` Frontend React site that render form using Headless Form API
* Site render using Content Graph
- `/samples/musicfestival-backend-dotnet` Backend site that fully index using Content Graph
- `/samples/musicfestival-frontend-react` Frontend React site that renders the full site, including the Form, using Content Graph

#### Installing and running sample sites
1. Clone repo

```sh
Expand Down
86 changes: 44 additions & 42 deletions samples/ManagementSite/Alloy.ManagementSite.csproj
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU5100;NU1803;NU1605;NU1504;</NoWarn>
<CmsUIVersion>12.23.0</CmsUIVersion>
<CmsCoreVersion>12.20.1</CmsCoreVersion>
<HeadlessFormVersion>0.1.1-inte-380</HeadlessFormVersion>
<ContentApiVersion>12.20.1</ContentApiVersion>
<FormVersion>5.8.2</FormVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPiServer.CMS.AspNetCore" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.MVC" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.Core" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Forms" Version="$(FormVersion)" />
<PackageReference Include="EPiServer.Framework" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Framework.AspNetCore" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Hosting" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.TinyMce" Version="4.4.2" />
<PackageReference Include="EPiServer.CMS.UI" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.Core" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.VisitorGroups" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.AspNetIdentity" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.ImageLibrary.ImageSharp" Version="2.0.1" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU5100;NU1803;NU1605;NU1504;</NoWarn>
<CmsUIVersion>12.30.0</CmsUIVersion>
<CmsCoreVersion>12.21.4</CmsCoreVersion>
<HeadlessFormVersion>1.0.0</HeadlessFormVersion>
<ContentApiVersion>12.20.1</ContentApiVersion>
<FormVersion>5.9.0</FormVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPiServer.CMS.AspNetCore" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.MVC" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.Core" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Forms" Version="$(FormVersion)" />
<PackageReference Include="EPiServer.Framework" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Framework.AspNetCore" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.Hosting" Version="$(CmsCoreVersion)" />
<PackageReference Include="EPiServer.CMS.TinyMce" Version="4.4.2" />
<PackageReference Include="EPiServer.CMS.UI" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.Core" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.VisitorGroups" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.CMS.UI.AspNetIdentity" Version="$(CmsUIVersion)" />
<PackageReference Include="EPiServer.ImageLibrary.ImageSharp" Version="2.0.1" />
</ItemGroup>
<ItemGroup Label="HeadlessForm">
<PackageReference Include="Optimizely.Cms.Preview1.Content.EPiServer" Version="$(ContentApiVersion)" />
<PackageReference Include="Optimizely.Headless.Form.Service" Version="$(HeadlessFormVersion)" />
<PackageReference Include="Optimizely.Cms.Forms.ContentGraph" Version="$(HeadlessFormVersion)" />
<PackageReference Include="Optimizely.Cms.Forms.Core" Version="$(HeadlessFormVersion)" />
<PackageReference Include="Optimizely.Cms.Forms.Service" Version="$(HeadlessFormVersion)" />
<PackageReference Include="Optimizely.ContentGraph.Cms" Version="3.5.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EPiServer.ContentDefinitionsApi" Version="3.3.0" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.9.1" />
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.3.0" />
<PackageReference Include="EPiServer.CloudPlatform.Cms" Version="1.2.0" />
</ItemGroup>
<PropertyGroup>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>NU5100;NU1803;NU1605;NU1504;</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPiServer.ContentDefinitionsApi" Version="3.3.0" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.9.1" />
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.3.0" />
<PackageReference Include="EPiServer.CloudPlatform.Cms" Version="1.2.0" />
</ItemGroup>
<PropertyGroup>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>NU5100;NU1803;NU1605;NU1504;</NoWarn>
</PropertyGroup>
</Project>
41 changes: 26 additions & 15 deletions samples/ManagementSite/Controllers/ReactController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using EPiServer.Cms.Shell;
using EPiServer;
using EPiServer.Core;
using EPiServer.Forms.Implementation.Elements;
using EPiServer.ServiceLocation;
using EPiServer.SpecializedProperties;
using EPiServer.Web;
using EPiServer.Web.Routing;
using Microsoft.AspNetCore.Mvc;
using Optimizely.Cms.Preview1.Content;
using Optimizely.Cms.Preview1.Content.Models;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -13,11 +15,8 @@ namespace AlloyMvcTemplates.Controllers;
[ApiController]
public class ReactController : ControllerBase
{
private readonly IContentRepository _contentRepositoryInteApi;

public ReactController(IContentRepository contentRepositoryInteApi)
public ReactController()
{
_contentRepositoryInteApi = contentRepositoryInteApi;
}

[HttpGet("GetFormInPageByUrl")]
Expand All @@ -32,18 +31,30 @@ public async Task<IActionResult> GetFormInPageByUrl(string url)
}
CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
var key = ContentKey.FormatAsKey(content.ContentGuid);

var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

var pageContent = contentLoader.Get<IContent>(content.ContentGuid);

var pageModel = new PageModel();
var contentHeadless = await _contentRepositoryInteApi.GetAsync(key, content.LanguageBranch());

if (contentHeadless is not null)
if (pageContent is not null)
{
pageModel.Title = contentHeadless.DisplayName;
pageModel.Title = pageContent.Name;
pageModel.PageUrl = UrlResolver.Current.GetUrl(content.ContentLink);

if (contentHeadless.Properties.ContainsKey("MainContentArea"))
if (pageContent.Property.Keys.Contains("MainContentArea"))
{
pageModel.Childrens.AddRange(contentHeadless.Properties["MainContentArea"] as IList<IContentComponent>);
var contentArea = pageContent.Property["MainContentArea"] as PropertyContentArea;
foreach (var item in contentArea.PublicContentArea.FilteredItems)
{
var contentItem = contentLoader.Get<IContent>(item.ContentLink);

if(contentItem is FormContainerBlock)
{
pageModel.FormKeys.Add(contentItem.ContentGuid.ToString("N"));
}
}
}
}

Expand All @@ -55,5 +66,5 @@ public class PageModel
{
public string Title { get; set; }
public string PageUrl { get; set; }
public List<IContentComponent> Childrens { get; set; } = new List<IContentComponent>();
}
public List<string> FormKeys { get; set; } = new List<string>();
}
5 changes: 1 addition & 4 deletions samples/ManagementSite/Nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="optimizely" value="https://api.nuget.optimizely.com/v3/index.json" />
<add key="headlessform.local" value="..\NugetPackages\" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
Expand All @@ -17,9 +16,7 @@
<package pattern="EPiServer.Forms.*" />
<package pattern="Optimizely.Cms.*" />
<package pattern="EPiServer.AddOns.*" />
</packageSource>
<packageSource key="headlessform.local">
<package pattern="Optimizely.Headless.*" />
<package pattern="Optimizely.Cms.Forms.*" />
</packageSource>
</packageSourceMapping>
</configuration>
2 changes: 1 addition & 1 deletion samples/ManagementSite/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "episerver/cms",
"applicationUrl": "http://localhost:8082",
"applicationUrl": "https://localhost:8082",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
Loading

0 comments on commit 2274dda

Please sign in to comment.