Skip to content

Commit

Permalink
Merge pull request #655 from credebl/merge/dev-to-qa
Browse files Browse the repository at this point in the history
merge: develop to qa
  • Loading branch information
bhavanakarwade authored Apr 11, 2024
2 parents 337c1d6 + b90bfb5 commit d5163f5
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 65 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ ui.env

# misc.
.dev*

# hidden files
._darcs
.bzr
.hg
BitKeeper
1 change: 1 addition & 0 deletions src/components/Authentication/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const ResetPassword = () => {
className="mt-12 space-y-6"
onSubmit={formikHandlers.handleSubmit}
>
<input type="hidden" name="_csrf" value={new Date().getTime()} />
<div>
<div className="text-primary-700 font-inter text-base font-medium leading-5">
<div className="block mb-2 text-sm font-medium dark:text-white">
Expand Down
1 change: 1 addition & 0 deletions src/components/Authentication/SignUpUserPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const SignUpUserPassword = ({
className="mt-12 space-y-6"
onSubmit={formikHandlers.handleSubmit}
>
<input type="hidden" name="_csrf" value={new Date().getTime()} />
<div>
<div className="text-primary-700 font-inter text-base font-medium leading-5">
<div className="block mb-2 text-sm font-medium dark:text-white">
Expand Down
2 changes: 1 addition & 1 deletion src/components/BreadCrumbs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function BreadCrumbs() {
: '';
return (
<Breadcrumb.Item className='mb-0' href={crumb.href} key={crumb.text}>
{routes}
{decodeURIComponent(routes)}
</Breadcrumb.Item>
);
})}
Expand Down
49 changes: 22 additions & 27 deletions src/components/CreateEcosystemOrgModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createEcosystems } from '../../api/ecosystem';
import { getOrgDetails } from '../../config/ecosystem';
import defaultUserIcon from '../../../public/images/person_FILL1_wght400_GRAD0_opsz24.svg';
import EndorsementTooltip from '../../commonComponents/EndorsementTooltip';
import { processImage } from '../../utils/processImage';
interface Values {
name: string;
description: string;
Expand Down Expand Up @@ -126,29 +127,20 @@ const CreateEcosystemOrgModal = (props: IProps) => {
const isEmpty = (object: any): boolean => {
return true;
};

const handleImageChange = (event: any): void => {
setImgError('');
const reader = new FileReader();
const file = event?.target?.files;

const imgfieSize = Number((file[0]?.size / 1024 / 1024)?.toFixed(2));
const extension = file[0]?.name
?.substring(file[0]?.name?.lastIndexOf('.') + 1)
?.toLowerCase();
if (extension === 'png' || extension === 'jpeg' || extension === 'jpg') {
if (imgfieSize <= imageSizeAccepted) {
reader.onloadend = (): void => {
ProcessImg(event);
isEmpty(reader.result);
};
reader.readAsDataURL(file[0]);
event.preventDefault();
processImage(event, (result, error) => {
if (result) {
setLogoImage({
logoFile: '',
imagePreviewUrl: result,
fileName: event.target.files[0].name,
});
} else {
setImgError('Please check image size');
setImgError(error || 'An error occurred while processing the image.');
}
} else {
setImgError('Invalid image type');
}
});
};

const submitCreateOrganization = async (values: Values) => {
Expand All @@ -170,6 +162,8 @@ const CreateEcosystemOrgModal = (props: IProps) => {
props.setMessage(data?.message);
}
props.setOpenModal(false);
window.location.href = '/organizations';

} else {
setErrMsg(resCreateOrg as string);
}
Expand Down Expand Up @@ -299,20 +293,21 @@ const CreateEcosystemOrgModal = (props: IProps) => {
>
<div className="mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-2 dark:bg-gray-800">
<div className="flex flex-col items-center sm:flex-row 2xl:flex-row p-2 gap-0 sm:gap-4">
{typeof logoImage.logoFile === 'string' ? (
{logoImage?.imagePreviewUrl ? (
<img
className="mb-4 rounded-lg w-28 h-28 sm:mb-0 xl:mb-4 2xl:mb-0"
src={logoImage?.imagePreviewUrl || ""}
alt={logoImage.fileName}
/>
) : typeof logoImage.logoFile === 'string' ? (
<Avatar size="lg" img={defaultUserIcon} />
) : (
<img
className="m-2 rounded-md w-28 h-28"
src={
typeof logoImage.logoFile === 'string'
? asset('images/users/bonnie-green-2x.png')
: URL.createObjectURL(logoImage.logoFile)
}
alt="Jese picture"
src={URL.createObjectURL(logoImage?.logoFile)}
alt={logoImage.fileName}
/>
)}

<div>
<h3 className="flex items-center justify-center sm:justify-start mb-1 text-xl font-bold text-gray-900 dark:text-white">
{popupName} Logo
Expand Down
2 changes: 1 addition & 1 deletion src/components/Issuance/CredDefSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const CredDefSelection = () => {
<Button
id="createSchemaButton"
onClick={() => {
window.location.href = `${pathRoutes.organizations.viewSchema}?schemaId=${schemaDetailsState?.schemaId}`;
window.location.href = `${pathRoutes.organizations.viewSchema}/${encodeURIComponent(schemaDetailsState?.schemaId)}`;
}}
className="ml-auto text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:!bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"
title="Create new credential-definition"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Resources/Schema/Schemas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SchemaList from "./SchemasList"
const Schemas = () => {
const schemaSelectionCallback = async (schemaId: string, attributes:any) => {
await setToLocalStorage(storageKeys.SCHEMA_ATTR, attributes)
window.location.href = `${pathRoutes.organizations.viewSchema}?schemaId=${schemaId}`
window.location.href = `${pathRoutes.organizations.viewSchema}/${encodeURIComponent(schemaId)}`
}
return (
<SchemaList schemaSelectionCallback={schemaSelectionCallback} />
Expand Down
11 changes: 5 additions & 6 deletions src/components/Resources/Schema/ViewSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const initialPageState = {
total: 0,
};

const ViewSchemas = () => {
const ViewSchemas = ({ schemaId }: { schemaId: string }) => {
const [schemaDetails, setSchemaDetails] = useState<SchemaData | null>(null);
const [credDeffList, setCredDeffList] = useState<any>([]);
const [loading, setLoading] = useState<boolean>(true);
Expand Down Expand Up @@ -137,11 +137,10 @@ const ViewSchemas = () => {
await checkEcosystemData();
const organizationId = await getFromLocalStorage(storageKeys.ORG_ID);
setOrgId(String(organizationId));
if (window?.location?.search) {
const str = window?.location?.search;
const schemaId = str.substring(str.indexOf('=') + 1);
await getSchemaDetails(schemaId, String(organizationId));
await getCredentialDefinitionList(schemaId, String(organizationId));
const id = encodeURIComponent(schemaId);
if (id) {
await getSchemaDetails(id, String(organizationId));
await getCredentialDefinitionList(id, String(organizationId));
}
};

Expand Down
12 changes: 7 additions & 5 deletions src/components/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ const Index = () => {
)}
<div className="w-full mx-auto bg-white border border-gray-200 rounded-lg dark:bg-gray-800 dark:border-gray-700">
<div className="px-6 py-6">
{loading ? (
{loading && (
<div className="flex items-center justify-center mb-4">
<CustomSpinner />
</div>
) : !loading && orgnizationId ? (
) }
{!loading && orgnizationId && (
<>
{' '}
<form action="#">
Expand Down Expand Up @@ -153,8 +154,7 @@ const Index = () => {
</span>
</div>

{(userRoles.includes(Roles.OWNER) ||
userRoles.includes(Roles.ADMIN)) && (
{(userRoles.includes(Roles.OWNER)) && (
<div className="text-start items-center mt-4 sm:mt-0 shrink-0">
{buttonDisplay && (
<Button
Expand Down Expand Up @@ -232,7 +232,9 @@ const Index = () => {
</div>
</form>{' '}
</>
) : (
) }

{!loading && !orgnizationId && (
<EmptyListMessage
message={'No Organization'}
description={'Get started by creating a new Organization'}
Expand Down
34 changes: 17 additions & 17 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ const UserDashBoard = () => {
}, [organizationsList]);

const goToOrgDashboard = async (orgId: string, rogRoles: string[], org: Organisation | null) => {
const {id, name, description, logoUrl, roles} = org || {};
const orgInfo = {id, name, description, logoUrl, roles}
const { id, name, description, logoUrl, roles } = org || {};
const orgInfo = { id, name, description, logoUrl, roles }
await setToLocalStorage(storageKeys.ORG_INFO, orgInfo);
await setToLocalStorage(storageKeys.ORG_ID, orgId);
window.location.href = pathRoutes.organizations.dashboard;
Expand All @@ -358,18 +358,16 @@ const UserDashBoard = () => {
const goToSchemaCredDef = async (schemaId: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
await setToLocalStorage(storageKeys.ORG_ID, orgId);
const url = `${
pathRoutes.organizations.viewSchema
}?schemaId=${encodeURIComponent(schemaId)}`;
const url = `${pathRoutes.organizations.viewSchema
}/${encodeURIComponent(schemaId)}`;
window.location.href = url;
};

const goToCredDef = async (credentialDefinitionId: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
await setToLocalStorage(storageKeys.ORG_ID, orgId);
const url = `${
pathRoutes.organizations.viewSchema
}?schemaId=${encodeURIComponent(credentialDefinitionId)}`;
const url = `${pathRoutes.organizations.viewSchema
}/${encodeURIComponent(credentialDefinitionId)}`;
window.location.href = url;
};

Expand All @@ -378,6 +376,12 @@ const UserDashBoard = () => {
const roles: string[] = org?.userOrgRoles.map((role) => role.orgRole.name);

await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString());

const { id, name, description, logoUrl } = org || {};
const orgInfo = {
id, name, description, logoUrl, roles
}
await setToLocalStorage(storageKeys.ORG_INFO, orgInfo);
};

const goToEcoDashboard = async (ecosystemId: string) => {
Expand All @@ -390,8 +394,7 @@ const UserDashBoard = () => {
orgId: string,
rogRoles: string[],
) => {
await setToLocalStorage(storageKeys.ORG_ID, orgId);
setOrgRoleDetails(org);
await setOrgRoleDetails(org);
window.location.href = pathRoutes.organizations.createSchema;
};

Expand All @@ -400,8 +403,7 @@ const UserDashBoard = () => {
orgId: string,
rogRoles: string[],
) => {
await setToLocalStorage(storageKeys.ORG_ID, orgId);
setOrgRoleDetails(org);
await setOrgRoleDetails(org);
window.location.href = pathRoutes.organizations.schemas;
};

Expand All @@ -410,8 +412,7 @@ const UserDashBoard = () => {
orgId: string,
rogRoles: string[],
) => {
await setToLocalStorage(storageKeys.ORG_ID, orgId);
setOrgRoleDetails(org);
await setOrgRoleDetails(org);
window.location.href = pathRoutes.organizations.issuedCredentials;
};

Expand All @@ -420,8 +421,7 @@ const UserDashBoard = () => {
orgId: string,
rogRoles: string[],
) => {
await setToLocalStorage(storageKeys.ORG_ID, orgId);
setOrgRoleDetails(org);
await setOrgRoleDetails(org);
window.location.href = pathRoutes.organizations.credentials;
};

Expand Down Expand Up @@ -604,7 +604,7 @@ const UserDashBoard = () => {
<div className="flex justify-between pb-2 flex text-center">
<div className="flex text-center justify-center items-center">
<h2 className="text-xl font-semibold text-gray-900 dark:text-white items-center">
Organizations{' '}
Organizations
</h2>
<Tooltip
content={<ToolTipDataForOrganization />}
Expand Down
7 changes: 0 additions & 7 deletions src/pages/organizations/schemas/view-schema.astro

This file was deleted.

9 changes: 9 additions & 0 deletions src/pages/organizations/schemas/view-schema/[schemaId].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
import LayoutSidebar from '../../../../app/LayoutSidebar.astro';
import ViewSchemas from '../../../../components/Resources/Schema/ViewSchema'
const schemaId = Astro.params.schemaId;
---
<LayoutSidebar>
<ViewSchemas schemaId={schemaId || ""} client:load/>
</LayoutSidebar>

0 comments on commit d5163f5

Please sign in to comment.