Skip to content

Commit

Permalink
Merge branch '1.x' into robbie/update-docs-and-test-plan
Browse files Browse the repository at this point in the history
  • Loading branch information
rfulton-lf authored Oct 18, 2023
2 parents a0cc646 + 75a684e commit bd9bb3c
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 93 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/jekyll_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy SharePoint Integration Documentation
on:
# Runs on pushes targeting the default branch
push:
branches: ["1.x"]
branches: ['1.x']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
Expand All @@ -27,12 +27,19 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Move LaserficheSharePointIntegrationAppManifest.json
run: cp ./UserDocuments/LaserficheSharePointIntegrationAppManifest.json ./jekyll_files/docs/assets/LaserficheSharePointIntegrationAppManifest.json

- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
message: Workflow run ${{github.server_url}}/${{github.repository}}/actions/runs/${{ github.run_id}}

- name: replace config/package-solution.json version
run: sed -i 's/VERSION_TO_UPDATE/${{env.fullVersion}}/g' config/package-solution.json
run: sed -i 's/"1.0.0.0"/"${{env.fullVersion}}"/g' config/package-solution.json

- name: replace package.json version
run: sed -i 's/VERSION_TO_UPDATE/${{env.fullVersion}}/g' package.json
run: sed -i 's/"1.0.0.0"/"${{env.fullVersion}}"/g' package.json

- name: Install dependencies
run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions config/package-solution.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"solution": {
"name": "Laserfiche Sharepoint Online Integration",
"id": "9d9d4fa7-bbf4-489a-acd5-0e1709d40e8b",
"version": "VERSION_TO_UPDATE",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"title": "Laserfiche SharePoint Online Integration",
"iconPath": "assets/laserfiche-logo-96.png",
Expand All @@ -20,7 +20,7 @@
"title": "Save to Laserfiche",
"description": "Allows user to save SharePoint documents to their Laserfiche repository, with admin-configured metadata mappings.",
"id": "9c2b7b96-fb6e-4c42-9676-9d434992110f",
"version": "VERSION_TO_UPDATE",
"version": "1.0.0.0",
"assets": {
"elementManifests": ["elements.xml"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parent: Laserfiche SharePoint Integration Administration Guide

1. Open the [Developer Console](https://developer.laserfiche.com/developer-console.html).
<a href="../assets/images/createAppFromManifest.png"><img src="../assets/images/createAppFromManifest.png"></a>
1. Attempt to Create a New App from Manifest, and upload the manifest provided [here](../assets/manifest.json).
1. Attempt to Create a New App from Manifest, and upload the manifest provided [here](../assets/LaserficheSharePointIntegrationAppManifest.json).
<a href="../assets/images/createApplication.png"><img src="../assets/images/createApplication.png"></a>
1. If the attempt fails because an app with that client ID already exists, find the app with that client id by opening [this url](https://app.laserfiche.com/devconsole/apps/8ee987ea-a0b1-4ca2-85c4-a79b335cd214/config) in a new tab.
<a href="../assets/images/clientIdRegistered.png"><img src="../assets/images/clientIdRegistered.png"></a>
Expand Down
14 changes: 0 additions & 14 deletions jekyll_files/docs/assets/manifest.json

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laserfiche-sharepoint-integration",
"version": "VERSION_TO_UPDATE",
"version": "1.0.0.0",
"private": true,
"main": "lib/index.js",
"license": "MIT",
Expand Down
32 changes: 15 additions & 17 deletions src/extensions/savetoLaserfiche/SaveToLaserficheDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import { SPComponentLoader } from '@microsoft/sp-loader';
import * as ReactDOM from 'react-dom';
import { BaseDialog } from '@microsoft/sp-dialog';
import { getRegion } from '../../Utils/Funcs';
import {
APIServerException,
Entry,
} from '@laserfiche/lf-repository-api-client';
import { Entry } from '@laserfiche/lf-repository-api-client';
import { RepositoryClientExInternal } from '../../repository-client/repository-client';
import { IRepositoryApiClientExInternal } from '../../repository-client/repository-client-types';
import { PathUtils } from '@laserfiche/lf-js-utils';
Expand Down Expand Up @@ -76,7 +73,8 @@ export default class SaveToLaserficheCustomDialog extends BaseDialog {
}
}

const ENTRY_WITH_SAME_NAME_EXISTS_IN_FOLDER_IF_CONTINUE_LF_WILL_RENAME = 'An entry with the same name already exists in the specified folder. If you continue, Laserfiche will automatically rename the new document.';
const ENTRY_WITH_SAME_NAME_EXISTS_IN_FOLDER_IF_CONTINUE_LF_WILL_RENAME =
'An entry with the same name already exists in the specified folder. If you continue, Laserfiche will automatically rename the new document.';
function SaveToLaserficheDialog(props: {
isSuccessfulLoggedIn: (success: boolean) => void;
closeClick: (success?: SavedToLaserficheDocumentData) => Promise<void>;
Expand Down Expand Up @@ -112,9 +110,9 @@ function SaveToLaserficheDialog(props: {

React.useEffect(() => {
const initializeComponentAsync: () => Promise<void> = async () => {
await SPComponentLoader.loadScript(ZONE_JS_URL);
await SPComponentLoader.loadScript(LF_UI_COMPONENTS_URL);
try {
await SPComponentLoader.loadScript(ZONE_JS_URL);
await SPComponentLoader.loadScript(LF_UI_COMPONENTS_URL);
if (loginComponent.current?.authorization_credentials) {
const validRepoClient = await tryGetValidRepositoryClientAsync();
const saveToLF = new SaveDocumentToLaserfiche(
Expand All @@ -129,13 +127,14 @@ function SaveToLaserficheDialog(props: {
repoId,
entryId: Number.parseInt(props.spFileMetadata.entryId, 10),
});
const entryWithPathExists = validRepoClient.entriesClient.getEntryByPath({
repoId,
fullPath: PathUtils.combinePaths(
entryInfo.fullPath,
props.spFileMetadata.fileName
),
});
const entryWithPathExists =
await validRepoClient.entriesClient.getEntryByPath({
repoId,
fullPath: PathUtils.combinePaths(
entryInfo.fullPath,
PathUtils.removeFileExtension(props.spFileMetadata.fileName)
),
});
if (entryWithPathExists) {
setShowSaveTo(false);
const confirmSave = await getConfirmation(
Expand All @@ -151,11 +150,10 @@ function SaveToLaserficheDialog(props: {
}
}
} catch (err) {
const docDoesNotAlreadyExists = (err as APIServerException).statusCode === 404;
const docDoesNotAlreadyExists = err.status === 404;
if (docDoesNotAlreadyExists) {
await continueSavingDocumentAsync(saveToLF);
}
else {
} else {
throw err;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { PathUtils } from '@laserfiche/lf-js-utils';
import { CreateConfigurations } from '../../Utils/CreateConfigurations';
import { getSPListURL } from '../../Utils/Funcs';
import { SP_LOCAL_STORAGE_KEY } from '../../webparts/constants';
import { LASERFICHE_SIGNIN_PAGE_NAME, SP_LOCAL_STORAGE_KEY } from '../../webparts/constants';

/**
* If your command set uses the ClientSideComponentProperties JSON input,
Expand All @@ -23,10 +23,6 @@ export interface ISendToLfCommandSetProperties {
sampleTextTwo: string;
}

enum SpWebPartNames {
'LaserficheSignIn' = 'LaserficheSignIn',
}

const LOG_SOURCE = 'SendToLfCommandSet';

export default class SendToLfCommandSet extends BaseListViewCommandSet<ISendToLfCommandSetProperties> {
Expand Down Expand Up @@ -112,7 +108,7 @@ export default class SendToLfCommandSet extends BaseListViewCommandSet<ISendToLf
const sitePages = await res.json();
for (let o = 0; o < sitePages.value.length; o++) {
const pageName = sitePages.value[o].Title;
if (pageName === SpWebPartNames.LaserficheSignIn) {
if (pageName === LASERFICHE_SIGNIN_PAGE_NAME) {
this.hasSignInPage = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@font-face {
font-family: 'Open Sans';
src: local('Open Sans'), local('OpenSans'), url(https://lfxstatic.com/libs/Open_Sans/OpenSans.woff) format('woff'), url(https://lfxstatic.com/libs/Open_Sans/OpenSans-Regular.ttf) format('truetype');
}

.lfAdhocMinHeight {
height: 450px;
}
Expand Down Expand Up @@ -125,7 +130,6 @@
.browserTitle {
margin-left: 10px;
font-size: 16px;
font-family: 'Open Sans';
font-weight: 600;
color: #333333;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IRepositoryApiClientExInternal } from '../../../repository-client/repos
import { RepositoryClientExInternal } from '../../../repository-client/repository-client';
import {
clientId,
LASERFICHE_SIGNIN_PAGE_NAME,
LF_INDIGO_PINK_CSS_URL,
LF_MS_OFFICE_LITE_CSS_URL,
LF_UI_COMPONENTS_URL,
Expand All @@ -22,7 +23,7 @@ require('../../../../node_modules/bootstrap/dist/js/bootstrap.min.js');
require('../../../Assets/CSS/bootstrap.min.css');
import './LaserficheRepositoryAccess.module.scss';
import { ILaserficheRepositoryAccessWebPartProps } from './ILaserficheRepositoryAccessWebPartProps';
import { getRegion } from '../../../Utils/Funcs';
import { getRegion, getSPListURL } from '../../../Utils/Funcs';
import styles from './LaserficheRepositoryAccess.module.scss';
import { MessageDialog } from '../../../extensions/savetoLaserfiche/CommonDialogs';

Expand All @@ -44,6 +45,7 @@ const FOR_MORE_INFO_VISIT = 'For more information visit';
const ONCE_SIGNED_IN_YOULL_SEE_REPOSITORY =
"Once signed in you'll be able to view your Laserfiche repository.";

const needLaserficheSignInPage = `Missing ${LASERFICHE_SIGNIN_PAGE_NAME} SharePoint page. Please refer to the Adding App to SharePoint Site topic in the administration guide for configuration steps.`;
export default function LaserficheRepositoryAccessWebPart(
props: ILaserficheRepositoryAccessWebPartProps
): JSX.Element {
Expand Down Expand Up @@ -88,11 +90,11 @@ export default function LaserficheRepositoryAccessWebPart(
};

const initializeComponentAsync: () => Promise<void> = async () => {
await SPComponentLoader.loadScript(ZONE_JS_URL);
await SPComponentLoader.loadScript(LF_UI_COMPONENTS_URL);
SPComponentLoader.loadCss(LF_INDIGO_PINK_CSS_URL);
SPComponentLoader.loadCss(LF_MS_OFFICE_LITE_CSS_URL);
try {
await SPComponentLoader.loadScript(ZONE_JS_URL);
await SPComponentLoader.loadScript(LF_UI_COMPONENTS_URL);
SPComponentLoader.loadCss(LF_INDIGO_PINK_CSS_URL);
SPComponentLoader.loadCss(LF_MS_OFFICE_LITE_CSS_URL);
const loginCompleted: () => Promise<void> = async () => {
await getAndInitializeRepositoryClientAndServicesAsync();
setLoggedIn(true);
Expand Down Expand Up @@ -121,10 +123,50 @@ export default function LaserficheRepositoryAccessWebPart(
void initializeComponentAsync();
}, []);

function clickLogin(): void {
async function pageConfigurationCheck(): Promise<boolean> {
try {
const res = await fetch(
`${getSPListURL(props.context, 'Site Pages')}/items`,
{
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}
);
const sitePages = await res.json();
for (let o = 0; o < sitePages.value.length; o++) {
const pageName = sitePages.value[o].Title;
if (pageName === LASERFICHE_SIGNIN_PAGE_NAME) {
return true;
}
}
} catch (error) {
console.warn(`Unable to determine if a SharePoint Page with name ${LASERFICHE_SIGNIN_PAGE_NAME} exists.`)
return false;
}
return false;
}

async function clickLogin(): Promise<void> {
const url =
props.context.pageContext.web.absoluteUrl +
'/SitePages/LaserficheSignIn.aspx?autologin';
const hasSignIn = await pageConfigurationCheck();
if (!hasSignIn) {
const mes = (
<MessageDialog
title='Sign In Failed'
message={needLaserficheSignInPage}
clickOkay={() => {
setMessageErrorModal(undefined);
}}
/>
);
setMessageErrorModal(mes);
return;
}
const loginWindow = window.open(url, 'loginWindow', 'popup');
loginWindow.resizeTo(800, 600);
window.addEventListener('message', (event) => {
Expand Down Expand Up @@ -176,15 +218,15 @@ export default function LaserficheRepositoryAccessWebPart(
</button>
</div>
{messageErrorModal !== undefined && (
<div
className={styles.modal}
id='messageErrorModal'
data-backdrop='static'
data-keyboard='false'
>
{messageErrorModal}
</div>
)}
<div
className={styles.modal}
id='messageErrorModal'
data-backdrop='static'
data-keyboard='false'
>
{messageErrorModal}
</div>
)}
<RepositoryViewComponent
webClientUrl={webClientUrl}
repoClient={repoClient}
Expand Down
Loading

0 comments on commit bd9bb3c

Please sign in to comment.