Browse Source

Merge branch 'master' into minor

Michael Bromley 4 years ago
parent
commit
52e5405977

+ 1 - 1
README.md

@@ -97,7 +97,7 @@ Running `yarn codegen` will generate the following files:
 * [`packages/common/src/generated-types.ts`](./packages/common/src/generated-types.ts): Types, Inputs & resolver args relating to the Admin API
 * [`packages/common/src/generated-shop-types.ts`](./packages/common/src/generated-shop-types.ts): Types, Inputs & resolver args relating to the Shop API
 * [`packages/admin-ui/src/lib/core/src/common/generated-types.ts`](./packages/admin-ui/src/lib/core/src/common/generated-types.ts): Types & operations relating to the admin-ui queries & mutations.
-* [`packages/admin-ui/src/lib/core/src/common/introspection-result.ts`](./packages/admin-ui/src/lib/core/src/common/introspection-result.ts): Used by the Apollo Client [`IntrospectionFragmentMatcher`](https://www.apollographql.com/docs/react/data/fragments/#fragments-on-unions-and-interfaces) to correctly handle fragements in the Admin UI.
+* [`packages/admin-ui/src/lib/core/src/common/introspection-result.ts`](./packages/admin-ui/src/lib/core/src/common/introspection-result.ts): Used by the Apollo Client [`IntrospectionFragmentMatcher`](https://www.apollographql.com/docs/react/data/fragments/#fragments-on-unions-and-interfaces) to correctly handle fragments in the Admin UI.
 * Also generates types used in e2e tests in those packages which feature e2e tests (core, elasticsearch-plugin, asset-server-plugin etc).
 
 ### Testing

+ 1 - 1
packages/admin-ui/src/lib/catalog/src/components/variant-price-detail/variant-price-detail.component.ts

@@ -25,7 +25,7 @@ export class VariantPriceDetailComponent implements OnInit, OnChanges {
 
     ngOnInit() {
         const taxRates$ = this.dataService.settings
-            .getTaxRates(999, 0, 'cache-first')
+            .getTaxRatesSimple(999, 0, 'cache-first')
             .mapStream(data => data.taxRates.items);
         const activeChannel$ = this.dataService.settings
             .getActiveChannel('cache-first')

+ 30 - 0
packages/admin-ui/src/lib/core/src/common/generated-types.ts

@@ -7571,6 +7571,27 @@ export type GetTaxRateListQuery = { taxRates: (
     )> }
   ) };
 
+export type GetTaxRateListSimpleQueryVariables = Exact<{
+  options?: Maybe<TaxRateListOptions>;
+}>;
+
+
+export type GetTaxRateListSimpleQuery = { taxRates: (
+    { __typename?: 'TaxRateList' }
+    & Pick<TaxRateList, 'totalItems'>
+    & { items: Array<(
+      { __typename?: 'TaxRate' }
+      & Pick<TaxRate, 'id' | 'createdAt' | 'updatedAt' | 'name' | 'enabled' | 'value'>
+      & { category: (
+        { __typename?: 'TaxCategory' }
+        & Pick<TaxCategory, 'id' | 'name'>
+      ), zone: (
+        { __typename?: 'Zone' }
+        & Pick<Zone, 'id' | 'name'>
+      ) }
+    )> }
+  ) };
+
 export type GetTaxRateQueryVariables = Exact<{
   id: Scalars['ID'];
 }>;
@@ -10141,6 +10162,15 @@ export namespace GetTaxRateList {
   export type Items = NonNullable<(NonNullable<(NonNullable<GetTaxRateListQuery['taxRates']>)['items']>)[number]>;
 }
 
+export namespace GetTaxRateListSimple {
+  export type Variables = GetTaxRateListSimpleQueryVariables;
+  export type Query = GetTaxRateListSimpleQuery;
+  export type TaxRates = (NonNullable<GetTaxRateListSimpleQuery['taxRates']>);
+  export type Items = NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>;
+  export type Category = (NonNullable<NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>['category']>);
+  export type Zone = (NonNullable<NonNullable<(NonNullable<(NonNullable<GetTaxRateListSimpleQuery['taxRates']>)['items']>)[number]>['zone']>);
+}
+
 export namespace GetTaxRate {
   export type Variables = GetTaxRateQueryVariables;
   export type Query = GetTaxRateQuery;

+ 24 - 0
packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts

@@ -259,6 +259,30 @@ export const GET_TAX_RATE_LIST = gql`
     ${TAX_RATE_FRAGMENT}
 `;
 
+export const GET_TAX_RATE_LIST_SIMPLE = gql`
+    query GetTaxRateListSimple($options: TaxRateListOptions) {
+        taxRates(options: $options) {
+            items {
+                id
+                createdAt
+                updatedAt
+                name
+                enabled
+                value
+                category {
+                    id
+                    name
+                }
+                zone {
+                    id
+                    name
+                }
+            }
+            totalItems
+        }
+    }
+`;
+
 export const GET_TAX_RATE = gql`
     query GetTaxRate($id: ID!) {
         taxRate(id: $id) {

+ 15 - 0
packages/admin-ui/src/lib/core/src/data/providers/settings-data.service.ts

@@ -40,6 +40,7 @@ import {
     GetTaxCategory,
     GetTaxRate,
     GetTaxRateList,
+    GetTaxRateListSimple,
     GetZone,
     GetZones,
     JobListOptions,
@@ -93,6 +94,7 @@ import {
     GET_TAX_CATEGORY,
     GET_TAX_RATE,
     GET_TAX_RATE_LIST,
+    GET_TAX_RATE_LIST_SIMPLE,
     GET_ZONES,
     REMOVE_MEMBERS_FROM_ZONE,
     UPDATE_CHANNEL,
@@ -243,6 +245,19 @@ export class SettingsDataService {
         );
     }
 
+    getTaxRatesSimple(take: number = 10, skip: number = 0, fetchPolicy?: FetchPolicy) {
+        return this.baseDataService.query<GetTaxRateListSimple.Query, GetTaxRateListSimple.Variables>(
+            GET_TAX_RATE_LIST_SIMPLE,
+            {
+                options: {
+                    take,
+                    skip,
+                },
+            },
+            fetchPolicy,
+        );
+    }
+
     getTaxRate(id: string) {
         return this.baseDataService.query<GetTaxRate.Query, GetTaxRate.Variables>(GET_TAX_RATE, {
             id,

+ 7 - 2
packages/core/src/api/resolvers/admin/tax-category.resolver.ts

@@ -20,8 +20,13 @@ export class TaxCategoryResolver {
     constructor(private taxCategoryService: TaxCategoryService) {}
 
     @Query()
-    @Allow(Permission.ReadSettings, Permission.ReadCatalog, Permission.ReadTaxCategory)
-    taxCategories(@Ctx() ctx: RequestContext): Promise<TaxCategory[]> {
+    @Allow(
+        Permission.ReadSettings,
+        Permission.ReadCatalog,
+        Permission.ReadProduct,
+        Permission.ReadTaxCategory,
+    )
+    async taxCategories(@Ctx() ctx: RequestContext): Promise<TaxCategory[]> {
         return this.taxCategoryService.findAll(ctx);
     }
 

+ 5 - 2
packages/core/src/api/resolvers/admin/tax-rate.resolver.ts

@@ -22,8 +22,11 @@ export class TaxRateResolver {
     constructor(private taxRateService: TaxRateService) {}
 
     @Query()
-    @Allow(Permission.ReadSettings, Permission.ReadCatalog, Permission.ReadTaxRate)
-    taxRates(@Ctx() ctx: RequestContext, @Args() args: QueryTaxRatesArgs): Promise<PaginatedList<TaxRate>> {
+    @Allow(Permission.ReadSettings, Permission.ReadCatalog, Permission.ReadProduct, Permission.ReadTaxRate)
+    async taxRates(
+        @Ctx() ctx: RequestContext,
+        @Args() args: QueryTaxRatesArgs,
+    ): Promise<PaginatedList<TaxRate>> {
         return this.taxRateService.findAll(ctx, args.options || undefined);
     }
 

+ 1 - 1
packages/core/src/config/catalog/collection-filter.ts

@@ -25,7 +25,7 @@ export interface CollectionFilterConfig<T extends ConfigArgs> extends Configurab
  * [`QueryBuilder`](https://typeorm.io/#/select-query-builder) object to which clauses may be added.
  *
  * Creating a CollectionFilter is considered an advanced Vendure topic. For more insight into how
- * they work, study the [default collection filters](https://github.com/vendure-ecommerce/vendure/blob/master/packages/core/src/config/collection/default-collection-filters.ts)
+ * they work, study the [default collection filters](https://github.com/vendure-ecommerce/vendure/blob/master/packages/core/src/config/catalog/default-collection-filters.ts)
  *
  * @docsCategory configuration
  */