Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: endorsement list and request endorsement for schema #324

Merged
merged 22 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4b50d4d
Implemented Endorsement list page, updated content with ecosystem rol…
sanjay-k1910 Oct 5, 2023
17dc1f2
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 6, 2023
a5ac739
feat: endorsement popups
MoulikaKulkarni Oct 6, 2023
e3e943f
feat: endorsement popups
MoulikaKulkarni Oct 6, 2023
42af753
feat: endorsement popups
MoulikaKulkarni Oct 6, 2023
70c165e
feat: endorsement popups
MoulikaKulkarni Oct 6, 2023
28130c1
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 7, 2023
411599a
refactor: added endorsement request apis and implemented confirmpopup…
sanjay-k1910 Oct 7, 2023
5f5d25c
Merge branch 'feat-endorsement' of https://github.com/credebl/studio …
sanjay-k1910 Oct 7, 2023
a20920a
Merge pull request #318 from credebl/ecosystem-endorsement-popups
sanjay-k1910 Oct 7, 2023
e6c7d44
refactor: create schema endorsement request API, endorsement card add…
sanjay-k1910 Oct 7, 2023
8905112
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 7, 2023
1986f49
refactor: passed orgId in ecosystem get request
sanjay-k1910 Oct 9, 2023
bb016d8
refactor: endorsement list api and request schema endorsement api
sanjay-k1910 Oct 10, 2023
fd06cb5
refactor: create endorsement request condition
sanjay-k1910 Oct 10, 2023
11c5f45
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 10, 2023
05245a7
refactor: unused props and schema list
sanjay-k1910 Oct 10, 2023
a5272f8
refactor: check ecosystem function and resolved sonarlint issues
sanjay-k1910 Oct 10, 2023
78acca8
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 10, 2023
896401d
refactor: test deployment
sanjay-k1910 Oct 10, 2023
f2a7b69
refactor: create cred-def payload
sanjay-k1910 Oct 10, 2023
fe01030
Merge branch 'develop' of https://github.com/credebl/studio into feat…
sanjay-k1910 Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 72 additions & 28 deletions src/api/ecosystem.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@

import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests"

import { apiRoutes } from "../config/apiRoutes";
import { getFromLocalStorage } from "./Auth";
import { storageKeys } from "../config/CommonConstant";
import { getHeaderConfigs } from "../config/GetHeaderConfigs";

interface DataPayload {
interface CreateEcosystemPayload {
name: string
description: string
logo: string
tags: string
userId: number
}

export interface GetEndorsementListParameter {
itemPerPage: number,
page: number,
search: string,
sortBy: string,
type: string,
status: string
}


export const createEcosystems = async (dataPayload: DataPayload) => {
export const createEcosystems = async (dataPayload: CreateEcosystemPayload) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);

const url = `${apiRoutes.Ecosystem.root}/${orgId}`
const payload = dataPayload

const token = await getFromLocalStorage(storageKeys.TOKEN)
const config = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
}
const axiosPayload = {
url,
payload,
config
config: await getHeaderConfigs()
}

try {
Expand All @@ -45,17 +48,10 @@ export const updateEcosystem = async (data: object) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Ecosystem.root}/${orgId}`
const payload = data
const token = await getFromLocalStorage(storageKeys.TOKEN)
const config = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
}
const axiosPayload = {
url,
payload,
config
config: await getHeaderConfigs()
}

try {
Expand All @@ -67,19 +63,30 @@ export const updateEcosystem = async (data: object) => {
}
}

export const getEcosystem = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
export const getEcosystem = async (orgId: string) => {
const url = `${apiRoutes.Ecosystem.root}/${orgId}`
const token = await getFromLocalStorage(storageKeys.TOKEN)
const config = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}

const axiosPayload = {
url,
config: await getHeaderConfigs()
}

try {
return await axiosGet(axiosPayload);
}
catch (error) {
const err = error as Error
return err?.message
}
}

export const getEndorsementList = async ({ search, itemPerPage, page, type, status }: GetEndorsementListParameter, ecosystemId: string, orgId: string) => {

const url = `${apiRoutes.Ecosystem.root}/${orgId}/${ecosystemId}${apiRoutes.Ecosystem.endorsements.list}?${page ? `pageNumber=${page}` : ""}${search ? `&search=${search}` : ""}${itemPerPage ? `&pageSize=${itemPerPage}` : ""}${type ? `&type=${type}` : ""}${status ? `&status=${status}` : ""}`

const axiosPayload = {
url,
config
config: await getHeaderConfigs()
}

try {
Expand All @@ -90,3 +97,40 @@ export const getEcosystem = async () => {
return err?.message
}
}

export const createSchemaRequest = async (data: object, endorsementId: string, orgId: number) => {
const url = `${apiRoutes.Ecosystem.root}/${endorsementId}/${orgId}${apiRoutes.Ecosystem.endorsements.createSchemaRequest}`
const payload = data
const axiosPayload = {
url,
payload,
config: await getHeaderConfigs()
}

try {
return await axiosPost(axiosPayload);
}
catch (error) {
const err = error as Error
return err?.message
}
}

export const createCredDefRequest = async (data: object, ecosystemId: string, orgId: number) => {

const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}${apiRoutes.Ecosystem.endorsements.createCredDefRequest}`
const payload = data
const axiosPayload = {
url,
payload,
config: await getHeaderConfigs()
}

try {
return await axiosPost(axiosPayload);
}
catch (error) {
const err = error as Error
return err?.message
}
}
1 change: 0 additions & 1 deletion src/app/LayoutSidebar.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import CopyrightNotice from '../components/CopyrightNotice.astro';
import FooterSidebar from './FooterSidebar.astro';
import LayoutCommon from './LayoutCommon.astro';
import NavBarSidebar from './NavBarSidebar.astro';
import SideBar from './SideBar.astro';
Expand Down
109 changes: 2 additions & 107 deletions src/app/SideBar.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import EcosystemSidebarOption from '../components/Ecosystem/EcosystemSidebarOption';
import { pathRoutes } from '../config/pathRoutes';
/* eslint max-lines: 'off' */
---
Expand Down Expand Up @@ -72,113 +73,7 @@ import { pathRoutes } from '../config/pathRoutes';
<span class="ml-3" sidebar-toggle-item>Dashboard</span>
</a>
</li>

<li>
<button
type="button"
class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
aria-controls="dropdown-ecosystems"
data-collapse-toggle="dropdown-ecosystems"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="flex-shrink-0 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white"
width="18"
height="17"
fill="none"
viewBox="0 0 25 25"
>
<path
fill="currentColor"
d="M23 9.487h-5.27V8.184a.997.997 0 0 0-.999-.999h-1.895v-.818c.872-.685 1.376-1.665 1.376-2.708C16.212 1.64 14.326 0 12.005 0 9.683 0 7.798 1.64 7.798 3.659c0 1.043.504 2.023 1.376 2.708v.818H7.278a.998.998 0 0 0-.999 1v1.302H1a.998.998 0 0 0-.999 1V23A.996.996 0 0 0 1 24h22c.554 0 1-.446 1-1V10.487a1 1 0 0 0-1-.999ZM10.669 4.971c-.549-.318-.877-.808-.877-1.312 0-.901 1.009-1.66 2.209-1.66 1.195 0 2.209.759 2.209 1.66 0 .504-.328.999-.877 1.312a1 1 0 0 0-.5.867V7.18h-1.665V5.838c0-.357-.19-.685-.5-.867ZM8.273 9.184h7.46v2.566h-7.46V9.184Zm13.729 12.818H1.998h14.733L19.5 22l2.497.002h.005Z"
></path></svg
>
<span
class="flex-1 ml-3 text-left whitespace-nowrap"
sidebar-toggle-item>Ecosystem</span
>
<svg
sidebar-toggle-item
class="w-6 h-6 flex-shrink-0 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white sidebar-expand-menu-icon"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
>
</path>
</svg>
</button>
<ul id="dropdown-ecosystems" class="py-2 space-y-2">
<li>
<a
href={pathRoutes.ecosystem.root}
class="flex items-center p-2 text-base text-gray-900 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
fill="none"
viewBox="0 0 25 22"
>
<path
stroke="#6B7280"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1.25"
d="M4 4h3.125M4 6.885h3.125M1 1h15.702M4.695 10h.962m1.453 0h.96m1.422 0h.962m1.452 0h.962M17 1v4.952m0 3.715V13H1V1"
></path>
<path
fill="#6B7280"
d="M14 5.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm-3.816 0a1.316 1.316 0 1 0 2.632 0 1.316 1.316 0 0 0-2.633 0Z"
></path>
<path
stroke="#6B7280"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1.25"
d="M7.164 13.647v1.47h7.53m-6.024.589v2.353h6.526m-4.518.294V21h11.044l3.263-1.177m0 0v-9.705m0 9.705h3.012m-3.012-9.705L23.48 8.353 16.2 6l-1.004.588-.25 1.47.501 1.177 3.263.883.502 1.764 1.004 1.765h1.506m3.263-3.53h3.012"
></path></svg
>
<span class="ml-2">Profile</span>
</a>
</li>
<li>
<a
href={pathRoutes.ecosystem.endorsements}
class="flex items-center p-2 text-base text-gray-900 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
fill="none"
viewBox="0 0 25 25"
>
<path
fill="#6B7280"
d="M19.322 8.824h-4.427V7.612c0-.515-.375-.93-.84-.93h-1.592v-.76a3.335 3.335 0 0 0 1.156-2.52C13.62 1.527 12.035 0 10.085 0 8.135 0 6.55 1.526 6.55 3.403c0 .97.424 1.881 1.157 2.519v.76H6.114c-.465 0-.84.415-.84.93v1.212H.84c-.465 0-.839.414-.839.93v11.638c0 .515.374.93.84.93h12.78l-.993-1.86 7.534-7.962V9.753c0-.51-.374-.93-.84-.93Zm-10.36-4.2c-.461-.296-.737-.752-.737-1.221 0-.838.848-1.544 1.856-1.544 1.004 0 1.855.706 1.855 1.544 0 .47-.275.93-.736 1.22a.952.952 0 0 0-.42.807v1.248H9.381V5.43a.958.958 0 0 0-.42-.806ZM6.948 8.54h6.267v2.141H6.949v-2.14Zm5.678 11.922H1.68v-9.78h16.804l.065 1.37 1.21.447h.403l-7.534 7.963Z"
></path>
<path
fill="#6B7280"
d="M24.997 17.854c0 3.945-2.889 7.143-6.452 7.143s-6.451-3.198-6.451-7.143 2.888-7.143 6.451-7.143c3.563 0 6.452 3.198 6.452 7.143Zm-11.292 0c0 2.96 2.167 5.358 4.84 5.358s4.84-2.399 4.84-5.358c0-2.96-2.167-5.359-4.84-5.359s-4.84 2.4-4.84 5.359Z"
></path>
<path
stroke="#6B7280"
stroke-linecap="round"
stroke-width="1.5"
d="m15.328 17.984 2.24 2.55 4.48-4.464"></path></svg
>
<span class="ml-2">Endorsements</span>
</a>
</li>
</ul>
</li>

<EcosystemSidebarOption client:load />
<li>
<a
href={pathRoutes.organizations.root}
Expand Down
14 changes: 13 additions & 1 deletion src/common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ export enum IssueCredentialUserText {
abandoned = 'Declined'
}

export enum EndorsementType {
schema = 'schema',
credDef = 'credDef'
}

export enum EndorsementStatus {
all = "all",
approved = "approved",
rejected = "rejected",
requested = "requested"
}

export enum EcosystemRoles {
ecosystemMember = "Ecosystem Member",
ecosystemLead = "Ecosystem Lead"
}
}
88 changes: 88 additions & 0 deletions src/commonComponents/ConfirmPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { Button, Modal } from 'flowbite-react';

interface IProps {
openModal: boolean;
closeModal: (flag: boolean) => void;
onSuccess: (flag: boolean) => void;
message: string
isProcessing: boolean
}

const ConfirmModal = (props: IProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please be specific for the model name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a custom confirmation popup and we can use it anywhere in our code.
Can you please suggest a better name?

return (
<Modal show={props.openModal} size="md">
<div className="relative w-full max-w-md max-h-full">
<div className="relative bg-white rounded-lg shadow dark:bg-gray-700">
<button
type="button"
className="absolute top-3 right-2.5 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white"
data-modal-hide="popup-modal"
onClick={() => {
props.closeModal(false)
}}
>
<svg
className="w-3 h-3"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 14 14"
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
/>
</svg>
<span className="sr-only">Close modal</span>
</button>
<div className="p-6 text-center">
<svg
className="mx-auto mb-4 text-yellow-300 w-12 h-12 dark:text-gray-200"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 20 20"
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
/>
</svg>
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">
{props.message}
</h3>
<button
data-modal-hide="popup-modal"
type="button"
className="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600"
onClick={() => {
props.closeModal(false)
}}
>
No, cancel
</button>
<Button
type="submit"
isProcessing={props.isProcessing}
disabled={props.isProcessing}
onClick={() => {
props.onSuccess(true)
}}
className="text-base bg-primary-700 hover:!bg-primary-800 focus:ring-4 focus:outline-none focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800 font-medium rounded-lg text-sm inline-flex items-center text-center ml-2"
>
Yes, I'm sure
</Button>
</div>
</div>
</div>
</Modal>
);
};

export default ConfirmModal;
Loading