mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-2214] Sharing URL being constructed from ECM Host incorrectly (#981)
* fix baseShareUrl defaults * allow controlling full path * unit test * update tomcat settings * use single slash * simplify documentation
This commit is contained in:
@@ -3,7 +3,7 @@ npm run build.e2e -- --base-href ./
|
|||||||
node -e "
|
node -e "
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const config = require('./dist/app/app.config.json');
|
const config = require('./dist/app/app.config.json');
|
||||||
config.baseShareUrl = 'http://localhost:4000/content-app';
|
config.baseShareUrl = 'http://localhost:4000/content-app/#/preview/s/';
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
'./dist/app/app.config.json',
|
'./dist/app/app.config.json',
|
||||||
JSON.stringify(config, null, 2)
|
JSON.stringify(config, null, 2)
|
||||||
|
@@ -49,32 +49,12 @@ Alternatively, you can provide a static address for the ACS server if necessary:
|
|||||||
|
|
||||||
The "baseShareUrl" property tells the application how to construct the address where users will access shared files.
|
The "baseShareUrl" property tells the application how to construct the address where users will access shared files.
|
||||||
|
|
||||||
#### Default
|
|
||||||
|
|
||||||
When the default value is set the application will construct the File Share URL from the "ecmHost" property:
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
...
|
"baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s"
|
||||||
"baseShareUrl": null,
|
|
||||||
...
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Configuration
|
|
||||||
|
|
||||||
If you run the application from a different server than the Content Services server the "baseShareUrl" property should must be configured correctly, for example:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
...
|
|
||||||
"baseShareUrl": "http://{serveraddress}{:port}",
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** If you run the application as part of Tomcat and not in the root (subfolder), then "baseShareUrl" value should contain full address to the app, for example: "baseShareUrl": "http://{serveraddress}{:port}/{folder}".
|
|
||||||
|
|
||||||
## Application settings
|
## Application settings
|
||||||
|
|
||||||
There are many settings you can change to alter the default behavior of the application.
|
There are many settings you can change to alter the default behavior of the application.
|
||||||
@@ -104,7 +84,6 @@ The default logo displayed in the top left corner of the Alfresco Content Applic
|
|||||||
|
|
||||||
2. In the app.config.json file, set the value of the application.logo to contain the name of the custom logo image: "logo": "/assets/images/[image-name].[extension]"
|
2. In the app.config.json file, set the value of the application.logo to contain the name of the custom logo image: "logo": "/assets/images/[image-name].[extension]"
|
||||||
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ecmHost": "{protocol}//{hostname}{:port}",
|
"ecmHost": "{protocol}//{hostname}{:port}",
|
||||||
"aosHost": "{protocol}//{hostname}{:port}/alfresco/aos",
|
"aosHost": "{protocol}//{hostname}{:port}/alfresco/aos",
|
||||||
"baseShareUrl": null,
|
"baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s",
|
||||||
"providers": "ECM",
|
"providers": "ECM",
|
||||||
"authType": "BASIC",
|
"authType": "BASIC",
|
||||||
"oauth2": {
|
"oauth2": {
|
||||||
|
@@ -24,20 +24,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
import { SetInitialStateAction } from './store/actions';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
let component;
|
let component: AppComponent;
|
||||||
const storeMock = <any>{
|
|
||||||
|
const storeMock: any = {
|
||||||
dispatch: jasmine.createSpy('dispatch')
|
dispatch: jasmine.createSpy('dispatch')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const configMock: any = {
|
||||||
|
get: (key: string) => {
|
||||||
|
if (key === 'baseShareUrl') {
|
||||||
|
return 'http://localhost:4200/#/preview/s';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
component = new AppComponent(
|
component = new AppComponent(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
storeMock,
|
storeMock,
|
||||||
null,
|
configMock,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -47,48 +58,59 @@ describe('AppComponent', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onFileUploadedError', () => {
|
beforeEach(() => {
|
||||||
afterEach(() => {
|
storeMock.dispatch = jasmine.createSpy('dispatch');
|
||||||
storeMock.dispatch['calls'].reset();
|
});
|
||||||
|
|
||||||
|
it('should setup baseShareUrl as per config', done => {
|
||||||
|
storeMock.dispatch.and.callFake((action: SetInitialStateAction) => {
|
||||||
|
expect(action.payload.sharedUrl).toBe(
|
||||||
|
'http://localhost:4200/#/preview/s/'
|
||||||
|
);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
component.loadAppSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onFileUploadedError', () => {
|
||||||
it('should dispatch 403 error message', () => {
|
it('should dispatch 403 error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 403 } });
|
component.onFileUploadedError(<any>{ error: { status: 403 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.403'
|
'APP.MESSAGES.UPLOAD.ERROR.403'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch 404 error message', () => {
|
it('should dispatch 404 error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 404 } });
|
component.onFileUploadedError(<any>{ error: { status: 404 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.404'
|
'APP.MESSAGES.UPLOAD.ERROR.404'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch 409 error message', () => {
|
it('should dispatch 409 error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 409 } });
|
component.onFileUploadedError(<any>{ error: { status: 409 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.CONFLICT'
|
'APP.MESSAGES.UPLOAD.ERROR.CONFLICT'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch 500 error message', () => {
|
it('should dispatch 500 error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 500 } });
|
component.onFileUploadedError(<any>{ error: { status: 500 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.500'
|
'APP.MESSAGES.UPLOAD.ERROR.500'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch 504 error message', () => {
|
it('should dispatch 504 error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 504 } });
|
component.onFileUploadedError(<any>{ error: { status: 504 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.504'
|
'APP.MESSAGES.UPLOAD.ERROR.504'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch generic error message', () => {
|
it('should dispatch generic error message', () => {
|
||||||
component.onFileUploadedError({ error: { status: 999 } });
|
component.onFileUploadedError(<any>{ error: { status: 999 } });
|
||||||
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe(
|
||||||
'APP.MESSAGES.UPLOAD.ERROR.GENERIC'
|
'APP.MESSAGES.UPLOAD.ERROR.GENERIC'
|
||||||
);
|
);
|
||||||
|
@@ -147,10 +147,11 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadAppSettings() {
|
loadAppSettings() {
|
||||||
const baseShareUrl =
|
let baseShareUrl = this.config.get<string>('baseShareUrl');
|
||||||
this.config.get<string>('baseShareUrl') ||
|
if (!baseShareUrl.endsWith('/')) {
|
||||||
this.config.get<string>('ecmHost');
|
baseShareUrl += '/';
|
||||||
|
}
|
||||||
|
|
||||||
const state: AppState = {
|
const state: AppState = {
|
||||||
...INITIAL_APP_STATE,
|
...INITIAL_APP_STATE,
|
||||||
@@ -158,7 +159,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
appName: this.config.get<string>('application.name'),
|
appName: this.config.get<string>('application.name'),
|
||||||
headerColor: this.config.get<string>('headerColor'),
|
headerColor: this.config.get<string>('headerColor'),
|
||||||
logoPath: this.config.get<string>('application.logo'),
|
logoPath: this.config.get<string>('application.logo'),
|
||||||
sharedUrl: `${baseShareUrl}/#/preview/s/`
|
sharedUrl: baseShareUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
this.store.dispatch(new SetInitialStateAction(state));
|
this.store.dispatch(new SetInitialStateAction(state));
|
||||||
|
Reference in New Issue
Block a user