diff --git a/src/components.d.ts b/src/components.d.ts
index 7401ae6b8..fcce5d701 100644
--- a/src/components.d.ts
+++ b/src/components.d.ts
@@ -226,13 +226,13 @@ export namespace Components {
interface ManifoldPlanSelector {
'connection': Connection;
'hideProvisionButton'?: boolean;
- 'productId': string;
+ 'productLabel': string;
'resourceId'?: string;
}
interface ManifoldPlanSelectorAttributes extends StencilHTMLAttributes {
'connection'?: Connection;
'hideProvisionButton'?: boolean;
- 'productId'?: string;
+ 'productLabel'?: string;
'resourceId'?: string;
}
diff --git a/src/components/manifold-plan-selector/manifold-plan-selector.tsx b/src/components/manifold-plan-selector/manifold-plan-selector.tsx
index aa25d60c7..58e803b3a 100644
--- a/src/components/manifold-plan-selector/manifold-plan-selector.tsx
+++ b/src/components/manifold-plan-selector/manifold-plan-selector.tsx
@@ -3,9 +3,6 @@ import { Component, State, Prop, Element } from '@stencil/core';
import Tunnel from '../../data/connection';
import { Connection, connections, Env } from '../../utils/connections';
-const byCost = (a: Catalog.ExpandedPlan, b: Catalog.ExpandedPlan) =>
- a.body.cost < b.body.cost ? -1 : 1;
-
@Component({
tag: 'manifold-plan-selector',
shadow: true,
@@ -15,20 +12,21 @@ export class ManifoldPlanSelector {
@Prop() connection: Connection = connections[Env.Prod];
@Prop() resourceId?: string;
@Prop() hideProvisionButton?: boolean;
- @Prop() productId: string;
+ @Prop() productLabel: string;
@State() product: Catalog.ExpandedProduct;
@State() plans: Catalog.Plan[];
async componentWillLoad() {
- await fetch(`${this.connection.catalog}/products/${this.productId}`)
- .then(response => response.json())
- .then(data => {
- this.product = data;
- });
- await fetch(`${this.connection.catalog}/plans?product_id=${this.productId}`)
+ await fetch(`${this.connection.catalog}/products/?label=${this.productLabel}`)
.then(response => response.json())
- .then(data => {
- this.plans = data.sort(byCost);
+ .then((products: Catalog.ExpandedProduct[]) => {
+ const [product] = products;
+ this.product = product
+ fetch(`${this.connection.catalog}/plans/?product_id=${product.id}`)
+ .then(response => response.json())
+ .then((plans: Catalog.ExpandedPlan[]) => {
+ this.plans = [...plans.sort((a, b) => a.body.cost - b.body.cost)]
+ });
});
}
diff --git a/src/components/manifold-plan-selector/readme.md b/src/components/manifold-plan-selector/readme.md
index c437b6b40..2a7f1cd75 100644
--- a/src/components/manifold-plan-selector/readme.md
+++ b/src/components/manifold-plan-selector/readme.md
@@ -3,9 +3,13 @@
Display the plans for a product.
```html
-
Display the plans for a product.
-<manifold-plan-selector product-id="234w1jyaum5j0aqe3g3bmbqjgf20p"></manifold-plan-selector>
+ <manifold-plan-selector product-label="jawsdb-mysql"></manifold-plan-selector>
+ Product Label
+
+ You can find the :service
label for each at
+ https://manifold.co/services/:service
.
+
Detecting changes
Events are dispatched on the manifold-planUpdated
custom event. To
@@ -366,8 +371,8 @@
Properties
undefined
- productId
- product-id
+ productLabel
+ product-label
string
undefined
@@ -389,14 +394,7 @@ Properties
-
-
-
-
-
-
+