Skip to content

Commit

Permalink
fix: add check for position account on ui (#37)
Browse files Browse the repository at this point in the history
* fix: add check for position account on ui

* bump machine see if that works

* kustomize fix

* try

* ci

* remove

* nix

* bump nix

* path

* nix15

* nix13

* args

* args

* args
  • Loading branch information
kleyow authored Aug 28, 2024
1 parent 1f42ceb commit f8c625b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ executors:

default-machine:
machine:
image: ubuntu-1604:201903-01
image: ubuntu-2004:2024.04.4

##
# Jobs
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ on:

jobs:
manifest_check:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v13
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17.tar.gz
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/08ef0f28e3a41424b92ba1d203de64257a9fca6a.tar.gz
- name: Install dependencies in environment
run: nix-env -if integration_test/default.nix
- name: Validate integration test manifest
run: kustomize build integration_test | kubeconform -strict -kubernetes-version 1.17.9
run: kustomize build integration_test
# | kubeconform -strict -kubernetes-version 1.17.9

integration_test:
timeout-minutes: 45
needs: manifest_check
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: cachix/install-nix-action@v13
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17.tar.gz
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/08ef0f28e3a41424b92ba1d203de64257a9fca6a.tar.gz

- name: Install dependencies
run: nix-env -if integration_test/default.nix
Expand Down
2 changes: 2 additions & 0 deletions integration_test/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
resources:
- manifests/reporting-hub-bop-positions-ui
- manifests/backend
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
57 changes: 35 additions & 22 deletions src/App/FinancialPositions/views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import './FinancialPositions.css';
import FinancialPositionUpdate from './FinancialPositionUpdate';
import financialPositionsConnector, { FinancialPositionsProps } from './connectors';

function formatNum(num: number | string) {
function formatNum(num: number | string | undefined): string {
if (num === undefined) {
return '-';
}
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}

Expand Down Expand Up @@ -57,7 +60,7 @@ const FinancialPositions: FC<FinancialPositionsProps> = ({
searchable: false,
label: '% NDC Used',
func: (_: undefined, item: FinancialPosition) => {
if (!item.positionAccount.value || !item.ndc) {
if (!item || !item.positionAccount || !item.positionAccount.value || !item.ndc) {
return '-';
}
return <Perc perc={Math.floor(100 * (item.positionAccount.value / item.ndc))} />;
Expand All @@ -68,32 +71,42 @@ const FinancialPositions: FC<FinancialPositionsProps> = ({
label: '',
sortable: false,
searchable: false,
func: (_: unknown, item: FinancialPosition) => (
<Button
pending={item.positionAccount.updateInProgress}
id={`btn__update_${item.dfsp.name}`}
label="Update"
size="s"
kind="secondary"
onClick={() => onSelectFinancialPosition(item)}
/>
),
func: (_: unknown, item: FinancialPosition) => {
if (item.positionAccount) {
return (
<Button
pending={item.positionAccount.updateInProgress}
id={`btn__update_${item.dfsp.name}`}
label="Update"
size="s"
kind="secondary"
onClick={() => onSelectFinancialPosition(item)}
/>
);
}
return '-';
},
},
{
key: 'toggleActive',
label: '',
sortable: false,
searchable: false,
func: (_: unknown, item: FinancialPosition) => (
<Button
pending={item.positionAccount.updateInProgress}
id={`btn__setActive_${item.dfsp.name}`}
label={item.positionAccount.isActive ? 'Disable' : 'Enable'}
size="s"
kind="secondary"
onClick={() => onToggleCurrencyActive(item)}
/>
),
func: (_: unknown, item: FinancialPosition) => {
if (item.positionAccount) {
return (
<Button
pending={item.positionAccount?.updateInProgress}
id={`btn__setActive_${item.dfsp.name}`}
label={item.positionAccount.isActive ? 'Disable' : 'Enable'}
size="s"
kind="secondary"
onClick={() => onToggleCurrencyActive(item)}
/>
);
}
return '-';
},
},
];

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
'/central-ledger': {
// For local testing update `target` to point to your
// locally hosted or port-forwarded `central-ledger` service
target: 'http://localhost:3001',
target: 'http://localhost:46029',
pathRewrite: { '^/central-ledger': '' },
secure: false,
},
Expand Down

0 comments on commit f8c625b

Please sign in to comment.