Skip to content

Commit

Permalink
Merge pull request #242 from codeforpdx/Development
Browse files Browse the repository at this point in the history
Merging [Hotfix] Fixes for Master v0.0.5 from Development v0.0.5.1 into Master.
  • Loading branch information
leekahung authored Jun 10, 2023
2 parents a2c2bf4 + b957514 commit 4305355
Show file tree
Hide file tree
Showing 30 changed files with 264 additions and 220 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pass",
"homepage": ".",
"version": "0.0.5",
"version": "0.0.5.1",
"description": "",
"scripts": {
"dev": "vite",
Expand Down
9 changes: 5 additions & 4 deletions src/components/Clients/AddClient.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import React, { useContext, useState } from 'react';
// Inrupt Library Imports
import { useSession } from '@inrupt/solid-ui-react';
// Utility Imports
import { runNotification, SOLID_IDENTITY_PROVIDER } from '../../utils';
import { runNotification } from '../../utils';
import { createUser } from '../../model-helpers/User';
// Custom Hook Imports
import { useStatusNotification, useField } from '../../hooks';
// Context Imports
import { UserListContext } from '../../contexts';
// Constants Imports
import { currentOidcIssuer } from '../../constants';
// Component Imports
import FormSection from '../Form/FormSection';

Expand All @@ -21,7 +23,7 @@ import FormSection from '../Form/FormSection';
*/

const renderWebId = (username) => {
const oidcProvider = SOLID_IDENTITY_PROVIDER.split('//')[1];
const oidcProvider = currentOidcIssuer.split('//')[1];
const template = ['https://', `.${oidcProvider}profile/card#me`];
return `${template[0]}${username}${template[1]}`;
};
Expand Down Expand Up @@ -145,8 +147,7 @@ const AddClient = () => {
<br />
<div>
<label htmlFor="add-username">
Add username to client list (i.e., username without{' '}
{SOLID_IDENTITY_PROVIDER.split('/')[2]}):{' '}
Add username to client list (i.e., username without {currentOidcIssuer.split('/')[2]}):{' '}
</label>
<br />
<br />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Clients/ClientList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ClientListTable from './ClientListTable';
const ClientList = () => {
const { userListObject } = useContext(UserListContext);

return userListObject.userList.length ? (
return userListObject.userList?.length ? (
// render if clients
<ClientListTable statusType="Status" defaultMessage="No actions" />
) : (
Expand Down
10 changes: 4 additions & 6 deletions src/components/Form/CheckAclPermsDocContainerForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import Button from '@mui/material/Button';
import FormControl from '@mui/material/FormControl';
import TextField from '@mui/material/TextField';
// Utility Imports
import { SOLID_IDENTITY_PROVIDER, checkContainerPermission, runNotification } from '../../utils';
import { checkContainerPermission, runNotification, getPodUrl } from '../../utils';
// Custom Hook Imports
import { useField, useStatusNotification } from '../../hooks';
// Context Imports
import { SelectUserContext } from '../../contexts';
import { SelectUserContext, SignedInUserContext } from '../../contexts';
// Component Imports
import FormSection from './FormSection';

Expand All @@ -30,6 +30,7 @@ const CheckAclPermsDocContainerForm = () => {
const { state, dispatch } = useStatusNotification();
const { clearValue: clearUrl, ...user } = useField('text');
const { selectedUser, setSelectedUser } = useContext(SelectUserContext);
const { podUrl } = useContext(SignedInUserContext);

const clearInputFields = () => {
clearUrl();
Expand Down Expand Up @@ -61,10 +62,7 @@ const CheckAclPermsDocContainerForm = () => {
return;
}

if (
`https://${podUsername}.${SOLID_IDENTITY_PROVIDER.split('/')[2]}/` ===
String(session.info.webId.split('profile')[0])
) {
if (getPodUrl(podUsername) === podUrl) {
runNotification(
'Check permissions failed. Reason: User already has access to their own Documents container.',
5,
Expand Down
8 changes: 8 additions & 0 deletions src/components/Form/CrossPodQueryForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ const CrossPodQueryForm = () => {
return;
}

if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

try {
const documentUrl = await getDocuments(
session,
Expand Down
9 changes: 9 additions & 0 deletions src/components/Form/CrossPodWriteForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const CrossPodWriteForm = () => {
session,
clearInputFields
);

// Event handler for form/document submission to Pod
const handleCrossPodUpload = async (event) => {
event.preventDefault();
Expand All @@ -75,6 +76,14 @@ const CrossPodWriteForm = () => {
return;
}

if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

handleFormSubmit(event, podUsername);
};

Expand Down
22 changes: 12 additions & 10 deletions src/components/Form/DeleteDocumentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSession } from '@inrupt/solid-ui-react';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
// Utility Imports
import { deleteDocumentFile, deleteDocumentContainer, runNotification } from '../../utils';
import { deleteDocumentFile, runNotification } from '../../utils';
// Custom Hook Imports
import { useStatusNotification } from '../../hooks';
// Component Imports
Expand Down Expand Up @@ -35,19 +35,21 @@ const DeleteDocumentForm = () => {
event.preventDefault();
dispatch({ type: 'SET_PROCESSING' });

if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

try {
const documentUrl = await deleteDocumentFile(session, docType);
await deleteDocumentFile(session, docType);

runNotification('File being deleted from Pod...', 3, state, dispatch);
runNotification('File being deleted from Pod...', 5, state, dispatch);

// Solid requires all files to be removed from container before it can be
// removed setTimeout lets deleteDocumentFile finish removing the files
setTimeout(() => {
deleteDocumentContainer(session, documentUrl);
runNotification('Removing file container from Pod...', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
} catch (_error) {
runNotification('Deletion failed. Reason: Data not found.', 5, state, dispatch);
Expand Down
8 changes: 8 additions & 0 deletions src/components/Form/FetchDocumentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const FetchDocumentForm = () => {
event.preventDefault();
dispatch({ type: 'SET_PROCESSING' });

if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

try {
const documentUrl = await getDocuments(session, docType, INTERACTION_TYPES.SELF);

Expand Down
18 changes: 12 additions & 6 deletions src/components/Form/SetAclPermissionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import RadioGroup from '@mui/material/RadioGroup';
import TextField from '@mui/material/TextField';
import Typography from '@mui/material/Typography';
// Utility Imports
import { SOLID_IDENTITY_PROVIDER, runNotification, setDocAclPermission } from '../../utils';
import { getPodUrl, runNotification, setDocAclPermission } from '../../utils';
// Custom Hook Imports
import { useField, useStatusNotification } from '../../hooks';
// Context Imports
import { SelectUserContext } from '../../contexts';
import { SelectUserContext, SignedInUserContext } from '../../contexts';
// Component Imports
import DocumentSelection from './DocumentSelection';
import FormSection from './FormSection';
Expand All @@ -35,6 +35,7 @@ const SetAclPermissionForm = () => {
const { state, dispatch } = useStatusNotification();
const { clearValue: clearUsername, ...username } = useField('text');
const { selectedUser, setSelectedUser } = useContext(SelectUserContext);
const { podUrl } = useContext(SignedInUserContext);
const [docType, setDocType] = useState('');

const handleDocType = (event) => {
Expand Down Expand Up @@ -68,10 +69,7 @@ const SetAclPermissionForm = () => {
return;
}

if (
`https://${podUsername}.${SOLID_IDENTITY_PROVIDER.split('/')[2]}/` ===
String(session.info.webId.split('profile')[0])
) {
if (getPodUrl(podUsername) === podUrl) {
runNotification(
'Set permissions failed. Reason: Current user Pod cannot change container permissions to itself.',
5,
Expand All @@ -92,6 +90,14 @@ const SetAclPermissionForm = () => {
return;
}

if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

try {
await setDocAclPermission(session, docType, permissions, podUsername);

Expand Down
14 changes: 4 additions & 10 deletions src/components/Form/SetAclPermsDocContainerForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ import RadioGroup from '@mui/material/RadioGroup';
import TextField from '@mui/material/TextField';
import Typography from '@mui/material/Typography';
// Utility Imports
import {
SOLID_IDENTITY_PROVIDER,
runNotification,
setDocContainerAclPermission
} from '../../utils';
import { getPodUrl, runNotification, setDocContainerAclPermission } from '../../utils';
// Custom Hook Imports
import { useField, useStatusNotification } from '../../hooks';
// Context Imports
import { SelectUserContext } from '../../contexts';
import { SelectUserContext, SignedInUserContext } from '../../contexts';
// Component Imports
import FormSection from './FormSection';

Expand All @@ -39,6 +35,7 @@ const SetAclPermsDocContainerForm = () => {
const { state, dispatch } = useStatusNotification();
const { clearValue: clearUsername, ...username } = useField('text');
const { selectedUser, setSelectedUser } = useContext(SelectUserContext);
const { podUrl } = useContext(SignedInUserContext);

const clearInputFields = () => {
clearUsername();
Expand Down Expand Up @@ -71,10 +68,7 @@ const SetAclPermsDocContainerForm = () => {
return;
}

if (
`https://${podUsername}.${SOLID_IDENTITY_PROVIDER.split('/')[2]}/` ===
String(session.info.webId.split('profile')[0])
) {
if (getPodUrl(podUsername) === podUrl) {
runNotification(
'Set permissions failed. Reason: Current user Pod cannot change container permissions to itself.',
5,
Expand Down
18 changes: 15 additions & 3 deletions src/components/Form/UploadDocumentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState } from 'react';
// Inrupt Library Imports
import { useSession } from '@inrupt/solid-ui-react';
// Utility Imports
import { makeHandleFormSubmission } from '../../utils';
import { makeHandleFormSubmission, runNotification } from '../../utils';
// Custom Hook Imports
import { useField, useStatusNotification } from '../../hooks';
// Constants Imports
Expand Down Expand Up @@ -50,14 +50,26 @@ const UploadDocumentForm = () => {
};

// Event handler for form/document submission to Pod
const handleFormSubmission = makeHandleFormSubmission(
const handleFormSubmit = makeHandleFormSubmission(
INTERACTION_TYPES.SELF,
state,
dispatch,
session,
clearInputFields
);

const handleDocumentUpload = async (event) => {
if (!docType) {
runNotification('Search failed. Reason: No document type selected.', 5, state, dispatch);
setTimeout(() => {
dispatch({ type: 'CLEAR_PROCESSING' });
}, 3000);
return;
}

handleFormSubmit(event);
};

const formRowStyle = {
margin: '20px 0'
};
Expand All @@ -69,7 +81,7 @@ const UploadDocumentForm = () => {
statusType="Upload status"
defaultMessage="To be uploaded..."
>
<form onSubmit={handleFormSubmission} autoComplete="off">
<form onSubmit={handleDocumentUpload} autoComplete="off">
<label htmlFor="verify-checkbox">
Verify File on upload:
<input
Expand Down
5 changes: 2 additions & 3 deletions src/components/Messages/NewMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styled from 'styled-components';
// Utility Imports
import { sendMessageTTL, getMessageTTL } from '../../utils';
// Context Imports
import { MessageContext } from '../../contexts';
import { MessageContext, SignedInUserContext } from '../../contexts';

/**
* New Message Component - Component that allows user to write
Expand All @@ -20,6 +20,7 @@ import { MessageContext } from '../../contexts';
const NewMessage = ({ closeForm }) => {
const { session } = useSession();
const { outboxList, setOutboxList } = useContext(MessageContext);
const { podUrl } = useContext(SignedInUserContext);

const [message, setMessage] = useState({
recipientUsername: '',
Expand All @@ -30,8 +31,6 @@ const NewMessage = ({ closeForm }) => {
const [success, setSuccess] = useState('');
const [successTimeout, setSuccessTimeout] = useState(false);

const podUrl = session.info.webId.split('profile')[0];

// Modifies message upon input
const handleChange = (e) => {
setMessage({
Expand Down
4 changes: 2 additions & 2 deletions src/components/NavBar/OidcLoginComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import React, { useState } from 'react';
import { LoginButton } from '@inrupt/solid-ui-react';
// Material UI Imports
import { TextField, Box, Button } from '@mui/material';
// Utility Imports
import { SOLID_IDENTITY_PROVIDER } from '../../utils';
// Custom Hook Imports
import { useRedirectUrl } from '../../hooks';
// Constants Imports
import { SOLID_IDENTITY_PROVIDER } from '../../constants';

const OidcLoginComponent = () => {
const [oidcIssuer, setOidcIssuer] = useState(SOLID_IDENTITY_PROVIDER);
Expand Down
3 changes: 2 additions & 1 deletion src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import RDF_PREDICATES from './rdf_predicates';
import INTERACTION_TYPES from './interaction_types';
import { SOLID_IDENTITY_PROVIDER, currentOidcIssuer } from './solid_provider';

export { RDF_PREDICATES, INTERACTION_TYPES };
export { RDF_PREDICATES, INTERACTION_TYPES, SOLID_IDENTITY_PROVIDER, currentOidcIssuer };
Loading

0 comments on commit 4305355

Please sign in to comment.