-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Purpose - Add addon-cards component to configure, enable, and disable addons ## Summary of Changes - Update adapters, addons route page, and manager - Add addons card component
- Loading branch information
1 parent
302d825
commit afabc86
Showing
29 changed files
with
355 additions
and
17 deletions.
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,7 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class GuidNodeAddons extends Route { | ||
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> |
56 changes: 56 additions & 0 deletions
56
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,56 @@ | ||
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 legacyAddonLogoMap: 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', | ||
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 | ||
closeDeleteModal() { | ||
this.deleteModalOpen = false; | ||
} | ||
|
||
@action | ||
disableAddon() { | ||
const { addon } = this.args; | ||
addon.disableProjectAddon(); | ||
} | ||
|
||
get assetLogo() { | ||
if (this.args.addon instanceof LegacyProvider) { | ||
return legacyAddonLogoMap[this.args.addon.provider.id]; | ||
} else { | ||
return this.args.addon.provider.iconUri; | ||
} | ||
} | ||
|
||
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' provider=@addon.provider.name}} | ||
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' (action (mut this.deleteModalOpen) true)}} | ||
> | ||
{{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='Disable addon 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.
Oops, something went wrong.