Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 802fcdb

Browse files
feat(#243): for the time being, published slides can't be deleted
1 parent bd9f958 commit 802fcdb

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

studio/src/app/components/editor/app-editor-toolbar/app-editor-toolbar.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {DeckDeckGoUtils} from '@deckdeckgo/utils';
88

99
import {IonControllerUtils} from '../../../utils/core/ion-controller-utils';
1010

11+
import {Deck} from '../../../models/data/deck';
12+
1113
import {ImageHelper} from '../../../helpers/editor/image.helper';
1214

1315
import {ToggleSlotUtils} from '../../../utils/editor/toggle-slot.utils';
@@ -19,6 +21,7 @@ import {ImageAction} from '../../../popovers/editor/app-image/image-action';
1921

2022
import {BusyService} from '../../../services/editor/busy/busy.service';
2123
import {AnonymousService} from '../../../services/editor/anonymous/anonymous.service';
24+
import {DeckEditorService} from '../../../services/editor/deck/deck-editor.service';
2225

2326
@Component({
2427
tag: 'app-editor-toolbar',
@@ -81,9 +84,16 @@ export class AppEditorToolbar {
8184

8285
@Event() signIn: EventEmitter<void>;
8386

87+
private deckEditorSubscription: Subscription;
88+
private deckEditorService: DeckEditorService;
89+
90+
@State()
91+
private deckPublished: boolean = false;
92+
8493
constructor() {
8594
this.busyService = BusyService.getInstance();
8695
this.anonymousService = AnonymousService.getInstance();
96+
this.deckEditorService = DeckEditorService.getInstance();
8797
}
8898

8999
async componentWillLoad() {
@@ -94,6 +104,10 @@ export class AppEditorToolbar {
94104
this.moveToolbarSubscription = this.moveToolbarSubject.pipe(debounceTime(250)).subscribe(async () => {
95105
await this.moveToolbar();
96106
});
107+
108+
this.deckEditorSubscription = this.deckEditorService.watch().subscribe(async (deck: Deck) => {
109+
this.deckPublished = deck && deck.data && deck.data.meta && deck.data.meta.published;
110+
});
97111
}
98112

99113
async componentDidLoad() {
@@ -109,6 +123,10 @@ export class AppEditorToolbar {
109123
this.moveToolbarSubscription.unsubscribe();
110124
}
111125

126+
if (this.deckEditorSubscription) {
127+
this.deckEditorSubscription.unsubscribe();
128+
}
129+
112130
this.removeWindowResize();
113131
}
114132

@@ -865,10 +883,15 @@ export class AppEditorToolbar {
865883
}
866884

867885
private renderDelete() {
868-
return <a onClick={() => this.deleteElement()} title="Delete"
869-
class={this.deckBusy && this.deckOrSlide ? "delete disabled" : "delete"}>
870-
<ion-icon name="trash"></ion-icon>
871-
</a>
886+
if (this.deckOrSlide && this.deckPublished) {
887+
// TODO: (#243) Currently we can't delete a published slide
888+
return <span style={{"margin-left": "auto"}}></span>;
889+
} else {
890+
return <a onClick={() => this.deleteElement()} title="Delete"
891+
class={this.deckBusy && this.deckOrSlide ? "delete disabled" : "delete"}>
892+
<ion-icon name="trash"></ion-icon>
893+
</a>
894+
}
872895
}
873896

874897
private renderColor() {

0 commit comments

Comments
 (0)