Skip to content

Commit

Permalink
Merge branch 'develop' into feature/GH-8499
Browse files Browse the repository at this point in the history
  • Loading branch information
Platonn committed Oct 14, 2020
2 parents 6624904 + 7e1f9c5 commit cd2ef2c
Show file tree
Hide file tree
Showing 147 changed files with 4,257 additions and 987 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/new-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ assignees: ''
- [ ] Get the spartacussampledataaddon for both 1905 and 2005 CX versions (use `release/1905/next` and `release/2005/next` branches)
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledataaddon/archive/release/1905/next.zip` -> `spartacussampledataaddon.1905.zip`
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledataaddon/archive/release/1905/next.tar.gz` -> `spartacussampledataaddon.1905.tar.gz`
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledataaddon/archive/release/2005/next.zip` -> `spartacussampledataaddon.2005.zip`
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledataaddon/archive/release/2005/next.tar.gz` -> `spartacussampledataaddon.2005.tar.gz`
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledata/archive/2005-2.0.0.zip` -> `spartacussampledataaddon.2005.zip`
- [ ] Download and rename in root directory `https://github.tools.sap/cx-commerce/spartacussampledata/archive/2005-2.0.0.tar.gz` -> `spartacussampledataaddon.2005.tar.gz`

## For all operative systems

Expand All @@ -69,6 +69,8 @@ assignees: ''
- [ ] `npm run release:assets:with-changelog`
- [ ] `npm run release:styles:with-changelog`
- [ ] `npm run release:schematics:with-changelog`
- [ ] `npm run release:setup:with-changelog` (needed since `3.0.0-next.1`)
- [ ] `npm run release:my-account:with-changelog` (needed since `3.0.0-next.1`)
- [ ] `npm run release:cdc:with-changelog` (since 2.1.0-next.0 - publish under `0.<packages-version>.0` eg. `0.201.0-next.0` for first `2.1.0-next.0` release)
- [ ] before the script set the spartacus peerDependencies manually (as we publish it under 0.201.0-next.0 version)
- [ ] Check that the release notes are populated on github (if they are not, update them)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ docs.zip

# spartacussampledataaddon
spartacussampledataaddon.*
spartacussampledata.*

# dependencies
node_modules/
Expand Down Expand Up @@ -55,3 +56,5 @@ testem.log
# System Files
.DS_Store
Thumbs.db

**/git-ignore
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ git:
branches:
only:
- develop
- master
- "/^feature\\/.*$/"
- "/^hotfix\\/.*$/"
- "/^release\\/.*$/"
- "/^doc\\/.*$/"
- "/^epic\\/.*$/"
env:
- TEST_SUITE="./build.sh sonar"
- TEST_SUITE="./ci-scripts/e2e-cypress.sh"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud. Spartacus talks to SAP Commerce Cloud exclusively through the Commerce REST API.

- Documentation is hosted on our dedicated [Spartacus Documentation site](https://sap.github.io/spartacus-docs/).
- Try out a [sample Spartacus storefront](https://spartacus.c39j2-walkersde1-d4-public.model-t.cc.commerce.ondemand.com/) on our public demo site.
- Try out a [sample Spartacus storefront](https://spartacus-training.eastus.cloudapp.azure.com/) on our public demo site.
- Technical questions? Get in touch with us on [Stack Overflow](https://stackoverflow.com/questions/tagged/spartacus-storefront).
- Non-technical questions? Join our [Slack workspace](https://join.slack.com/t/spartacus-storefront/shared_invite/enQtNDM1OTI3OTMwNjU5LTg1NGVjZmFkZjQzODc1MzFhMjc3OTZmMzIzYzg0YjMwODJiY2YxYjA5MTE5NjVmN2E5NjMxNjEzMGNlMDRjMjU).
- Non-technical questions? Join our [Slack workspace](https://join.slack.com/t/spartacus-storefront/shared_invite/zt-i36rvrqe-kNA9RutaT0W17A_jh0Hygg).
- For details on the 2.0 launch, see the [Release Information page](https://sap.github.io/spartacus-docs/release-information/) on our Spartacus documentation site.

Spartacus is...
Expand Down Expand Up @@ -101,14 +101,14 @@ Spartacus is provided "as-is" with no official lines of support.

To get help from the Spartacus community:

- For more general questions, post a question in the Help chat of our [Slack workspace](https://join.slack.com/t/spartacus-storefront/shared_invite/enQtNDM1OTI3OTMwNjU5LTg1NGVjZmFkZjQzODc1MzFhMjc3OTZmMzIzYzg0YjMwODJiY2YxYjA5MTE5NjVmN2E5NjMxNjEzMGNlMDRjMjU).
- For more general questions, post a question in the Help chat of our [Slack workspace](https://join.slack.com/t/spartacus-storefront/shared_invite/zt-i36rvrqe-kNA9RutaT0W17A_jh0Hygg).
- For developer questions, post a question to [Stack Overflow with the 'spartacus' tag](https://stackoverflow.com/questions/tagged/spartacus).

# Contributing

Team Spartacus welcomes feedback, ideas, requests, and especially code contributions.

- Post comments to our Feedback chat in our [Slack](https://join.slack.com/t/spartacus-storefront/shared_invite/enQtNDM1OTI3OTMwNjU5LTg1NGVjZmFkZjQzODc1MzFhMjc3OTZmMzIzYzg0YjMwODJiY2YxYjA5MTE5NjVmN2E5NjMxNjEzMGNlMDRjMjU) channel.
- Post comments to our Feedback chat in our [Slack](https://join.slack.com/t/spartacus-storefront/shared_invite/zt-i36rvrqe-kNA9RutaT0W17A_jh0Hygg) channel.
- Read the [Contributing document](CONTRIBUTING.md) and learn how to:
- Help others
- Report an issue
Expand Down
2 changes: 1 addition & 1 deletion ci-scripts/build-for-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ yarn build:core:lib:cds

echo "-----"
echo "Building SPA app"
cross-env SPARTACUS_BASE_URL=https://api.c39j2-walkersde1-d4-public.model-t.cc.commerce.ondemand.com ng build storefrontapp
cross-env SPARTACUS_BASE_URL=https://spartacus-training.eastus.cloudapp.azure.com ng build storefrontapp
5 changes: 1 addition & 4 deletions core-libs/setup/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"entryFile": "public_api.ts",
"umdModuleIds": {
"@spartacus/core": "core",
"@spartacus/storefront": "storefront",
"@spartacus/my-account": "my-account",
"@spartacus/my-account/organization": "organization",
"rxjs": "rxjs"
"@spartacus/storefront": "storefront"
}
}
}
3 changes: 1 addition & 2 deletions core-libs/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@angular/core": "^10.1.0",
"rxjs": "^6.6.0",
"@spartacus/core": "3.0.0-next.3",
"@spartacus/storefront": "3.0.0-next.3",
"@spartacus/my-account": "3.0.0-next.3"
"@spartacus/storefront": "3.0.0-next.3"
}
}
5 changes: 2 additions & 3 deletions core-libs/setup/recipes/b2b/b2b-storefront.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ import {
StorefrontConfig,
StorefrontModule,
} from '@spartacus/storefront';
import { OrganizationModule } from '@spartacus/my-account/organization';
import { defaultB2bOccConfig } from './config/default-b2b-occ-config';
import { defaultB2bCheckoutConfig } from './config/default-b2b-checkout-config';
import { defaultB2bOccConfig } from './config/default-b2b-occ-config';

@NgModule({
imports: [
StorefrontModule,

// the cms lib module contains all components that added in the bundle
CmsLibModule,
CostCenterModule.forRoot(),
OrganizationModule,
],
providers: [
provideDefaultConfig(layoutConfig),
Expand Down
16 changes: 1 addition & 15 deletions core-libs/setup/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@
"lib": ["es2020", "dom"],
"paths": {
"@spartacus/core": ["dist/core"],
"@spartacus/storefront": ["dist/storefrontlib"],
"@spartacus/my-account": ["dist/my-account"],
"@spartacus/my-account/organization": ["dist/my-account/organization"],
"@spartacus/my-account/organization/core": [
"dist/my-account/organization/core"
],
"@spartacus/my-account/organization/occ": [
"dist/my-account/organization/occ"
],
"@spartacus/my-account/organization/components": [
"dist/my-account/organization/components"
],
"@spartacus/my-account/organization/assets": [
"dist/my-account/organization/assets"
]
"@spartacus/storefront": ["dist/storefrontlib"]
}
},
"angularCompilerOptions": {
Expand Down
35 changes: 35 additions & 0 deletions docs/migration/3_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Technical Changes in Spartacus 3.0

## Breaking Changes

### Default Router options changed
The Angular router can be initialized with so-called `ExtraOptions` in the `forRoot` method fo the `RouterModule`. See https://angular.io/api/router/ExtraOptions for more information on those options.

The default `ExtraOptions` have changed with 3.0. Before 3.0, Spartacus set the `anchorScrolling` and `scrollPositionRestoration` options. In Spartacus 3.0, the `scrollPositionRestoration` has dropped and the `relativeLinkResolution` has been added. See the below table for the actual values and reasoning

| Option | < 3.0 | > 3.0
| --- | --- | ---
| `anchorScrolling` | `'enabled'` | `'enabled'`
| `scrollPositionRestoration` | `'enabled'` | (removed)
| `relativeLinkResolution` | n/a | `'corrected'`
| | |

The enabled `scrollPositionRestoration` was causing a bad experience in most cases, as it would scroll the page to the top on each route change. This is unexpected in a single page experience.

The corrected `relativeLinkResolution` is used to opt-in to [a fix](https://github.com/angular/angular/issues/37355) that has been added in angular. This will become default from angular 11 onwards.


The `RouterModule.forRoot()` method can actually only be called _once_ in an angular application. This makes the default options rather opinionated, which is why the default configurations are carefully selected in Spartacus. The options that have been added/removed can be provided in your custom application with the Angular `ROUTER_CONFIGURATION` injection token. For example:

```typescript
providers: [
{
provide: ROUTER_CONFIGURATION,
useValue: {
scrollPositionRestoration: 'enabled'
}
}
]
```

There's no automation (schematics) planned for this change.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ export const unit = {
upOneLevel: 'Up one level',
},
children: {
header: 'Child Units in {{code}}',
newChild: 'New child unit',
create: {
title: 'Create child unit',
subtitle: '',
},
},

form: {
parentOrgUnit: 'Parent business unit',
create: 'Create Unit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import {
} from '@spartacus/core';
import {
CartSharedModule,
CmsPageGuard,
FormErrorsModule,
OrderDetailApprovalDetailsComponent,
OrderDetailItemsComponent,
OrderDetailShippingComponent,
OrderDetailsService,
OrderDetailTotalsComponent,
PageLayoutComponent,
SpinnerModule,
} from '@spartacus/storefront';
import { OrderApprovalDetailFormComponent } from './order-approval-detail-form/order-approval-detail-form.component';
Expand All @@ -33,14 +31,7 @@ import { OrderApprovalDetailService } from './order-approval-detail.service';
UrlModule,
FormErrorsModule,
SpinnerModule,
RouterModule.forChild([
{
path: null,
canActivate: [AuthGuard, CmsPageGuard],
component: PageLayoutComponent,
data: { cxRoute: 'orderApprovalDetails' },
},
]),
RouterModule,
ConfigModule.withConfig(<CmsConfig>{
cmsComponents: {
OrderApprovalDetailTotalsComponent: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { PermissionComponentsModule } from './permission/permission-components.m
import { UnitsComponentsModule } from './unit/units-components.module';
import { UserGroupComponentsModule } from './user-group/user-group-components.module';
import { UserComponentsModule } from './user/user-components.module';
import { defaultOrganizationLayoutConfig } from './config/default-organization-layout.config';

@NgModule({
imports: [
Expand All @@ -20,17 +19,12 @@ import { defaultOrganizationLayoutConfig } from './config/default-organization-l
OrderApprovalComponentsModule,
],
providers: [
provideDefaultConfig(defaultOrganizationLayoutConfig),
provideDefaultConfig(<RoutingConfig>{
routing: {
routes: {
organization: {
paths: ['organization'],
},
orderApprovalDetails: {
paths: ['my-account/approval/:approvalCode'],
paramsMapping: { approvalCode: 'approvalCode' },
},
},
},
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { Injectable } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Params } from '@angular/router';
import { RouterState, RoutingService } from '@spartacus/core';
import { RoutingService } from '@spartacus/core';
import { Observable, of, Subject } from 'rxjs';
import { CurrentOrganizationItemService } from './current-organization-item.service';

const mockCode = 'b1';
const PARAM = 'myParam';

const mockParams = new Subject();
const mockState = new Subject();

class MockRoutingService {
getRouterState() {
return mockState;
}

getParams() {
return mockParams;
}
Expand Down Expand Up @@ -58,30 +52,25 @@ describe('CurrentOrganizationItemService', () => {
expect(service).toBeTruthy();
});

describe('parentUnit$', () => {
it('should resolve parentUnit from query parameters', () => {
describe('b2bUnit$', () => {
it('should resolve b2bUnit from route parameter', () => {
let result;
service.b2bUnit$.subscribe((value) => (result = value));
mockParams.next({ unitCode: 'unit1' });
expect(result).toEqual('unit1');
});

it('should resolve b2bUnit among other route parameters', () => {
let result;
service.b2bUnit$.subscribe((unit) => (result = unit));
mockState.next({
state: {
queryParams: {
parentUnit: 'ppp',
} as Params,
},
} as RouterState);
expect(result).toEqual('ppp');
});

it('should not resolve parentUnit from query parameters', () => {
mockState.next({
state: {
queryParams: {
foo: 'bar',
} as Params,
},
} as RouterState);
service.b2bUnit$.subscribe((value) => (result = value));
mockParams.next({ unitCode: 'unit2', foo: 'bar' });
expect(result).toEqual('unit2');
});

it('should resolve b2bUnit from route parameter', () => {
let result;
service.b2bUnit$.subscribe((unit) => (result = unit));
service.b2bUnit$.subscribe((value) => (result = value));
mockParams.next({ foo: 'bar' });
expect(result).toBeFalsy();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { RoutingService } from '@spartacus/core';
import { merge, Observable, of } from 'rxjs';
import { distinctUntilChanged, map, pluck, switchMap } from 'rxjs/operators';
import { QUERY_PARAMS, ROUTE_PARAMS } from '../constants';
import { Observable, of } from 'rxjs';
import { distinctUntilChanged, pluck, switchMap } from 'rxjs/operators';
import { ROUTE_PARAMS } from '../constants';

/**
* Abstract Base class for all organization entities. This class simplifies
Expand Down Expand Up @@ -34,26 +34,12 @@ export abstract class CurrentOrganizationItemService<T> {
switchMap((code: string) => (code ? this.getItem(code) : of(null)))
);

protected unitRouteQueryParam$ = this.routingService
.getRouterState()
.pipe(
map(
(routingData) =>
routingData.state.queryParams?.[QUERY_PARAMS.parentUnit]
)
);

protected unitRouteParam$ = this.routingService
.getParams()
.pipe(pluck(ROUTE_PARAMS.unitCode), distinctUntilChanged());

/**
* Observes the b2bUnit based on the query parameters.
* Observes the b2bUnit based on the unitCode route parameter.
*/
readonly b2bUnit$: Observable<string> = merge(
this.unitRouteQueryParam$,
this.unitRouteParam$
);
readonly b2bUnit$: Observable<string> = this.routingService
.getParams()
.pipe(pluck(ROUTE_PARAMS.unitCode), distinctUntilChanged());

/**
* Returns the route parameter key for the item. The route parameter key differs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ export class ToggleStatusComponent<T extends BaseItem> implements OnDestroy {
protected getPatchedItem(item: T): T {
const patch: BaseItem = {};
patch[this.key] = item[this.key];
if ((item as any).type === 'b2BCostCenterWsDTO') {
(patch as any).activeFlag = !item.active;
} else {
patch.active = !item.active;
}
patch.active = !item.active;
return patch as T;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class OrganizationFormComponent<T> {
this.setI18nRoot(item);
if (!item && unitUid) {
// TODO: as long as we do not have harmonized unit property, we have to workaround here,
item = { orgUnit: { uid: unitUid } } as any;
item = { parentOrgUnit: { uid: unitUid } } as any;
}
return this.itemService.getForm(item);
})
Expand Down
Loading

0 comments on commit cd2ef2c

Please sign in to comment.