From af40c8edb6acc56008bb17e48cf3d45e8c4adef1 Mon Sep 17 00:00:00 2001 From: maany Date: Thu, 14 Dec 2023 01:24:54 +0100 Subject: [PATCH] add create rule status page #395 --- .../Demos/03_1_Create_Rules.stories.tsx | 14 ++- .../Pages/Rule/CreateRule.stories.tsx | 14 ++- .../Pages/Rule/CreateRule.tsx | 14 +-- .../Rule/CreateRuleStatusPage.stories.tsx | 13 ++- .../Pages/Rule/CreateRuleStatusPage.tsx | 101 ++++++++++++++++-- .../Pages/Rule/DIDSummaryTable.stories.tsx | 2 +- src/component-library/Pages/Rule/RulePage.tsx | 7 +- src/component-library/outputtailwind.css | 15 +++ .../data/view-model/create-rule.ts | 12 ++- test/component/CreateRule.test.tsx | 2 +- 10 files changed, 159 insertions(+), 35 deletions(-) diff --git a/src/component-library/Demos/03_1_Create_Rules.stories.tsx b/src/component-library/Demos/03_1_Create_Rules.stories.tsx index 6b167b2e4..24f84fcf9 100644 --- a/src/component-library/Demos/03_1_Create_Rules.stories.tsx +++ b/src/component-library/Demos/03_1_Create_Rules.stories.tsx @@ -16,10 +16,16 @@ export const CreateRule: Story = { onSubmit: (query: TCreateRuleFeatureRequestParams): Promise => { return Promise.resolve({ status: 'success', - rules: { - "123123143243": "scope:dataset1", - "127849dsgs": "scope:dataset2", - } + rules: [ + { + RuleID: "123123143243", + DID: "scope:dataset1" + }, + { + RuleID: "127849dsgs", + DID: "scope:dataset2" + }, + ] }) }, didListComDOM: mockUseComDOM(Array.from({ length: 100 }, () => fixtureListDIDViewModel())), diff --git a/src/component-library/Pages/Rule/CreateRule.stories.tsx b/src/component-library/Pages/Rule/CreateRule.stories.tsx index b85a942d0..ae36e128b 100644 --- a/src/component-library/Pages/Rule/CreateRule.stories.tsx +++ b/src/component-library/Pages/Rule/CreateRule.stories.tsx @@ -20,10 +20,16 @@ CreateRule.args = { onSubmit: (query: TCreateRuleFeatureRequestParams): Promise => { return Promise.resolve({ status: 'success', - rules: { - "123123143243": "scope:dataset1", - "127849dsgs": "scope:dataset2", - } + rules: [ + { + RuleID: "123123143243", + DID: "scope:dataset1" + }, + { + RuleID: "127849dsgs", + DID: "scope:dataset2" + }, + ] }) }, didListComDOM: mockUseComDOM(Array.from({ length: 100 }, () => fixtureListDIDsViewModel())), diff --git a/src/component-library/Pages/Rule/CreateRule.tsx b/src/component-library/Pages/Rule/CreateRule.tsx index 76869ead6..c96edf94a 100644 --- a/src/component-library/Pages/Rule/CreateRule.tsx +++ b/src/component-library/Pages/Rule/CreateRule.tsx @@ -282,11 +282,11 @@ export const CreateRule = ( * ================================================= */ const [Page4State, setPage4State] = useState({ status: 'pending', - rules: {} + rules: [] }) const submitRuleRequestAndLoadStatus = async (event: any) => { - setPage4State({ rules: {}, status: 'pending' }) + setPage4State({ rules: [], status: 'pending' }) setActivePage(4) const createRulesRequest:TCreateRuleFeatureRequestParams = { RSEViewModels: Page1State.RSESelection, @@ -326,7 +326,7 @@ export const CreateRule = ( /> - { page0nextFunction(event) }} onPrev={pagePrevFunction}> + { page0nextFunction(event) }} onPrev={pagePrevFunction}> - { setActivePage(activePage + 1) }} onPrev={pagePrevFunction}> + { setActivePage(activePage + 1) }} onPrev={pagePrevFunction}>
@@ -416,7 +416,7 @@ export const CreateRule = (
- { loadRuleSummaryPage() }} onPrev={pagePrevFunction}> + { loadRuleSummaryPage() }} onPrev={pagePrevFunction}>
@@ -527,7 +527,7 @@ export const CreateRule = (
- + - {}} isLastPage> + {}} allowNext={false} allowPrev={Page4State.status === 'error'}> diff --git a/src/component-library/Pages/Rule/CreateRuleStatusPage.stories.tsx b/src/component-library/Pages/Rule/CreateRuleStatusPage.stories.tsx index 299f9871b..e68895027 100644 --- a/src/component-library/Pages/Rule/CreateRuleStatusPage.stories.tsx +++ b/src/component-library/Pages/Rule/CreateRuleStatusPage.stories.tsx @@ -14,8 +14,17 @@ const Template: StoryFn = (args) => { - const [viewModel, setViewModel] = useState("") + const columnHelper = createColumnHelper() + const tablecolumns: any[] = [ + columnHelper.accessor("RuleID", { + id: "RuleID", + header: info => { + return ( +
+ Rule ID +
+ ) + }, + cell: info => { + return ( +
+ + {info.getValue()} + +
+ ) + } + }), + columnHelper.accessor("DID", { + id: "DID", + header: info => { + return ( +
+ DID +
+ ) + }, + cell: info => { + return ( +
+ {info.getValue()} +
+ ) + } + }), + ] // Handle Loading State - if (!createRuleViewModel) return ( + if (!createRuleViewModel || createRuleViewModel.status === 'pending') return (
) // Handle errors - if(createRuleViewModel.status === 'error'){ + if (createRuleViewModel.status === 'error') { const errorMessage = createRuleViewModel.message return (
-
-
{errorMessage}
+ +
+ {errorMessage}
) @@ -51,15 +107,40 @@ export const CreateRuleStatusPage = ({ return (
-
-
Success!
+ + +
+ You can also view all your rules by clicking  + + here. +
) diff --git a/src/component-library/Pages/Rule/DIDSummaryTable.stories.tsx b/src/component-library/Pages/Rule/DIDSummaryTable.stories.tsx index 073e584ec..d430b3ca4 100644 --- a/src/component-library/Pages/Rule/DIDSummaryTable.stories.tsx +++ b/src/component-library/Pages/Rule/DIDSummaryTable.stories.tsx @@ -4,7 +4,7 @@ import { Meta, StoryFn } from "@storybook/react"; import { DIDSummaryTable } from "./DIDSummaryTable"; export default { - title: 'Components/Pages/Rule/CreateRule/DIDSummaryTable', + title: 'Components/Pages/Rule/DIDSummaryTable', component: DIDSummaryTable, } as Meta; diff --git a/src/component-library/Pages/Rule/RulePage.tsx b/src/component-library/Pages/Rule/RulePage.tsx index daa011253..f03052a2d 100644 --- a/src/component-library/Pages/Rule/RulePage.tsx +++ b/src/component-library/Pages/Rule/RulePage.tsx @@ -8,7 +8,8 @@ export const RulePage = ( activePage: number, onNext: (event: any) => void, onPrev: (event: any) => void, - isLastPage?: boolean, + allowNext: boolean, + allowPrev: boolean, submit?: boolean, progressBlocked?: boolean, children?: any @@ -27,13 +28,13 @@ export const RulePage = ( {props.children}
- +