-
Notifications
You must be signed in to change notification settings - Fork 59
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-4964] Addon cards #2092
Merged
brianjgeiger
merged 6 commits into
CenterForOpenScience:feature/addon-services
from
futa-ikeda:addon-cards
Dec 19, 2023
Merged
[ENG-4964] Addon cards #2092
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b0e6301
Update mirage and adapters
futa-ikeda 4516be7
Updates to addon route and manager
futa-ikeda edb7fcc
Add addon card component
futa-ikeda 3c0d848
Copy-pasta
futa-ikeda 91b88ec
CR feedback
futa-ikeda b13252b
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
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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import Store from '@ember-data/store'; | ||
|
||
export default class GuidNodeAddons extends Route { | ||
@service store: Store; | ||
|
||
async model() { | ||
return await this.modelFor('guid-node').taskInstance; | ||
} | ||
} |
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,4 @@ | ||
.addon-cards-wrapper { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} |
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 +1,10 @@ | ||
{{!-- List all providers to choose from here --}} | ||
<AddonsService::Manager | ||
@node={{this.model}} | ||
as |manager| | ||
> | ||
<div local-class='addon-cards-wrapper'> | ||
{{#each manager.addonProviders as |addon|}} | ||
<AddonCard @addon={{addon}} @manager={{manager}} /> | ||
{{/each}} | ||
</div> | ||
</AddonsService::Manager> |
58 changes: 58 additions & 0 deletions
58
lib/osf-components/addon/components/addon-card/component.ts
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,58 @@ | ||
import { action } from '@ember/object'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
import LegacyProvider from 'ember-osf-web/packages/addons-service/legacy-provider'; | ||
import Provider from 'ember-osf-web/packages/addons-service/provider'; | ||
import AddonsServiceManagerComponent from 'osf-components/components/addons-service/manager/component'; | ||
|
||
interface Args { | ||
addon: LegacyProvider | Provider; | ||
manager: AddonsServiceManagerComponent; | ||
} | ||
|
||
const addonLogoMap: Record<string, string> = { | ||
aws: '/assets/images/addons/logos/aws.png', | ||
bitbucket: '/assets/images/addons/logos/bitbucket.png', | ||
boa: '/assets/images/addons/logos/boa_color.png', | ||
box: '/assets/images/addons/logos/box.png', | ||
dataverse: '/assets/images/addons/logos/dataverse.png', | ||
dropbox: '/assets/images/addons/logos/dropbox.png', | ||
figshare: '/assets/images/addons/logos/figshare.png', | ||
github: '/assets/images/addons/logos/github.png', | ||
gitlab: '/assets/images/addons/logos/gitlab.png', | ||
googledrive: '/assets/images/addons/logos/google.png', | ||
mendeley: '/assets/images/addons/logos/mendeley.png', | ||
onedrive: '/assets/images/addons/logos/onedrive.png', | ||
owncloud: '/assets/images/addons/logos/owncloud.png', | ||
zotero: '/assets/images/addons/logos/zotero.png', | ||
}; | ||
|
||
export default class AddonsCardComponent extends Component<Args> { | ||
@tracked deleteModalOpen = false; | ||
|
||
@action | ||
toggleDeleteModal() { | ||
this.deleteModalOpen = !this.deleteModalOpen; | ||
} | ||
|
||
@action | ||
closeDeleteModal() { | ||
this.deleteModalOpen = false; | ||
} | ||
|
||
@action | ||
disableAddon() { | ||
const { addon } = this.args; | ||
addon.disableProjectAddon(); | ||
} | ||
|
||
get assetLogo() { | ||
return addonLogoMap[this.args.addon.provider.id]; | ||
} | ||
|
||
get addonIsConfigured() { | ||
const { addon, manager } = this.args; | ||
return manager.projectEnabledAddons.includes(addon); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
lib/osf-components/addon/components/addon-card/styles.scss
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,47 @@ | ||
.card-wrapper { | ||
min-width: 208px; | ||
border: solid 1px $color-border-gray; | ||
margin: 5px 3px; | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
|
||
.addon-card-logo { | ||
height: 36px; | ||
} | ||
|
||
.provider-name { | ||
font-weight: bold; | ||
margin: 15px 0; | ||
} | ||
|
||
.button-looking-links { | ||
composes: Button from '../button/styles.scss'; | ||
composes: MediumButton from '../button/styles.scss'; | ||
composes: SecondaryButton from '../button/styles.scss'; | ||
} | ||
|
||
.buttons-wrapper { | ||
display: flex; | ||
justify-content: center; | ||
|
||
.enable { | ||
color: darken($brand-success, 10%); | ||
} | ||
|
||
.configure { | ||
border-bottom-right-radius: 0; | ||
border-top-right-radius: 0; | ||
} | ||
|
||
.disable { | ||
color: darken($brand-danger, 10%); | ||
border-left: 0; | ||
border-bottom-left-radius: 0; | ||
border-top-left-radius: 0; | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
lib/osf-components/addon/components/addon-card/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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<div | ||
local-class='card-wrapper' | ||
data-test-addon-card={{@addon.provider.name}} | ||
data-analytics-scope={{concat 'Addon card' @addon.provider.name}} | ||
> | ||
<img | ||
data-test-addon-card-logo | ||
src={{this.assetLogo}} | ||
alt={{t 'osf-components.addon-card.provider-logo-alt' [email protected]}} | ||
local-class='addon-card-logo' | ||
/> | ||
<div | ||
data-test-addon-card-title | ||
local-class='provider-name' | ||
> | ||
{{@addon.provider.name}} | ||
</div> | ||
|
||
<div local-class='buttons-wrapper'> | ||
{{#if this.addonIsConfigured}} | ||
<OsfLink | ||
data-test-addon-card-configure | ||
data-analytics-name='Configure' | ||
local-class='button-looking-links configure' | ||
@route='guid-node.addons.addon.configure' | ||
@models={{array @manager.node.id @addon.provider.id}} | ||
> | ||
{{t 'osf-components.addon-card.configure'}} | ||
</OsfLink> | ||
<Button | ||
data-test-addon-card-disable | ||
data-analytics-name='Disable' | ||
local-class='disable' | ||
{{on 'click' this.toggleDeleteModal}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not seeing another use of toggle, and I don't think this is clickable while the dialog is open. Would it make more sense to just |
||
> | ||
{{t 'osf-components.addon-card.disable'}} | ||
</Button> | ||
{{else}} | ||
<OsfLink | ||
data-test-addon-card-enable | ||
data-analytics-name='Enable' | ||
local-class='button-looking-links enable' | ||
@route='guid-node.addons.addon.terms' | ||
@models={{array @manager.node.id @addon.provider.id}} | ||
> | ||
{{t 'osf-components.addon-card.enable'}} | ||
</OsfLink> | ||
{{/if}} | ||
</div> | ||
</div> | ||
{{#if this.addonIsConfigured}} | ||
<OsfDialog | ||
@isOpen={{this.deleteModalOpen}} | ||
@onClose={{action this.closeDeleteModal}} | ||
as |dialog| | ||
> | ||
<dialog.heading> | ||
{{t 'osf-components.addon-card.disable-modal-header'}} | ||
</dialog.heading> | ||
<dialog.main> | ||
<p> | ||
{{t 'osf-components.addon-card.disable-modal-body'}} | ||
</p> | ||
</dialog.main> | ||
<dialog.footer data-analytics-scope='Verify email modal'> | ||
<Button | ||
data-test-addon-disable-cancel | ||
data-analytics-name='Cancel' | ||
@type='secondary' | ||
{{on 'click' dialog.close}} | ||
> | ||
{{t 'general.cancel'}} | ||
</Button> | ||
<Button | ||
data-test-addon-disable-modal-disable | ||
data-analytics-name='Disable' | ||
@type='destroy' | ||
{{on 'click' (queue this.disableAddon dialog.close)}} | ||
> | ||
{{t 'osf-components.addon-card.disable'}} | ||
</Button> | ||
</dialog.footer> | ||
</OsfDialog> | ||
{{/if}} | ||
|
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
6 changes: 6 additions & 0 deletions
6
lib/osf-components/addon/components/addons-service/manager/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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{yield (hash | ||
node=this.node | ||
addonProviders=this.addonProviders | ||
loading=this.loading | ||
projectEnabledAddons=this.projectEnabledAddons | ||
)}} |
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 @@ | ||
export { default } from 'osf-components/components/addon-card/component'; |
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 @@ | ||
export { default } from 'osf-components/components/addon-card/template'; |
1 change: 1 addition & 0 deletions
1
lib/osf-components/app/components/addons-service/manager/template.js
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 @@ | ||
export { default } from 'osf-components/components/addons-service/manager/template'; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Since this one will be coming from the services API, we shouldn't need to store this one. That being said, I have no idea how we'd mirage that, so it may just not show properly when we're running locally though mirage.