Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e4e471c
fix(add-project-redirect-modal): added project redirect modal
rnastyuk Sep 10, 2025
80a52a8
Merge branch 'main' into feat/230-add-project-redirect-modal
rnastyuk Sep 10, 2025
2853041
refactor(add-project-redirect-modal): added pipe to the modal subscri…
rnastyuk Sep 10, 2025
1aa52dc
fix(addons): added logic for handling redirection after the oauth flo…
rnastyuk Sep 12, 2025
3b2d197
Merge branch 'main' into fix/addons
rnastyuk Sep 12, 2025
d7dade1
fix(addons): added data attributes
rnastyuk Sep 12, 2025
67dd510
Merge remote-tracking branch 'origin/fix/addons' into fix/addons
rnastyuk Sep 12, 2025
4e6ca60
fix(addons): fixed comments
rnastyuk Sep 12, 2025
d8da3d0
fix(addons): fixed binding visibility change issues
rnastyuk Sep 12, 2025
fe4b94f
Merge branch 'refs/heads/main' into fix/addons
rnastyuk Sep 15, 2025
9cb2cba
fix(addons): fixed issue with connecting citations addons
rnastyuk Sep 15, 2025
7127f46
Fix/625 view duplicates bug (#389)
nsemets Sep 15, 2025
d28d72f
fix(users): added 5 more columns options (#390)
nsemets Sep 15, 2025
8a85f6f
Fix test env SHARE url (#393)
mfraezz Sep 15, 2025
e3b752c
Fix/wiki (#392)
nmykhalkevch-exoft Sep 15, 2025
68955dc
Feature/eslint pipeline Fixed all the lint errors and updated sentry …
bp-cos Sep 15, 2025
c2778cf
Fix/main to dev (#395)
nsemets Sep 15, 2025
6bb5fd0
Fix/wiki (#398)
nmykhalkevch-exoft Sep 16, 2025
f63b15e
Fix - Contributors permissions (#391)
rrromchIk Sep 16, 2025
9a26d6b
fix(eng-8505): added config variable for google file picker (#397)
bp-cos Sep 16, 2025
2adbc64
Fix/649 moderation tab (#400)
nsemets Sep 16, 2025
b56ce01
fix(datalayer): fixed to handle datalayer existence (#401)
bp-cos Sep 16, 2025
68e6827
fix(metadata): correct resource type values (#402)
aaxelb Sep 16, 2025
d337216
Fix(view-only-links): View only links files access issues (#399)
rnastyuk Sep 17, 2025
f22c5ef
fix(addons): fixed connect/configure button appearence and logic
rnastyuk Sep 17, 2025
e2cb954
Merge branch 'main' into fix/addons
rnastyuk Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/app/features/project/addons/addons.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@
/>

@if (!isConfiguredAddonsLoading()) {
<osf-addon-card-list
[cards]="allConfiguredAddons()"
[cardButtonLabel]="'settings.addons.connectAddon.configure' | translate"
/>
<osf-addon-card-list [cards]="allConfiguredAddons()" />
} @else {
<div class="flex-1 mt-6 md:mt-8 lg:pt-7">
<osf-loading-spinner />
Expand Down
33 changes: 27 additions & 6 deletions src/app/features/project/addons/addons.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { LoadingSpinnerComponent, SearchInputComponent, SelectComponent, SubHead
import { AddonCardListComponent } from '@shared/components/addons';
import { ADDON_CATEGORY_OPTIONS, ADDON_TAB_OPTIONS } from '@shared/constants';
import { AddonCategory, AddonTabValue } from '@shared/enums';
import { isAddonServiceConfigured } from '@shared/helpers';
import { AddonCardModel } from '@shared/models';
import {
AddonsSelectors,
ClearConfiguredAddons,
Expand Down Expand Up @@ -151,6 +153,10 @@ export class AddonsComponent implements OnInit {
return authorizedAddons.filter((card) => card.displayName.toLowerCase().includes(searchValue));
});

allConfiguredAddonsForCheck = computed(() => {
return [...this.configuredStorageAddons(), ...this.configuredCitationAddons(), ...this.configuredLinkAddons()];
});

resourceReferenceId = computed(() => {
return this.addonsResourceReference()[0]?.id;
});
Expand Down Expand Up @@ -181,13 +187,28 @@ export class AddonsComponent implements OnInit {
}
});

filteredAddonCards = computed(() => {
filteredAddonCards = computed((): AddonCardModel[] => {
const searchValue = this.searchValue().toLowerCase();
return this.currentAddonsState().filter(
(card) =>
card.externalServiceName.toLowerCase().includes(searchValue) ||
card.displayName.toLowerCase().includes(searchValue)
);
const configuredAddons = this.allConfiguredAddonsForCheck();

return this.currentAddonsState()
.filter(
(card) =>
card.externalServiceName.toLowerCase().includes(searchValue) ||
card.displayName.toLowerCase().includes(searchValue)
)
.map((addon) => {
const isConfigured = isAddonServiceConfigured(addon, configuredAddons);
const configuredAddon = configuredAddons.find(
(config) => config.externalServiceName === addon.externalServiceName
);

return {
addon,
isConfigured,
configuredAddon,
} as AddonCardModel;
});
});

onCategoryChange(value: Primitive): void {
Expand Down
6 changes: 1 addition & 5 deletions src/app/features/settings/addons/addons.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@
/>

@if (!isAuthorizedAddonsLoading()) {
<osf-addon-card-list
[cards]="allAuthorizedAddons()"
[cardButtonLabel]="'settings.addons.form.buttons.reconnect' | translate"
[showDangerButton]="true"
/>
<osf-addon-card-list [cards]="allAuthorizedAddons()" [showDangerButton]="true" />
} @else {
<div class="mt-8">
<osf-loading-spinner />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<section class="grid">
@if (cards().length) {
@for (card of cards(); track card.id) {
@for (card of cards(); track $index) {
<div class="col-12 sm:col-6 md:col-6 lg:col-4">
<osf-addon-card [cardButtonLabel]="cardButtonLabel()" [card]="card" [showDangerButton]="showDangerButton()" />
<osf-addon-card [card]="card" [showDangerButton]="showDangerButton()" />
</div>
}
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ describe('AddonCardListComponent', () => {
expect(component.cards()).toEqual([]);
});

it('should have default empty string ', () => {
expect(component.cardButtonLabel()).toBe('');
});

it('should have default false value', () => {
expect(component.showDangerButton()).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TranslatePipe } from '@ngx-translate/core';

import { Component, input } from '@angular/core';

import { AddonModel, AuthorizedAccountModel, ConfiguredAddonModel } from '@shared/models';
import { AddonCardModel, AddonModel, AuthorizedAccountModel, ConfiguredAddonModel } from '@shared/models';

import { AddonCardComponent } from '../addon-card/addon-card.component';

Expand All @@ -13,7 +13,6 @@ import { AddonCardComponent } from '../addon-card/addon-card.component';
styleUrl: './addon-card-list.component.scss',
})
export class AddonCardListComponent {
cards = input<(AddonModel | AuthorizedAccountModel | ConfiguredAddonModel)[]>([]);
cardButtonLabel = input<string>('');
cards = input<(AddonModel | AuthorizedAccountModel | ConfiguredAddonModel | AddonCardModel)[]>([]);
showDangerButton = input<boolean>(false);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="addon-card flex flex-1 gap-4 flex-column p-5">
<div class="max-h-8rem flex justify-content-center align-items-center">
@if (card()!.externalServiceName) {
@if (actualAddon()?.externalServiceName) {
<img
class="addon-image"
alt="Addon card image"
[src]="'assets/icons/addons/' + card()!.externalServiceName + '.svg'"
[src]="'assets/icons/addons/' + actualAddon()!.externalServiceName + '.svg'"
data-test-addon-card-logo
/>
}
</div>

<div class="flex flex-column gap-3">
<h3 class="text-center" data-test-addon-card-title>{{ card()?.displayName }}</h3>
<h3 class="text-center" data-test-addon-card-title>{{ actualAddon()?.displayName }}</h3>

<div class="flex justify-content-center align-items-center md:gap-5 md:mt-3 btn-container">
@if (showDangerButton()) {
Expand All @@ -24,7 +24,7 @@ <h3 class="text-center" data-test-addon-card-title>{{ card()?.displayName }}</h3
}

<p-button
[label]="cardButtonLabel() || ('settings.addons.form.buttons.connect' | translate)"
[label]="buttonLabel() | translate"
severity="secondary"
(onClick)="!isConfiguredAddon() ? onConnectAddon() : onConfigureAddon()"
></p-button>
Expand Down
55 changes: 45 additions & 10 deletions src/app/shared/components/addons/addon-card/addon-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Router } from '@angular/router';

import { getAddonTypeString, isConfiguredAddon } from '@osf/shared/helpers';
import { CustomConfirmationService, LoaderService } from '@osf/shared/services';
import { AddonModel, AuthorizedAccountModel, ConfiguredAddonModel } from '@shared/models';
import { AddonCardModel, AddonModel, AuthorizedAccountModel, ConfiguredAddonModel } from '@shared/models';
import { DeleteAuthorizedAddon } from '@shared/stores/addons';

@Component({
Expand All @@ -24,15 +24,38 @@ export class AddonCardComponent {
private readonly loaderService = inject(LoaderService);
private readonly actions = createDispatchMap({ deleteAuthorizedAddon: DeleteAuthorizedAddon });

readonly card = input<AddonModel | AuthorizedAccountModel | ConfiguredAddonModel | null>(null);
readonly cardButtonLabel = input<string>('');
readonly card = input<AddonModel | AuthorizedAccountModel | ConfiguredAddonModel | AddonCardModel | null>(null);
readonly showDangerButton = input<boolean>(false);

readonly addonTypeString = computed(() => getAddonTypeString(this.card()));
readonly isConfiguredAddon = computed(() => isConfiguredAddon(this.card()));
readonly actualAddon = computed(() => {
const actualCard = this.card();
if (!actualCard) return null;

if ('isConfigured' in actualCard) {
return actualCard.addon;
}

return actualCard;
});

readonly addonTypeString = computed(() => getAddonTypeString(this.actualAddon()));
readonly isConfiguredAddon = computed(() => {
const actualCard = this.card();
if (!actualCard) return false;

if ('isConfigured' in actualCard) {
return actualCard.isConfigured;
}

return isConfiguredAddon(actualCard);
});

readonly buttonLabel = computed(() => {
return this.isConfiguredAddon() ? 'settings.addons.form.buttons.configure' : 'settings.addons.form.buttons.connect';
});

onConnectAddon(): void {
const addon = this.card();
const addon = this.actualAddon();
if (addon) {
const currentUrl = this.router.url;
const baseUrl = currentUrl.split('/addons')[0];
Expand All @@ -43,13 +66,24 @@ export class AddonCardComponent {
}

onConfigureAddon(): void {
const addon = this.card();
if (addon) {
const actualCard = this.card();
if (!actualCard) return;

if ('isConfigured' in actualCard && actualCard.configuredAddon) {
const currentUrl = this.router.url;
const baseUrl = currentUrl.split('/addons')[0];
this.router.navigate([`${baseUrl}/addons/configure-addon`], {
state: { addon },
state: { addon: actualCard.configuredAddon },
});
} else {
const addon = this.actualAddon();
if (addon) {
const currentUrl = this.router.url;
const baseUrl = currentUrl.split('/addons')[0];
this.router.navigate([`${baseUrl}/addons/configure-addon`], {
state: { addon },
});
}
}
}

Expand All @@ -63,7 +97,8 @@ export class AddonCardComponent {
}

onDisableAddon(): void {
const addonId = this.card()?.id;
const addon = this.actualAddon();
const addonId = addon?.id;

if (addonId) {
this.loaderService.show();
Expand Down
6 changes: 6 additions & 0 deletions src/app/shared/helpers/addon-type.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ export function isConfiguredAddon(addon: AddonModel | AuthorizedAccountModel | C
addon.type === ConfiguredAddonType.LINK
);
}

export function isAddonServiceConfigured(addon: AddonModel | null, configuredAddons: ConfiguredAddonModel[]): boolean {
if (!addon) return false;

return configuredAddons.some((configuredAddon) => configuredAddon.externalServiceName === addon.externalServiceName);
}
8 changes: 8 additions & 0 deletions src/app/shared/models/addons/addon-card.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AddonModel } from './addons.models';
import { ConfiguredAddonModel } from './configured-addon.model';

export interface AddonCardModel {
addon: AddonModel;
isConfigured: boolean;
configuredAddon?: ConfiguredAddonModel;
}
1 change: 1 addition & 0 deletions src/app/shared/models/addons/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './addon-card.model';
export * from './addon-form.model';
export * from './addon-terms.model';
export * from './addons.models';
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,7 @@
"acceptingTerms": "Accepting...",
"back": "Back",
"connect": "Connect",
"configure": "Configure",
"reconnect": "Reconnect",
"authorize": "Authorize",
"disable": "Disable",
Expand Down
Loading