Skip to content

Commit

Permalink
Fixup users
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Sep 3, 2023
1 parent 6d8d509 commit d035521
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 250 deletions.
17 changes: 14 additions & 3 deletions foursight_core/react/api/react_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def _get_redis_server_version(self) -> Optional[str]:

@function_cache
def _get_user_attribution(self, type: str, env: str, raw: bool = False,
map_title: Optional[Callable] = None,
additional_info: Optional[Callable] = None) -> list:
"""
Returns the list of available user projects.
Expand All @@ -175,7 +176,7 @@ def _get_user_attribution(self, type: str, env: str, raw: bool = False,
"id": item.get("@id"),
"uuid": item.get("uuid"),
"name": item.get("name"),
"title": item.get("title"),
"title": item.get("title") if not map_title else map_title(item.get("title")),
"description": item.get("description")
}
if additional_info:
Expand Down Expand Up @@ -208,11 +209,21 @@ def _get_user_labs(self, env: str, raw: bool = False) -> list:

@function_cache
def _get_user_consortia(self, env: str, raw: bool = False) -> list:
return self._get_user_attribution("Consortium", env, raw)
def map_title(title: str) -> str:
suffix_to_ignore = " Consortium"
if title.endswith(suffix_to_ignore):
title = title[:-len(suffix_to_ignore)]
return title
return self._get_user_attribution("Consortium", env, raw, map_title=map_title)

@function_cache
def _get_user_submission_centers(self, env: str, raw: bool = False) -> list:
return self._get_user_attribution("SubmissionCenter", env, raw)
def map_title(title: str) -> str:
suffix_to_ignore = " Submission Center"
if title.endswith(suffix_to_ignore):
title = title[:-len(suffix_to_ignore)]
return title
return self._get_user_attribution("SubmissionCenter", env, raw, map_title=map_title)

@function_cache
def _get_user_roles(self, env: str) -> list:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "foursight-core"
version = "4.4.0.1b13" # TODO: To become 4.5.0
version = "4.4.0.1b14" # TODO: To become 4.5.0
description = "Serverless Chalice Application for Monitoring"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
56 changes: 0 additions & 56 deletions react/src/hooks/UserMetadata.js

This file was deleted.

7 changes: 4 additions & 3 deletions react/src/pages/AccountsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,15 @@ const AccountInfoLeft = ({ header, info, foursightUrl }) => {
</> }
</Row>
<Row title="S3 Encryption" value={info.get("foursight.s3.has_encryption") ? "Yes" : "No"} showEmpty={true}
tooltip={[`This is controlled by the S3_ENCRYPT_KEY environment variable.`, `tooltip-has-encryption}`]} showEmpty={true}>
tooltip={[`Controlled by the S3_ENCRYPT_KEY environment variable.`, `tooltip-has-encryption}`]} showEmpty={true}>
</Row>
<Row title="S3 Encryption ID" value={info.get("foursight.s3.encrypt_key_id")}
externalLink={`https://us-east-1.console.aws.amazon.com/kms/home?region=us-east-1#/kms/keys/${info.get("foursight.s3.encrypt_key_id")}`}
tooltip={[`S3 Bucket Encryption Key ID`, `tooltip-encryption-key-${info.get("foursight.aws_account_number")}`]} showEmpty={true}>
tooltip={[`S3 encryption key ID from the ENCODED_S3_ENCRYPT_KEY_ID environment variable.`,
`tooltip-encryption-key-${info.get("foursight.aws_account_number")}`]} showEmpty={true}>
</Row>
<Row title="S3 Access Key" value={info.get("foursight.s3.access_key")}
tooltip={[`This is from the S3_AWS_ACCESS_KEY_ID environment variable.`,
tooltip={[`From the S3_AWS_ACCESS_KEY_ID environment variable.`,
`tooltip-s3-aws-access-key-id${info.get("foursight.s3.access_key")}`]}>
&nbsp;
{ info.get("foursight.s3.access_key_error") ? <>
Expand Down
5 changes: 5 additions & 0 deletions react/src/pages/EditBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import Uuid from 'react-uuid';
// Generic box to edit (create, update, delete) a list of plain input fields representing some data record.
// If the onCreate argument is specified then assume this is a create.

const useConsortia = () => {
const consortia = useFetch("/users/consortia", { nofetch: true, cache: true, onData: (data) => {return data;} });
return consortia;
}

const DynamicSelect = (props) => {

const values = useFetch(props.url, { nofetch: true, cache: true });
Expand Down
9 changes: 0 additions & 9 deletions react/src/pages/UserCreatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ const UserCreatePage = () => {

const navigate = useNavigate();

useEffect(() => {
const institutionInput = inputs.find(input => input.name === "institution");
if (institutionInput) {
institutionInput.subComponent =
(institution) =>
<UserDefs.PrincipalInvestigatorLine institution={institution} />
}
}, []);

function onCreate(values) {
if (values.admin) {
delete values["admin"]
Expand Down
Loading

0 comments on commit d035521

Please sign in to comment.