-
Notifications
You must be signed in to change notification settings - Fork 56
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
[ENG-6419] Share integration #2377
Merged
futa-ikeda
merged 9 commits into
CenterForOpenScience:feature/insti-dash-improv
from
futa-ikeda:share-integration
Nov 5, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c5870be
Add no DOI logic
futa-ikeda 52fc4f5
Add logic for missing fields
futa-ikeda 7269b4d
Update metrics getter
futa-ikeda a6318d1
Use new utility package for contributor field
futa-ikeda d940adc
More tweaks to contributor field
futa-ikeda d35d4d1
Account for no affiliations
futa-ikeda 73d6fff
Update preprint controller getters
futa-ikeda 532df5a
Update registration controller getters
futa-ikeda 5de072e
fix test
futa-ikeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
app/institutions/dashboard/-components/object-list/contributors-field/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{{#each this.topInstitutionAffiliatedContributors as |contributor|}} | ||
<OsfLink | ||
@href={{contributor.url}} | ||
> | ||
{{contributor.name}} | ||
</OsfLink> | ||
{{t 'institutions.dashboard.object-list.table-items.permission-level' permissionLevel=contributor.permissionLevel}} | ||
<div> | ||
<OsfLink | ||
@href={{contributor.url}} | ||
> | ||
{{contributor.name}} | ||
</OsfLink> | ||
{{t 'institutions.dashboard.object-list.table-items.permission-level' permissionLevel=contributor.permissionLevel}} | ||
</div> | ||
{{/each}} |
2 changes: 2 additions & 0 deletions
2
app/institutions/dashboard/-components/object-list/doi-field/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{{#each this.dois as |doi|}} | ||
<OsfLink @href={{doi.fullLink}} @target='_blank'>{{doi.displayText}}</OsfLink> | ||
{{else}} | ||
{{t 'institutions.dashboard.object-list.table-items.no-info' field=(t 'institutions.dashboard.object-list.table-headers.doi')}} | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export function *iterOsfmapObjects(osfmapObject: any, propertyPath: string[]): IterableIterator<any> { | ||
const [property, ...remainingPath] = propertyPath; | ||
const innerObjArray = osfmapObject[property] || []; | ||
if (remainingPath.length) { | ||
for (const innerObj of innerObjArray) { | ||
yield* iterOsfmapObjects(innerObj, remainingPath); | ||
} | ||
} else { | ||
yield* innerObjArray; | ||
} | ||
} | ||
|
||
export function *iterOsfmapValues(osfmapObject: any, propertyPath: string[]): IterableIterator<any> { | ||
for (const obj of iterOsfmapObjects(osfmapObject, propertyPath)) { | ||
yield (Object.hasOwn(obj, '@id') ? obj['@id'] : obj['@value']); | ||
} | ||
} | ||
|
||
export function getOsfmapValues(osfmapObject: any, propertyPath: string[]) { | ||
return Array.from(iterOsfmapValues(osfmapObject, propertyPath)); | ||
} | ||
|
||
export function getSingleOsfmapValue(osfmapObject: any, propertyPath: string[]) { | ||
return iterOsfmapValues(osfmapObject, propertyPath).next().value; | ||
} | ||
|
||
export function getOsfmapObjects(osfmapObject: any, propertyPath: string[]) { | ||
return Array.from(iterOsfmapObjects(osfmapObject, propertyPath)); | ||
} | ||
|
||
export function getSingleOsfmapObject(osfmapObject: any, propertyPath: string[]) { | ||
return iterOsfmapObjects(osfmapObject, propertyPath).next().value; | ||
} | ||
|
||
export function hasOsfmapValue(osfmapObject: any, propertyPath: string[], expectedValue: any) { | ||
// could use `Iterator.prototype.some()` instead, if polyfilled | ||
for (const value of iterOsfmapValues(osfmapObject, propertyPath)) { | ||
if (value === expectedValue) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you use this on something that's not a single value? Does it fail gracefully? Or does typescript help here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just get the first one, and if there's no
@id
or@value
, it should just returnundefined