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

[DT-1077] typescriptify datasetstatistics and fix #2757

Merged

Conversation

s-rubenstein
Copy link
Contributor

Addresses

I noticed the issue appeared to be based on properties missing, so I added a test with no additional properties that still renders.

I opted not to put in the additional effort to typescriptify the test, because test files are much less impact as js vs ts, and if we decide to move unit tests to jest eventually, I wanted to prioritize effort.

Summary


Have you read Terra's Contributing Guide lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@s-rubenstein s-rubenstein requested a review from a team as a code owner December 18, 2024 20:44
@s-rubenstein s-rubenstein requested review from pshapiro4broad and snf2ye and removed request for a team December 18, 2024 20:44
@@ -1,6 +0,0 @@

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 file is side by side with a models.js file, and the capitalization being the only difference was causing issues. Given this was only used in one place I just moved it.

Copy link
Contributor

@rjohanek rjohanek left a comment

Choose a reason for hiding this comment

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

typescriptification looks good, love the additional test, is there a way to include pictures to show that the full page renders as expected?

@s-rubenstein s-rubenstein force-pushed the sr/dt-1077-typescriptify-datasetstatistics-and-fix branch from 1827bc8 to 51defb4 Compare December 19, 2024 15:25
@s-rubenstein
Copy link
Contributor Author

Screenshot 2024-12-19 at 10 35 58 AM
Here's a screenshot, but I don't think we can get much clarity on whether it worked without the specific prod data.

Comment on lines -118 to +135
{extract('Dataset Description') || dataset?.description || dataset?.study?.description || 'N/A'}
{extract('Dataset Description') || dataset?.study?.description || 'N/A'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is dataset?.description not needed here?

Copy link
Member

Choose a reason for hiding this comment

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

I think that was an error, the type Dataset doesn't have a description field. Maybe the API changed at some point and this was kept around for backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its not actually a field on the typed object! I don't know why it was there before.

const [dars, setDars] = useState();
const [datasetId, setDatasetId] = useState<number>();
const [dataset, setDataset] = useState<Dataset>();
const [dars, setDars] = useState<any>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to type dars as well?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like it wouldn't be too hard, although this type doesn't exist yet in duos-ui. The Java type is a List of DarMetricsSummary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@pshapiro4broad pshapiro4broad 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'm looking forward to having more typescript in this code base

const extract = useCallback((propertyName) => {
const property = find({propertyName})(dataset.properties);
const extract = useCallback((propertyName: string) => {
const property = find({propertyName})(dataset?.properties) as DatasetProperty;
Copy link
Member

Choose a reason for hiding this comment

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

Would it be too ambitious to add types to the Ajax APIs too? If there's a way to incrementally add types to just the APIs used here that would be an improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ajax often has types, but extract doesn't because properties is ambiguous.


const LINE = <div style={{borderTop: '1px solid #BABEC1', height: 0}}/>;

export default function DatasetStatistics(props) {
enum AccessManagement {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be moved to Model.ts? Or this only an UI concept and not part of an API model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not a part of the API model I believe. Or at least, it was in a separate file and model.js is a generated file. Model.ts was conflicting because of the import conflicts in js having issues with casing

Comment on lines -118 to +135
{extract('Dataset Description') || dataset?.description || dataset?.study?.description || 'N/A'}
{extract('Dataset Description') || dataset?.study?.description || 'N/A'}
Copy link
Member

Choose a reason for hiding this comment

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

I think that was an error, the type Dataset doesn't have a description field. Maybe the API changed at some point and this was kept around for backward compatibility?

@s-rubenstein s-rubenstein merged commit d1ea23f into develop Dec 20, 2024
9 checks passed
@s-rubenstein s-rubenstein deleted the sr/dt-1077-typescriptify-datasetstatistics-and-fix branch December 20, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants