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

Feature/metadata editing/restrict annotations #464

Open
wants to merge 14 commits into
base: feature/metadata-editing/develop
Choose a base branch
from

Conversation

SeanLeRoy
Copy link
Contributor

@SeanLeRoy SeanLeRoy commented Mar 7, 2025

Changes

Anya added a ton of metadata editing logic this is the last piece which just adds a password modal auth before the actual edit modal and also restricts some of the annotations by hard coding some locked down ones. Resolves #341 & resolves #343.

Additionally:

  • I randomly also made a common spinner component as part of this because it was bugging me having to implement it so many times.
  • Pushed some stuff into common use hooks
  • Tried to simplify some of the ways props were passed down to reduce render counts and enhance readability
  • Fixed the way getFiles worked (this is already on main but because this is merged into a different branch it shows as a diff)

Testing

Tested locally against staging and production (staging seems to recently have gotten a data change though making it difficult to test with)

TODO

  • Talk with users about what other programs we need to add and then add them

@@ -18,16 +18,23 @@ import styles from "./EditMetadata.module.css";
// a more robust solution in the future such as login or a more secure method.
// or find a way to get this information passed in via GH secrets to the packaged
// web bundle
// TODO: Actually lets try to request this from GH or something..?
Copy link
Contributor Author

@SeanLeRoy SeanLeRoy Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Before merging - test putting this into a file we can request from the web or something at least to get it out of this level of hard-coded. (Maybe even labkey...)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is to update these password quarterly, right? So at least extracting them seems smart.

@@ -22,7 +23,7 @@ export const AnnotationTypeIdMap = {
[AnnotationType.BOOLEAN]: 3,
[AnnotationType.DATETIME]: 4,
[AnnotationType.DROPDOWN]: 5,
// [AnnotationType.LOOKUP]: 6, // Not currently supported
[AnnotationType.LOOKUP]: 6, // Not currently supported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this comment still valid?

Copy link
Contributor

@aswallace aswallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only partway through reviewing, just adding comments so far for now

@@ -16,6 +9,7 @@ import { interaction } from "../../state";
import { StatusUpdate, ProcessStatus } from "../../state/interaction/actions";

import styles from "./StatusMessage.module.css";
import LoadingIcon from "../Icons/LoadingIcon";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import order thing

@@ -81,6 +82,10 @@ export default class Annotation {
return this.annotation.isOpenFileLink || false;
}

public get isImmutable(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if would benefit from an explanatory comment here (e.g., that this is mainly to prevent editing on certain top level annotations)

@@ -136,7 +136,7 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
],
},
},
...(isQueryingAicsFms
...(isQueryingAicsFms && isOnWeb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we preventing editing on desktop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I was originally but I think I'll add it back and use LK or something to grab the passwords - I just didn't want the desktop to be a relic holding stale passwords

"Cell Line R And D",
"Cell Line Source",
"Cell Population Id",
,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra comma?

@@ -102,6 +102,9 @@ export default class HttpFileService extends HttpServiceBase implements FileServ
public async getFiles(request: GetFilesRequest): Promise<FileDetail[]> {
const { from, limit, fileSet } = request;

if (limit - from > 1000) {
throw new Error("uhh" + limit + " " + from);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

filesSelected = await fileSet.fetchFileRange(0, totalFileCount);
} else {
filesSelected = await fileSelection.fetchAllDetails();
console.log("non-filters", filesSelected.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needed?

invertColor?: boolean;
size?: SpinnerSize;

"data-testid"?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a prop used by the testing components - generally we don't need to explicitly define it like this but in this case we do

infoMessage = (
<p className={styles.errorMessage}>
The files you have selected do not share the same program or do not have a program
at all.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"program at all" feels a little weird. maybe "program metadata tag"

Copy link
Contributor

@aswallace aswallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!! I couldn't fully test locally but tried out the pre-submit behavior and things work as expected

key: annotation.name,
text: annotation.displayName,
disabled: annotation.isImmutable,
title: annotation.isImmutable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this tooltip show up for some reason

text: annotation.displayName,
disabled: annotation.isImmutable,
title: annotation.isImmutable
? "This field cannot be edited because it is automatically created based on some heuristic"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if wording of "based on some heuristic" is clear but I don't have a suggested alternative

// If it's a dropdown, we need to fetch the dropdown options
if (option?.data === AnnotationType.STRING) {
annotationService
.fetchAnnotationDetails(selectedFieldName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this likely to ever take long (i.e., any chance we'd need a loading indicator on the UI side?)

@@ -0,0 +1,79 @@
.error-message {
background-color: rgba(194, 48, 48, 0.5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are also the global variables --error-status-background-color and --error-status-text-color which are what we use for backgrounds/borders in the status messages

<>
<p>
A password is required for editing or creating new metadata. Each password is
specific to a program, only files associated with that program can be edited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit: program; instead of program,
also in line 65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants