Skip to content

Commit

Permalink
Merge branch 'task/digital-rocks' into task/WC-171--DRP-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz committed Feb 18, 2025
2 parents ca57668 + 1a7a491 commit d59cade
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CombinedBreadcrumbs.propTypes = {
path: PropTypes.string.isRequired,
section: PropTypes.string.isRequired,
isPublic: PropTypes.bool,
basePath: PropTypes.string,
className: PropTypes.string,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const BreadcrumbsDropdown = ({
scheme,
system,
path,
basePath,
section,
isPublic,
}) => {
Expand All @@ -36,7 +37,7 @@ const BreadcrumbsDropdown = ({
: null;

const handleNavigation = (targetPath) => {
const basePath = isPublic ? '/public-data' : '/workbench/data';
if (!basePath) basePath = isPublic ? '/public-data' : '/workbench/data';
let url;

if (scheme === 'projects' && targetPath === systemName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DataFilesListing = ({
path,
isPublic,
rootSystem,
basePath,
}) => {
// Redux hooks
const location = useLocation();
Expand All @@ -54,7 +55,7 @@ const DataFilesListing = ({
);
const sharedWorkspaces = systems.find((e) => e.scheme === 'projects');
const isPortalProject = scheme === 'projects';
const hideSearchBar = isPortalProject && sharedWorkspaces.hideSearchBar;
const hideSearchBar = isPortalProject && sharedWorkspaces?.hideSearchBar;

const showViewPath = useSelector(
(state) =>
Expand Down Expand Up @@ -101,6 +102,7 @@ const DataFilesListing = ({
scheme={scheme}
href={row.original._links.self.href}
isPublic={isPublic}
basePath={basePath}
length={row.original.length}
metadata={row.original.metadata}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const FileNavCell = React.memo(
scheme,
href,
isPublic,
basePath,
length,
metadata,
rootSystem,
Expand All @@ -80,7 +81,7 @@ export const FileNavCell = React.memo(
});
};

const basePath = isPublic ? '/public-data' : '/workbench/data';
if (!basePath) basePath = isPublic ? '/public-data' : '/workbench/data';

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ import {
import DataFilesListing from '../DataFilesListing/DataFilesListing';
import styles from './DataFilesProjectFileListing.module.scss';

const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
const DataFilesProjectFileListing = ({
rootSystem,
system,
path,
basePath,
}) => {
const dispatch = useDispatch();
const { fetchListing } = useFileListing('FilesListing');
const { isPublicationSystem, isReviewSystem } = useSystems();
if (!basePath) basePath = '/workbench/data';

// logic to render addonComponents for DRP
const portalName = useSelector((state) => state.workbench.portalName);
Expand Down Expand Up @@ -54,7 +60,7 @@ const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
metadata.members
.filter((member) =>
member.user
? member.user.username === state.authenticatedUser.user.username
? member.user.username === state.authenticatedUser?.user?.username
: { access: null }
)
.map((currentUser) => currentUser.access === 'owner')[0]
Expand Down Expand Up @@ -172,6 +178,7 @@ const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
scheme="projects"
system={system}
path={path || '/'}
basePath={basePath}
rootSystem={rootSystem}
/>
</SectionTableWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import './DataFilesPublicationsList.scss';
import Searchbar from '_common/Searchbar';
import { formatDate, formatDateTimeFromValue } from 'utils/timeFormat';

const DataFilesPublicationsList = ({ rootSystem }) => {
const DataFilesPublicationsList = ({ rootSystem, basePath }) => {
const { error, loading, publications } = useSelector(
(state) => state.publications.listing
);

const _basePath = basePath ?? '/workbench/data';

const query = queryStringParser.parse(useLocation().search);

const systems = useSelector(
Expand All @@ -38,7 +40,7 @@ const DataFilesPublicationsList = ({ rootSystem }) => {
type: 'PUBLICATIONS_GET_PUBLICATIONS',
payload: {
queryString: query.query_string,
system: selectedSystem.system,
system: selectedSystem?.system,
},
});
}, [dispatch, query.query_string]);
Expand All @@ -60,7 +62,7 @@ const DataFilesPublicationsList = ({ rootSystem }) => {
Cell: (el) => (
<Link
className="data-files-nav-link"
to={`/workbench/data/tapis/projects/${rootSystem}/${el.row.original.id}`}
to={`${_basePath}/tapis/projects/${selectedSystem?.system}/${el.row.original.id}`}
>
{el.value}
</Link>
Expand Down Expand Up @@ -141,6 +143,7 @@ const DataFilesPublicationsList = ({ rootSystem }) => {
isLoading={loading}
noDataText={noDataText}
className="publications-listing"
columnMemoProps={[selectedSystem]}
/>
</div>
</SectionTableWrapper>
Expand Down
44 changes: 44 additions & 0 deletions client/src/components/Publications/PublicationDetailPublicView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import CombinedBreadcrumbs from '../DataFiles/CombinedBreadcrumbs/CombinedBreadcrumbs';
import DataFilesPreviewModal from '../DataFiles/DataFilesModals/DataFilesPreviewModal';
import DataFilesProjectCitationModal from '../DataFiles/DataFilesModals/DataFilesProjectCitationModal';
import DataFilesProjectTreeModal from '../DataFiles/DataFilesModals/DataFilesProjectTreeModal';
import DataFilesPublicationAuthorsModal from '../DataFiles/DataFilesModals/DataFilesPublicationAuthorsModal';
import DataFilesShowPathModal from '../DataFiles/DataFilesModals/DataFilesShowPathModal';
import DataFilesViewDataModal from '../DataFiles/DataFilesModals/DataFilesViewDataModal';
import DataFilesProjectFileListing from '../DataFiles/DataFilesProjectFileListing/DataFilesProjectFileListing';

function PublicationDetailPublicView({ params }) {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
padding: '10px',
}}
>
<CombinedBreadcrumbs
api="tapis"
scheme="projects"
system={params.system}
path={params.path || ''}
section="FilesListing"
basePath="/publications"
/>
<DataFilesProjectFileListing
rootSystem={params.root_system}
system={params.system}
path={params.path || '/'}
basePath="/publications"
/>
<DataFilesPreviewModal />
<DataFilesShowPathModal />
<DataFilesProjectTreeModal />
<DataFilesPublicationAuthorsModal />
<DataFilesProjectCitationModal />
<DataFilesViewDataModal />
</div>
);
}

export default PublicationDetailPublicView;
14 changes: 14 additions & 0 deletions client/src/components/Publications/PublicationsPublicView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import DataFilesPublicationsList from '../DataFiles/DataFilesPublicationsList/DataFilesPublicationsList';
import DataFilesProjectDescriptionModal from '../DataFiles/DataFilesModals/DataFilesProjectDescriptionModal';

function PublicationsPublicView() {
return (
<div>
<DataFilesPublicationsList basePath="/publications" />
<DataFilesProjectDescriptionModal />
</div>
);
}

export default PublicationsPublicView
15 changes: 14 additions & 1 deletion client/src/components/Workbench/AppRouter.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useSystems } from 'hooks/datafiles';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom';
import Workbench from './Workbench';
import * as ROUTES from '../../constants/routes';
import TicketStandaloneCreate from '../Tickets/TicketStandaloneCreate';
import PublicData from '../PublicData/PublicData';
import RequestAccess from '../RequestAccess/RequestAccess';
import GoogleDrivePrivacyPolicy from '../ManageAccount/GoogleDrivePrivacyPolicy';
import SiteSearch from '../SiteSearch';
import PublicationsPublicView from '../Publications/PublicationsPublicView';
import PublicationDetailPublicView from '../Publications/PublicationDetailPublicView';


function AppRouter() {
const dispatch = useDispatch();
Expand Down Expand Up @@ -45,6 +48,16 @@ function AppRouter() {
<Route path={ROUTES.WORKBENCH} component={Workbench} />
<Route path="/tickets/new" component={TicketStandaloneCreate} />
<Route path="/public-data" component={PublicData} />
<Route path="/publications" exact component={PublicationsPublicView}/>
<Route path="/publications/tapis/projects/:root_system" exact>
<Redirect to="/publications" />
</Route>
<Route
path={`/publications/tapis/projects/:root_system/:system/:path*`}
render={({ match: { params } }) => {
return <PublicationDetailPublicView params={params}/>;
}}
/>
<Route path="/request-access" component={RequestAccess} />
<Route
path="/googledrive-privacy-policy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DataFilesProjectFileListingAddon = ({ rootSystem, system }) => {
const { canEditDataset, canRequestPublication, canReviewPublication } =
useSelector((state) => {
const { members } = state.projects.metadata;
const { username } = state.authenticatedUser.user;
const { username } = state.authenticatedUser?.user ?? {};
const currentUser = members.find(
(member) => member.user?.username === username
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DataFilesProjectFileListingMetadataTitleAddon = ({
const userAccess = state.projects.metadata.members
.filter((member) =>
member.user
? member.user.username === state.authenticatedUser.user.username
? member.user.username === state.authenticatedUser?.user?.username
: { access: null }
)
.map((currentUser) => {
Expand Down
2 changes: 1 addition & 1 deletion server/conf/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ http {
alias /srv/www/portal/server/docs;
}

location ~ ^/(core|auth|workbench|tickets|googledrive-privacy-policy|public-data|request-access|accounts|api|login|webhooks|search) {
location ~ ^/(core|auth|workbench|tickets|googledrive-privacy-policy|public-data|publications|request-access|accounts|api|login|webhooks|search) {
proxy_pass http://portal_core;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
Expand Down
6 changes: 5 additions & 1 deletion server/portal/apps/datafiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get(self, request):
response['default_host'] = system_def.host
response['default_system'] = system_id
else:
response['system_list'] = [sys for sys in portal_systems if sys['scheme'] == 'public']
response['system_list'] = [sys for sys in portal_systems if sys['scheme'] == 'public' or sys['system'] == settings.PORTAL_PROJECTS_PUBLISHED_ROOT_SYSTEM_NAME]

return JsonResponse(response)

Expand All @@ -71,6 +71,8 @@ def get(self, request, systemId):
public_sys = next((sys for sys in settings.PORTAL_DATAFILES_STORAGE_SYSTEMS if sys['scheme'] == 'public'), None)
if public_sys and public_sys['system'] == systemId:
client = service_account()
if systemId.startswith(settings.PORTAL_PROJECTS_PUBLISHED_SYSTEM_PREFIX):
client = service_account()
else:
return JsonResponse({'message': 'Unauthorized'}, status=401)
system_def = client.systems.getSystem(systemId=systemId)
Expand All @@ -92,6 +94,8 @@ def get(self, request, operation=None, scheme=None, system=None, path='/'):
public_sys = next((sys for sys in settings.PORTAL_DATAFILES_STORAGE_SYSTEMS if sys['scheme'] == 'public'), None)
if public_sys and public_sys['system'] == system and path.startswith(public_sys['homeDir'].strip('/')):
client = service_account()
if system and system.startswith(settings.PORTAL_PROJECTS_PUBLISHED_SYSTEM_PREFIX):
client = service_account()
else:
return JsonResponse(
{'message': 'This data requires authentication to view.'},
Expand Down
9 changes: 6 additions & 3 deletions server/portal/apps/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.conf import settings
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from portal.libs.agave.utils import service_account
from portal.utils.decorators import agave_jwt_login
from portal.exceptions.api import ApiException
from portal.views.base import BaseApiView
Expand Down Expand Up @@ -157,7 +158,6 @@ def post(self, request): # pylint: disable=no-self-use


@method_decorator(agave_jwt_login, name='dispatch')
@method_decorator(login_required, name='dispatch')
class ProjectInstanceApiView(BaseApiView):
"""Project Instance API view.
Expand All @@ -178,8 +178,11 @@ def get(self, request, project_id=None, system_id=None):
# Based on url mapping, either system_id or project_id is always available.
if system_id is not None:
project_id = system_id.split(f"{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.")[1]

client = request.user.tapis_oauth.client

if system_id and system_id.startswith(settings.PORTAL_PROJECTS_PUBLISHED_SYSTEM_PREFIX):
client = service_account()
else:
client = request.user.tapis_oauth.client

prj = get_project(client, project_id)

Expand Down
Loading

0 comments on commit d59cade

Please sign in to comment.