Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object creation caltech replay #391

Merged
merged 12 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pm_to_blib
release-archives/
target/
.cpcache/
.classpath
.factorypath

# Elastic Beanstalk Files
.ebextensions/app-env.config
Expand Down Expand Up @@ -53,5 +55,11 @@ data/
# Source code linter cache
/.clj-kondo/.cache/

# IDE project/module settings
.vscode
.project
.settings

# VS Code calva extension configs
.calva
.lsp
64 changes: 54 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ifeq ($(PROJ_NAME), wormbase-names)
else ifeq ($(PROJ_NAME), wormbase-names-test)
WB_DB_URI ?= "datomic:ddb://${AWS_DEFAULT_REGION}/WSNames-test-14/wormbase"
GOOGLE_REDIRECT_URI ?= "https://test-names.wormbase.org"
APP_PROFILE ?= "prod"
APP_PROFILE ?= "test"
else
WB_DB_URI ?= "datomic:ddb-local://localhost:8000/WBNames_local/wormbase"
# Ensure GOOGLE_REDIRECT_URI is defined appropriately as an env variable or CLI argument
Expand Down Expand Up @@ -170,7 +170,7 @@ docker-tag: ENV.VERSION_TAG \
@docker tag ${ECR_REPO_NAME}:${VERSION_TAG} ${ECR_REPO_URI}

.PHONY: eb-def-app-env
eb-def-app-env: google-oauth2-secrets ENV.VERSION_TAG \
eb-def-app-env: google-oauth2-secrets caltech-api-secrets ENV.VERSION_TAG \
$(call print-help,eb-def-app-env \
[WB_DB_URI=<datomic-db-uri>] [GOOGLE_REDIRECT_URI=<google-redirect-uri>],\
Define the ElasticBeanStalk app-environment config file.)
Expand All @@ -185,6 +185,9 @@ endif
sed -i -r 's~(API_GOOGLE_OAUTH_CLIENT_ID:\s+)".*"~\1"'"${GOOGLE_OAUTH_CLIENT_ID}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(API_GOOGLE_OAUTH_CLIENT_SECRET:\s+)".*"~\1"'"${GOOGLE_OAUTH_CLIENT_SECRET}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(GOOGLE_REDIRECT_URI:\s+)".*"~\1"'"${GOOGLE_REDIRECT_URI}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(CALTECH_API_URL:\s+)".*"~\1"'"${CALTECH_API_URL}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(CALTECH_API_USER:\s+)".*"~\1"'"${CALTECH_API_USER}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(CALTECH_API_PASSWORD:\s+)".*"~\1"'"${CALTECH_API_PASSWORD}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i -r 's~(WB_NAMES_RELEASE: ).+~\1'${VERSION_TAG}'~' .ebextensions/${EB_APP_ENV_FILE}

.PHONY: eb-create
Expand Down Expand Up @@ -306,24 +309,30 @@ release: ENV.VERSION_TAG deploy-ecr \
Release the applicaton.)

.PHONY: run-tests
run-tests: google-oauth2-secrets \
run-tests: google-oauth2-secrets caltech-api-secrets \
$(call print-help,run-tests,\
Run all tests.)
@ export API_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
export API_GOOGLE_OAUTH_CLIENT_SECRET=${GOOGLE_OAUTH_CLIENT_SECRET} && \
export GOOGLE_REDIRECT_URI=${LOCAL_GOOGLE_REDIRECT_URI} && \
@ export API_GOOGLE_OAUTH_CLIENT_ID="${GOOGLE_OAUTH_CLIENT_ID}" && \
export API_GOOGLE_OAUTH_CLIENT_SECRET="${GOOGLE_OAUTH_CLIENT_SECRET}" && \
export CALTECH_API_URL="${CALTECH_API_URL}" && \
export CALTECH_API_USER="${CALTECH_API_USER}" && \
export CALTECH_API_PASSWORD="${CALTECH_API_PASSWORD}" && \
export GOOGLE_REDIRECT_URI="${LOCAL_GOOGLE_REDIRECT_URI}" && \
clojure -A:datomic-pro:logging:webassets:dev:test:run-tests

.PHONY: run-dev-webserver
run-dev-webserver: PORT := 4010
run-dev-webserver: google-oauth2-secrets \
run-dev-webserver: google-oauth2-secrets caltech-api-secrets \
$(call print-help,run-dev-webserver PORT=<port> WB_DB_URI=<datomic-uri> \
GOOGLE_REDIRECT_URI=<google-redirect-uri>,\
Run a local development webserver.)
@ export WB_DB_URI=${WB_DB_URI} && export PORT=${PORT} && \
export GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI} && \
export API_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
export API_GOOGLE_OAUTH_CLIENT_SECRET=${GOOGLE_OAUTH_CLIENT_SECRET} && \
export GOOGLE_REDIRECT_URI="${GOOGLE_REDIRECT_URI}" && \
export API_GOOGLE_OAUTH_CLIENT_ID="${GOOGLE_OAUTH_CLIENT_ID}" && \
export API_GOOGLE_OAUTH_CLIENT_SECRET="${GOOGLE_OAUTH_CLIENT_SECRET}" && \
export CALTECH_API_URL="${CALTECH_API_URL}" && \
export CALTECH_API_USER="${CALTECH_API_USER}" && \
export CALTECH_API_PASSWORD="${CALTECH_API_PASSWORD}" && \
clj -A:logging:datomic-pro:webassets:dev -m wormbase.names.service

.PHONY: run-dev-ui
Expand Down Expand Up @@ -356,11 +365,46 @@ ENV.GOOGLE_OAUTH_CLIENT_SECRET: source-secrets \
$(call check_defined, GOOGLE_OAUTH_CLIENT_SECRET, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: ENV.CALTECH_API_URL
ENV.CALTECH_API_URL: \
$(call print-help,ENV.CALTECH_API_URL,\
Retrieve the CALTECH_API_URL env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${CALTECH_API_URL},"Using predefined CALTECH_API_URL.","Retrieving CALTECH_API_URL from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${CALTECH_API_URL},,$(eval CALTECH_API_URL := $(shell ${AWS_CLI_BASE} ssm get-parameter --name "/name-service/${APP_PROFILE}/caltech-api-config/url" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, CALTECH_API_URL, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: ENV.CALTECH_API_USER
ENV.CALTECH_API_USER: \
$(call print-help,ENV.CALTECH_API_USER,\
Retrieve the CALTECH_API_USER env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${CALTECH_API_USER},"Using predefined CALTECH_API_USER.","Retrieving CALTECH_API_USER from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${CALTECH_API_USER},,$(eval CALTECH_API_USER := $(shell ${AWS_CLI_BASE} ssm get-parameter --name "/name-service/${APP_PROFILE}/caltech-api-config/username" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, CALTECH_API_USER, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: ENV.CALTECH_API_PASSWORD
ENV.CALTECH_API_PASSWORD: \
$(call print-help,ENV.CALTECH_API_PASSWORD,\
Retrieve the CALTECH_API_PASSWORD env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${CALTECH_API_PASSWORD},"Using predefined CALTECH_API_PASSWORD.","Retrieving CALTECH_API_PASSWORD from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${CALTECH_API_PASSWORD},,$(eval CALTECH_API_PASSWORD := $(shell ${AWS_CLI_BASE} ssm get-parameter --name "/name-service/${APP_PROFILE}/caltech-api-config/password" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, CALTECH_API_PASSWORD, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: google-oauth2-secrets
google-oauth2-secrets: ENV.GOOGLE_OAUTH_CLIENT_ID ENV.GOOGLE_OAUTH_CLIENT_SECRET \
$(call print-help,google-oauth2-secrets,\
Store the Google oauth2 client details as env variables.)

.PHONY: caltech-api-secrets
caltech-api-secrets: ENV.CALTECH_API_URL ENV.CALTECH_API_USER ENV.CALTECH_API_PASSWORD \
$(call print-help,caltech-api-secrets,\
Store the Caltech API details as env variables.)

${STORE_SECRETS_FILE}: google-oauth2-secrets
@install -m 600 /dev/null ${STORE_SECRETS_FILE}
@echo "GOOGLE_OAUTH_CLIENT_ID:=${GOOGLE_OAUTH_CLIENT_ID}" >> ${STORE_SECRETS_FILE}
Expand Down
22 changes: 0 additions & 22 deletions client/package-lock.json

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

1 change: 0 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"prop-types": "15.7.2",
"query-string": "5",
"react": "16.8.5",
"react-document-title": "2.0.3",
"react-dom": "16.8.5",
"react-router-dom": "5.3.4",
"react-storage-hooks": "3.0.1",
Expand Down
3 changes: 0 additions & 3 deletions client/src/components/elements/DocumentTitle.js

This file was deleted.

31 changes: 17 additions & 14 deletions client/src/components/elements/NotFound.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React, { Component } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { Typography, withStyles } from '@material-ui/core';

class NotFound extends Component {
render() {
const { classes } = this.props;
return (
<div className={classes.root}>
<Typography variant="h3" gutterBottom>
Not Found
</Typography>
{this.props.children}
</div>
);
}
}
import { useTitle } from '../../hooks/useTitle';

const NotFound = (props) => {
const { classes } = props;

useTitle('Not found');

return (
<div className={classes.root}>
<Typography variant="h3" gutterBottom>
Not Found
</Typography>
{props.children}
</div>
);
};

NotFound.propTypes = {
children: PropTypes.element,
Expand Down
18 changes: 10 additions & 8 deletions client/src/components/elements/Page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core';

function page({ classes, ...others }) {
return <div className={classes.root} {...others} />;
}
page.propTypes = {
import { useTitle } from '../../../hooks/useTitle';

const Page = (props) => {
useTitle(props.title);
return <div className={props.classes.root} {...props} />;
};
Page.propTypes = {
classes: PropTypes.object.isRequired,
title: PropTypes.string,
};

function pageMain({ classes, ...others }) {
Expand All @@ -30,15 +34,15 @@ pageRight.propTypes = {
classes: PropTypes.object.isRequired,
};

export const Page = withStyles((theme) => ({
export default withStyles((theme) => ({
root: {
display: 'flex',
margin: theme.spacing(4),
[theme.breakpoints.down('sm')]: {
flexDirection: 'column',
},
},
}))(page);
}))(Page);

export const PageLeft = withStyles((theme) => ({
left: {
Expand Down Expand Up @@ -70,5 +74,3 @@ export const PageMain = withStyles((theme) => ({
// },
// },
// }))(pageRight);

export default Page;
2 changes: 1 addition & 1 deletion client/src/components/elements/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import React from 'react';
import TextField from './TextField';

export default function TextArea(props) {
return <TextField multiline fullWidth rows={4} {...props} />;
return <TextField multiline fullWidth minRows={4} {...props} />;
}
9 changes: 4 additions & 5 deletions client/src/components/elements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

import {
MuiThemeProvider,
createMuiTheme,
createTheme,
withStyles,
Dialog as MuiDialog,
withMobileDialog,
Expand Down Expand Up @@ -44,13 +44,12 @@ export { default as AutocompleteSuggestion } from './AutocompleteSuggestion';
export { default as BaseForm } from './BaseForm';
export { default as BiotypeSelect } from './BiotypeSelect';
export { default as Button } from './Button';
export { default as DocumentTitle } from './DocumentTitle';
export { default as EntityTypeSelect } from './EntityTypeSelect';
export { default as ErrorBoundary } from './ErrorBoundary';
export { default as SimpleAjax } from './SimpleAjax';
export { default as NoData } from './NoData';
export { default as NotFound } from './NotFound';
export { Page, PageLeft, PageMain } from './Page';
export { default as Page, PageLeft, PageMain } from './Page';
export * from './ProgressButton';
export { default as ProgressButton } from './ProgressButton';
export { default as SimpleListPagination } from './SimpleListPagination';
Expand Down Expand Up @@ -85,7 +84,7 @@ export const Dialog = withMobileDialog()(
// };
// All the following keys are optional.
// We try our best to provide a great default value.
export const theme = createMuiTheme({
export const theme = createTheme({
palette: {
primary: {
main: primaryColor[700],
Expand All @@ -104,4 +103,4 @@ export const theme = createMuiTheme({
},
});

export { MuiThemeProvider, createMuiTheme, withStyles };
export { MuiThemeProvider, createTheme, withStyles };
3 changes: 3 additions & 0 deletions client/src/containers/Authenticate/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '../../components/elements';

import { useTitle } from '../../hooks/useTitle';

const Profile = (props) => {
useTitle('Your profile');
return (
<div className={props.classes.root}>
<h2>{props.name}</h2>
Expand Down
9 changes: 5 additions & 4 deletions client/src/containers/Authenticate/ProfileButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Button, withStyles } from '../../components/elements';
import { Link } from 'react-router-dom';
import PersonIcon from '@material-ui/icons/Person';

const my_profile_link = React.forwardRef(function(props, ref) {
return <Link to="/me" {...props} ref={ref} />;
});

const ProfileButton = (props) => {
return props.name ? (
<Button
component={({ ...props }) => <Link to="/me" {...props} />}
className={props.classes.button}
>
<Button component={my_profile_link} className={props.classes.button}>
<PersonIcon className={props.classes.icon} />
Hi, {props.name.split(/\s+/)[0]}
</Button>
Expand Down
Loading