Skip to content

Commit

Permalink
Merge pull request #58 from Laserfiche/alex/good-erro-for-signin-page
Browse files Browse the repository at this point in the history
add error if LaserficheSignIn page is not configured
  • Loading branch information
alexgomezlf authored Oct 18, 2023
2 parents fe66f21 + 3b484fc commit 75a684e
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 39 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
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
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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ function ImportFileModal(props: {
}
const extension = PathUtils.getCleanedExtension(fileData.name);
const renamedFile = new File([fileData], fileName + extension);
const fileContainsBacklash = fileName.includes('\\');
const fileContainsBackslash = fileName.includes('\\');
try {
const entryWithPathExists =
await props.repoClient.entriesClient.getEntryByPath({
Expand Down Expand Up @@ -493,7 +493,7 @@ function ImportFileModal(props: {
throw err;
}
}
if (fileContainsBacklash) {
if (fileContainsBackslash) {
setFileUploadPercentage(0);
setImportFileValidationMessage(fileNameWithBacklash);
return;
Expand Down Expand Up @@ -725,7 +725,8 @@ function CreateFolderModal(props: {

const createNewFolderAsync: () => Promise<void> = async () => {
if (folderName) {
if (/^[\\\\]*$/.test(folderName)) {
const fileContainsBackslash = folderName.includes('\\');
if (fileContainsBackslash) {
setCreateFolderNameValidationMessage(folderBackslashNameValidation);
} else {
setCreateFolderNameValidationMessage(undefined);
Expand Down
1 change: 1 addition & 0 deletions src/webparts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const MANAGE_MAPPING = 'ManageMapping';
export const MANAGE_CONFIGURATIONS = 'ManageConfigurations';

export const LOGIN_WINDOW_SUCCESS = 'loginWindowSuccess';
export const LASERFICHE_SIGNIN_PAGE_NAME = 'LaserficheSignIn';

export const SP_LOCAL_STORAGE_KEY = 'spdocdata';
export const SPDEVMODE_LOCAL_STORAGE_KEY = 'spDevMode';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import EditManageConfiguration from './EditManageConfiguration/EditManageConfigu
import AddNewManageConfiguration from './AddNewManageConfiguration/AddNewManageConfiguration';
import {
clientId,
LASERFICHE_SIGNIN_PAGE_NAME,
LF_INDIGO_PINK_CSS_URL,
LF_MS_OFFICE_LITE_CSS_URL,
LF_UI_COMPONENTS_URL,
Expand All @@ -25,14 +26,15 @@ import {
import { RepositoryClientExInternal } from '../../../repository-client/repository-client';
import { IRepositoryApiClientExInternal } from '../../../repository-client/repository-client-types';
import { SPComponentLoader } from '@microsoft/sp-loader';
import { getRegion } from '../../../Utils/Funcs';
import { getRegion, getSPListURL } from '../../../Utils/Funcs';
import styles from './LaserficheAdminConfiguration.module.scss';
import { SPPermission } from '@microsoft/sp-page-context';
import { MessageDialog } from '../../../extensions/savetoLaserfiche/CommonDialogs';

const YOU_DO_NOT_HAVE_RIGHTS_FOR_ADMIN_CONFIG_PLEASE_CONTACT_ADMIN =
'You do not have the necessary rights to view or edit the Laserfiche SharePoint Integration configuration. Please contact your administrator for help.';

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 LaserficheAdminConfiguration(
props: ILaserficheAdminConfigurationProps
): JSX.Element {
Expand Down Expand Up @@ -113,10 +115,50 @@ export default function LaserficheAdminConfiguration(
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
Loading

0 comments on commit 75a684e

Please sign in to comment.