Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ <h2 class="align-self-center inline-block">
</p>

<div class="flex gap-2">
<p-button
icon="fas fa-pencil"
text
(click)="toggleEditMode()"
(keydown.enter)="toggleEditMode()"
></p-button>
@if (canRename()) {
<p-button
icon="fas fa-pencil"
text
(click)="toggleEditMode()"
(keydown.enter)="toggleEditMode()"
></p-button>
}
<p-button
icon="fas fa-trash"
severity="danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class ConfigureAddonComponent implements OnInit {
addon = signal<ConfiguredAddonModel | null>(null);

readonly isGoogleDrive = computed(() => this.storageAddon()?.wbKey === 'googledrive');
readonly canRename = computed(() => this.addon()?.currentUserIsOwner ?? false);

isEditMode = signal<boolean>(false);
selectedStorageItemId = signal('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
</div>
</section>
@if (!isAllAddonsTabLoading()) {
<osf-addon-card-list [cards]="filteredAddonCards()" [showDangerButton]="false" />
<osf-addon-card-list
[cards]="filteredAddonCards()"
[isConnected]="false"
[hasAdminAccess]="hasAdminAccess()"
/>
} @else {
<div class="flex-1 mt-4 md:mt-8 lg:pt-5">
<osf-loading-spinner />
Expand All @@ -58,7 +62,11 @@
/>

@if (!isConfiguredAddonsLoading()) {
<osf-addon-card-list [cards]="allConfiguredAddons()" />
<osf-addon-card-list
[cards]="allConfiguredAddons()"
[isConnected]="false"
[hasAdminAccess]="hasAdminAccess()"
/>
} @else {
<div class="flex-1 mt-6 md:mt-8 lg:pt-7">
<osf-loading-spinner />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
GetLinkAddons,
GetStorageAddons,
} from '@shared/stores/addons';
import { CurrentResourceSelectors } from '@shared/stores/current-resource';

@Component({
selector: 'osf-project-addons',
Expand Down Expand Up @@ -75,6 +76,7 @@ export class ProjectAddonsComponent implements OnInit {
selectedTab = signal<number>(this.defaultTabValue);

currentUser = select(UserSelectors.getCurrentUser);
hasAdminAccess = select(CurrentResourceSelectors.hasAdminAccess);
addonsResourceReference = select(AddonsSelectors.getAddonsResourceReference);
addonsUserReference = select(AddonsSelectors.getAddonsUserReference);
storageAddons = select(AddonsSelectors.getStorageAddons);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</section>

@if (!isAddonsLoading()) {
<osf-addon-card-list [cards]="filteredAddonCards()" [showDangerButton]="false" />
<osf-addon-card-list [cards]="filteredAddonCards()" [isConnected]="false" [hasAdminAccess]="true" />
} @else {
<div class="mt-8">
<osf-loading-spinner />
Expand All @@ -62,7 +62,7 @@
/>

@if (!isAuthorizedAddonsLoading()) {
<osf-addon-card-list [cards]="allAuthorizedAddons()" [showDangerButton]="true" />
<osf-addon-card-list [cards]="allAuthorizedAddons()" [isConnected]="true" [hasAdminAccess]="true" />
} @else {
<div class="mt-8">
<osf-loading-spinner />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@if (cards().length) {
@for (card of cards(); track $index) {
<div class="col-12 sm:col-6 md:col-6 lg:col-4">
<osf-addon-card [card]="card" [showDangerButton]="showDangerButton()" />
<osf-addon-card [card]="card" [isConnected]="isConnected()" [hasAdminAccess]="hasAdminAccess()" />
</div>
}
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('AddonCardListComponent', () => {
});

it('should have default false value', () => {
expect(component.showDangerButton()).toBe(false);
expect(component.isConnected()).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ import { AddonCardComponent } from '../addon-card/addon-card.component';
})
export class AddonCardListComponent {
cards = input<(AddonModel | AuthorizedAccountModel | ConfiguredAddonModel | AddonCardModel)[]>([]);
showDangerButton = input<boolean>(false);
isConnected = input<boolean>(false);
hasAdminAccess = input<boolean>(false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<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()) {
@if (isConnected()) {
<p-button
[label]="'settings.addons.form.buttons.disable' | translate"
severity="danger"
Expand All @@ -26,6 +26,8 @@ <h3 class="text-center" data-test-addon-card-title>{{ actualAddon()?.displayName
<p-button
[label]="buttonLabel() | translate"
severity="secondary"
[disabled]="!canConfigure()"
[class.opacity-0]="!canConfigure()"
(onClick)="!isConfiguredAddon() ? onConnectAddon() : onConfigureAddon()"
></p-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export class AddonCardComponent {
private readonly actions = createDispatchMap({ deleteAuthorizedAddon: DeleteAuthorizedAddon });

readonly card = input<AddonModel | AuthorizedAccountModel | ConfiguredAddonModel | AddonCardModel | null>(null);
readonly showDangerButton = input<boolean>(false);
readonly isConnected = input<boolean>(false);
readonly hasAdminAccess = input<boolean>(false);

readonly actualAddon = computed(() => {
const actualCard = this.card();
Expand All @@ -50,8 +51,24 @@ export class AddonCardComponent {
return isConfiguredAddon(actualCard);
});

readonly canConfigure = computed(() => {
const isConfigured = this.isConfiguredAddon();
const hasAdmin = this.hasAdminAccess();

if (!isConfigured) return true;

return hasAdmin;
});

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

if (isConfigured) {
return 'settings.addons.form.buttons.configure';
}

return isConnected ? 'settings.addons.form.buttons.reconnect' : 'settings.addons.form.buttons.connect';
});

onConnectAddon(): void {
Expand Down
Loading