Skip to content

Commit

Permalink
show the access level info for datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
zotya committed Nov 21, 2022
1 parent c717d12 commit 217641e
Showing 1 changed file with 62 additions and 14 deletions.
76 changes: 62 additions & 14 deletions src/components/ItemView/Datasets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ import React from 'react';
import { Icon, List, Accordion } from 'semantic-ui-react';

import servicesSVG from './icons/services.svg';
import lockSVG from 'remixicon/icons/System/lock-line.svg';

const is_internal_url = (url) => {
let internal = false;
url.split('/').forEach((part) => {
if (part.split('_')[6] === 'i') {
internal = true;
}
});
return internal;
};

const is_internal = (dataset) => {
let internal = false;
const links = dataset?.link || [];
links.forEach((link) => {
if (is_internal_url(link?.url)) {
internal = true;
}
});
return internal;
};

const SVGIcon = ({ name, size, color, className, title, onClick }) => {
return (
Expand Down Expand Up @@ -51,6 +73,9 @@ const DatasetList = (props) => {
>
<span>{item.name}</span>
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
{item.description && (
Expand Down Expand Up @@ -87,6 +112,9 @@ const DatasetList = (props) => {
Download link
</a>
)}
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
</List.Item>
Expand All @@ -107,6 +135,9 @@ const DatasetList = (props) => {
>
WebDAV: {item.name || item.function}
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
</List.Item>
Expand All @@ -127,6 +158,9 @@ const DatasetList = (props) => {
>
WebDAV: {item.name || item.function}
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
</List.Item>
Expand All @@ -144,13 +178,18 @@ const DatasetList = (props) => {
return (
<List.Item key={i}>
<List.Content>
<SVGIcon name={servicesSVG} size="18" />
{/* {(item.name || item.description) && (
<span className="item-protocol">{item.protocol}:</span>
)} */}
<a className="item-link" href={item.url}>
{item.protocol} {item.name || item.description}
</a>
<div>
<SVGIcon name={servicesSVG} size="18" />
{/* {(item.name || item.description) && (
<span className="item-protocol">{item.protocol}:</span>
)} */}
<a className="item-link" href={item.url}>
{item.protocol} {item.name || item.description}
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
</List.Item>
);
Expand All @@ -160,13 +199,18 @@ const DatasetList = (props) => {
return (
<List.Item key={i}>
<List.Content>
<SVGIcon name={servicesSVG} size="18" />
{/* {(item.name || item.description) && (
<span className="item-protocol">{item.protocol}:</span>
)} */}
<a className="item-link" href={item.url}>
{item.protocol} {item.name || item.description}
</a>
<div>
<SVGIcon name={servicesSVG} size="18" />
{/* {(item.name || item.description) && (
<span className="item-protocol">{item.protocol}:</span>
)} */}
<a className="item-link" href={item.url}>
{item.protocol} {item.name || item.description}
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
</List.Item>
);
Expand All @@ -193,6 +237,9 @@ const DatasetList = (props) => {
>
<span>{item.name || item.url}</span>
</a>
{is_internal_url(item.url) && (
<SVGIcon name={lockSVG} size="18" />
)}
</div>
</List.Content>
{item.description && (
Expand Down Expand Up @@ -259,6 +306,7 @@ const Datasets = (props) => {
);
})}
</span>
{is_internal(dataset) && <SVGIcon name={lockSVG} size="18" />}
</span>
<Icon className="ri-arrow-down-s-line" />
</Accordion.Title>
Expand Down

0 comments on commit 217641e

Please sign in to comment.