Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
import React , { FormEvent , ReactElement } from 'react'
2022-11-04 14:52:40 +01:00
import Button from '../../../@shared/atoms/Button'
2021-10-18 20:44:33 +02:00
import styles from './index.module.css'
2022-11-04 14:52:40 +01:00
import Loader from '../../../@shared/atoms/Loader'
2022-06-17 14:51:16 +02:00
import { useWeb3 } from '@context/Web3'
2022-10-20 14:17:36 +02:00
import Web3 from 'web3'
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
2022-11-11 10:54:21 +01:00
export interface ButtonBuyProps {
2022-03-23 14:30:03 +01:00
action : 'download' | 'compute'
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
disabled : boolean
hasPreviousOrder : boolean
hasDatatoken : boolean
2022-08-03 14:48:57 +02:00
btSymbol : string
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
dtSymbol : string
dtBalance : string
2021-04-08 17:10:51 +02:00
assetType : string
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
assetTimeout : string
2021-07-06 08:51:37 +02:00
isConsumable : boolean
consumableFeedback : string
2021-04-08 17:10:51 +02:00
hasPreviousOrderSelectedComputeAsset? : boolean
hasDatatokenSelectedComputeAsset? : boolean
dtSymbolSelectedComputeAsset? : string
dtBalanceSelectedComputeAsset? : string
selectedComputeAssetType? : string
2021-08-31 09:47:55 +02:00
isBalanceSufficient : boolean
2022-04-27 08:50:17 +02:00
isLoading? : boolean
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
onClick ? : ( e : FormEvent < HTMLButtonElement > ) = > void
stepText? : string
type ? : 'submit'
2021-06-16 03:32:11 +02:00
priceType? : string
algorithmPriceType? : string
2022-03-01 00:43:57 +01:00
isAlgorithmConsumable? : boolean
2022-06-14 18:30:35 +02:00
isSupportedOceanNetwork? : boolean
2022-06-20 05:54:26 +02:00
hasProviderFee? : boolean
2022-11-11 10:54:21 +01:00
retry? : boolean
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
}
2021-04-08 17:10:51 +02:00
function getConsumeHelpText (
2022-08-03 14:48:57 +02:00
btSymbol : string ,
2021-04-08 17:10:51 +02:00
dtBalance : string ,
dtSymbol : string ,
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
hasDatatoken : boolean ,
hasPreviousOrder : boolean ,
2021-07-06 08:51:37 +02:00
assetType : string ,
isConsumable : boolean ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient : boolean ,
2022-06-14 18:30:35 +02:00
consumableFeedback : string ,
2022-06-17 14:51:16 +02:00
isSupportedOceanNetwork : boolean ,
2022-10-20 14:17:36 +02:00
web3 : Web3
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
) {
2021-07-06 08:51:37 +02:00
const text =
isConsumable === false
? consumableFeedback
2022-06-24 15:06:13 +02:00
: hasPreviousOrder && web3 && isSupportedOceanNetwork
2021-07-06 08:51:37 +02:00
? ` You bought this ${ assetType } already allowing you to use it without paying again. `
: hasDatatoken
2022-08-15 15:57:53 +02:00
? ` You own ${ dtBalance } ${ dtSymbol } allowing you to use this dataset by spending 1 ${ dtSymbol } , but without paying ${ btSymbol } again. `
2022-06-24 15:06:13 +02:00
: isBalanceSufficient === false
2022-08-03 14:48:57 +02:00
? ` You do not have enough ${ btSymbol } in your wallet to purchase this asset. `
2022-08-02 11:53:22 +02:00
: ` For using this ${ assetType } , you will buy 1 ${ dtSymbol } and immediately spend it back to the publisher. `
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
return text
}
2022-06-14 18:30:35 +02:00
function getAlgoHelpText (
dtSymbolSelectedComputeAsset : string ,
dtBalanceSelectedComputeAsset : string ,
isConsumable : boolean ,
isAlgorithmConsumable : boolean ,
hasPreviousOrderSelectedComputeAsset : boolean ,
selectedComputeAssetType : string ,
hasDatatokenSelectedComputeAsset : boolean ,
isBalanceSufficient : boolean ,
2022-06-24 15:06:13 +02:00
isSupportedOceanNetwork : boolean ,
2022-10-20 14:17:36 +02:00
web3 : Web3
2022-06-14 18:30:35 +02:00
) {
const text =
( ! dtSymbolSelectedComputeAsset && ! dtBalanceSelectedComputeAsset ) ||
isConsumable === false ||
isAlgorithmConsumable === false
? ''
2022-06-24 15:06:13 +02:00
: hasPreviousOrderSelectedComputeAsset && web3 && isSupportedOceanNetwork
2022-06-14 18:30:35 +02:00
? ` You already bought the selected ${ selectedComputeAssetType } , allowing you to use it without paying again. `
: hasDatatokenSelectedComputeAsset
? ` You own ${ dtBalanceSelectedComputeAsset } ${ dtSymbolSelectedComputeAsset } allowing you to use the selected ${ selectedComputeAssetType } by spending 1 ${ dtSymbolSelectedComputeAsset } , but without paying OCEAN again. `
2022-06-24 15:06:13 +02:00
: web3 && ! isSupportedOceanNetwork
? ` Connect to the correct network to interact with this asset. `
: isBalanceSufficient === false
2022-06-14 18:30:35 +02:00
? ''
: ` Additionally, you will buy 1 ${ dtSymbolSelectedComputeAsset } for the ${ selectedComputeAssetType } and spend it back to its publisher and pool. `
return text
}
2021-04-08 17:10:51 +02:00
function getComputeAssetHelpText (
hasPreviousOrder : boolean ,
hasDatatoken : boolean ,
2022-08-03 14:48:57 +02:00
btSymbol : string ,
2021-04-08 17:10:51 +02:00
dtSymbol : string ,
dtBalance : string ,
2021-07-06 08:51:37 +02:00
isConsumable : boolean ,
consumableFeedback : string ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient : boolean ,
2021-04-08 17:10:51 +02:00
hasPreviousOrderSelectedComputeAsset? : boolean ,
hasDatatokenSelectedComputeAsset? : boolean ,
2022-08-02 11:53:22 +02:00
assetType? : string ,
2021-04-08 17:10:51 +02:00
dtSymbolSelectedComputeAsset? : string ,
dtBalanceSelectedComputeAsset? : string ,
2021-07-06 08:51:37 +02:00
selectedComputeAssetType? : string ,
2022-06-14 18:30:35 +02:00
isAlgorithmConsumable? : boolean ,
2022-06-17 14:51:16 +02:00
isSupportedOceanNetwork? : boolean ,
2022-10-20 14:17:36 +02:00
web3? : Web3 ,
2022-06-20 05:54:26 +02:00
hasProviderFee? : boolean
2021-04-08 17:10:51 +02:00
) {
const computeAssetHelpText = getConsumeHelpText (
2022-08-03 14:48:57 +02:00
btSymbol ,
2021-04-08 17:10:51 +02:00
dtBalance ,
dtSymbol ,
hasDatatoken ,
hasPreviousOrder ,
2021-07-06 08:51:37 +02:00
assetType ,
isConsumable ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient ,
2022-06-14 18:30:35 +02:00
consumableFeedback ,
2022-06-17 14:51:16 +02:00
isSupportedOceanNetwork ,
web3
2021-04-08 17:10:51 +02:00
)
2022-06-14 18:30:35 +02:00
2022-10-20 14:17:36 +02:00
const computeAlgoHelpText = getAlgoHelpText (
dtSymbolSelectedComputeAsset ,
dtBalanceSelectedComputeAsset ,
isConsumable ,
isAlgorithmConsumable ,
hasPreviousOrderSelectedComputeAsset ,
selectedComputeAssetType ,
hasDatatokenSelectedComputeAsset ,
isBalanceSufficient ,
isSupportedOceanNetwork ,
web3
)
2022-06-23 17:53:05 +02:00
const providerFeeHelpText = hasProviderFee
2022-06-20 05:54:26 +02:00
? 'In order to start the job you also need to pay the fees for renting the c2d resources.'
: 'C2D resources required to start the job are available, no payment required for those fees.'
2022-08-02 11:53:22 +02:00
const computeHelpText = ` ${ computeAssetHelpText } ${ computeAlgoHelpText } ${ providerFeeHelpText } `
2021-07-22 13:04:55 +02:00
return computeHelpText
2021-04-08 17:10:51 +02:00
}
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
export default function ButtonBuy ( {
action ,
disabled ,
hasPreviousOrder ,
hasDatatoken ,
2022-08-03 14:48:57 +02:00
btSymbol ,
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
dtSymbol ,
dtBalance ,
2021-04-08 17:10:51 +02:00
assetType ,
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
assetTimeout ,
2021-07-06 08:51:37 +02:00
isConsumable ,
consumableFeedback ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient ,
2021-04-08 17:10:51 +02:00
hasPreviousOrderSelectedComputeAsset ,
hasDatatokenSelectedComputeAsset ,
dtSymbolSelectedComputeAsset ,
dtBalanceSelectedComputeAsset ,
selectedComputeAssetType ,
onClick ,
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
stepText ,
isLoading ,
2021-06-16 03:32:11 +02:00
type ,
priceType ,
2021-07-06 08:51:37 +02:00
algorithmPriceType ,
2022-06-14 18:30:35 +02:00
isAlgorithmConsumable ,
2022-11-11 10:54:21 +01:00
hasProviderFee ,
2022-11-14 16:47:44 +01:00
retry ,
isSupportedOceanNetwork
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
} : ButtonBuyProps ) : ReactElement {
2022-06-17 14:51:16 +02:00
const { web3 } = useWeb3 ( )
2022-11-11 10:54:21 +01:00
const buttonText = retry
? 'Retry'
: action === 'download'
? hasPreviousOrder
? 'Download'
: priceType === 'free'
? 'Get'
: ` Buy ${ assetTimeout === 'Forever' ? '' : ` for ${ assetTimeout } ` } `
: hasPreviousOrder &&
hasPreviousOrderSelectedComputeAsset &&
! hasProviderFee
? 'Start Compute Job'
: priceType === 'free' && algorithmPriceType === 'free'
? 'Order Compute Job'
: ` Buy Compute Job `
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
return (
< div className = { styles . actions } >
{ isLoading ? (
< Loader message = { stepText } / >
) : (
< >
< Button
style = "primary"
type = { type }
onClick = { onClick }
disabled = { disabled }
2022-06-14 14:21:56 +02:00
className = { action === 'compute' ? styles . actionsCenter : '' }
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
>
{ buttonText }
< / Button >
< div className = { styles . help } >
2021-04-08 17:10:51 +02:00
{ action === 'download'
? getConsumeHelpText (
2022-08-03 14:48:57 +02:00
btSymbol ,
2021-04-08 17:10:51 +02:00
dtBalance ,
dtSymbol ,
hasDatatoken ,
hasPreviousOrder ,
2021-07-06 08:51:37 +02:00
assetType ,
isConsumable ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient ,
2022-06-14 18:30:35 +02:00
consumableFeedback ,
2022-06-17 14:51:16 +02:00
isSupportedOceanNetwork ,
web3
2021-04-08 17:10:51 +02:00
)
: getComputeAssetHelpText (
hasPreviousOrder ,
hasDatatoken ,
2022-08-03 14:48:57 +02:00
btSymbol ,
2021-04-08 17:10:51 +02:00
dtSymbol ,
dtBalance ,
2021-07-06 08:51:37 +02:00
isConsumable ,
consumableFeedback ,
2021-08-31 09:47:55 +02:00
isBalanceSufficient ,
2021-04-08 17:10:51 +02:00
hasPreviousOrderSelectedComputeAsset ,
hasDatatokenSelectedComputeAsset ,
2022-08-02 11:53:22 +02:00
assetType ,
2021-04-08 17:10:51 +02:00
dtSymbolSelectedComputeAsset ,
dtBalanceSelectedComputeAsset ,
2021-07-06 08:51:37 +02:00
selectedComputeAssetType ,
2022-06-14 18:30:35 +02:00
isAlgorithmConsumable ,
2022-06-17 14:51:16 +02:00
isSupportedOceanNetwork ,
2022-06-21 14:32:20 +02:00
web3 ,
2022-06-20 05:54:26 +02:00
hasProviderFee
2021-04-08 17:10:51 +02:00
) }
Start compute job (#439)
* Wip start compute job
* Wip select algorithm design
* Asset selection form component, for start compute job (#442)
* prototype AssetSelection
* assetselection styling
* typing "fix"
* put back file info icon
* AssetSelection styling in context
* update start job method, fixed algo select, and fixed option typing
* compute logic update
* add has previous orders for algo asset
* fixed search algorithm assets in start compute form
* fixed lint errors
* updated previous order for algo logic and compute flow
* update use price hook and added buy DT for algo
* display only alg of type exchange and sort by value
* display only trusted algo for asset if field is set
* added logic for allow all published algorithms or no algorithms allowed
* asset selection style & spacing tweaks
* refactor get algorithms for compute and edit compute
* fixed form options and more refactoring
* new ButtonBuy component
* shared component between consume/compute
* dealing with various states: loading, previous orders, help text output
* effect dependencies
* move error output into toast
* formik data flow refactor
* ditch custom field change handler
* fix initialValues
* typed form data & validation
* fixes multiple form validation issues along the way
* isInitialValid → validateOnMount
* metadata display tweaks
* error feedback tweaks
* oler assets checks, confeti on succes job, market fee on order, removed algo compute logic
* more startJob logging
* feedback & messaging changes
* metadata display
* return all algos, fixed & dynamic priced ones
* fix DOM nesting
* messaging updates
* copy tweaks
* check algorithm previous history for both acces and compute sercive types
* handle start compute error
* extra checks on start compute response
* styling tweaks, fix toast UI errors
* AssetSelection: empty screen, tweak min/max height
* fix FRE issues on start compute
* check is ordarable before start compute job
* logging tweaks
* disable eslint no-unused-vars rule for some Apollo code blocks
* fix metadata editing for compute assets
* consider dataset timeout for compute too
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-04-01 17:21:08 +02:00
< / div >
< / >
) }
< / div >
)
}