Skip to content

Commit

Permalink
fix(*): fix log to customer subscription transition workflow (#13914)
Browse files Browse the repository at this point in the history
ref: MANAGER-15056

Signed-off-by: David Arsène <[email protected]>
  • Loading branch information
darsene authored Nov 14, 2024
1 parent c622cd7 commit 081da67
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
27 changes: 14 additions & 13 deletions packages/manager/modules/log-to-customer/src/list/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class LogToCustomerListCtrl {
}

$onInit() {
this.loading = false;
this.streamLoading = {};
this.accountList = [];
this.streams = [];
this.streamSubscriptions = {};
Expand Down Expand Up @@ -58,13 +58,10 @@ export default class LogToCustomerListCtrl {
}

getStreamData() {
this.$q
return this.$q
.all([this.getSubscribedStreams(), this.getLogAccountStreams()])
.catch((error) => {
this.alertError(error?.data?.message);
})
.finally(() => {
this.loading = false;
});
}

Expand All @@ -82,50 +79,54 @@ export default class LogToCustomerListCtrl {

createLogSubscription(id) {
this.trackClick(this.trackingHits.SUBSCRIBE);
this.loading = id;
this.streamLoading[id] = true;
this.LogToCustomerService.post(this.logSubscriptionApiData.url, {
...this.logSubscriptionApiData.params,
streamId: id,
})
.then(({ data }) => {
this.LogToCustomerService.pollOperation(
return this.LogToCustomerService.pollOperation(
this.selectedAccount.serviceName,
data,
).then(() => {
this.Alerter.success(
this.$translate.instant('logs_list_subscription_success'),
);
this.getStreamData();
return this.getStreamData();
});
})
.catch(({ data }) => {
this.alertError(data.message);
this.loading = false;
})
.finally(() => {
this.streamLoading[id] = false;
});
}

deleteLogSubscription(streamId) {
this.trackClick(this.trackingHits.UNSUBSCRIBE);
this.loading = streamId;
this.streamLoading[streamId] = true;
const { subscriptionId } = this.streamSubscriptions[streamId];

this.LogToCustomerService.delete(
`${this.logSubscriptionApiData.url}/${subscriptionId}`,
)
.then(({ data }) => {
this.LogToCustomerService.pollOperation(
return this.LogToCustomerService.pollOperation(
this.selectedAccount.serviceName,
data,
).then(() => {
this.Alerter.success(
this.$translate.instant('logs_list_unsubscription_success'),
);
this.getStreamData();
return this.getStreamData();
});
})
.catch(({ data }) => {
this.alertError(data.message);
this.loading = false;
})
.finally(() => {
this.streamLoading[streamId] = false;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,24 @@
data-variant="secondary"
data-ng-if="!$ctrl.streamSubscriptions.hasOwnProperty($row.streamId)"
data-ng-click="$ctrl.createLogSubscription($row.streamId)"
data-disabled="$ctrl.streamLoading[$row.streamId]"
>
<span data-translate="list_button_subscribe"></span>
<oui-spinner
size="s"
data-ng-if="$ctrl.loading === $row.streamId"
data-ng-if="$ctrl.streamLoading[$row.streamId]"
></oui-spinner>
</oui-button>
<oui-button
data-variant="secondary"
loading="$ctrl.loading === $row.streamId"
data-ng-if="$ctrl.streamSubscriptions.hasOwnProperty($row.streamId)"
data-ng-click="$ctrl.deleteLogSubscription($row.streamId)"
data-disabled="$ctrl.streamLoading[$row.streamId]"
>
<span data-translate="list_button_unsubscribe"></span>
<oui-spinner
size="s"
data-ng-if="$ctrl.loading === $row.streamId"
data-ng-if="$ctrl.streamLoading[$row.streamId]"
></oui-spinner>
</oui-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class LogToCustomerTileCtrl {
this.loading = true;
this.streamSubscriptions = [];

this.$q
return this.$q
.all([this.getDataStreams(), this.getSubscribedStreams()])
.catch(({ data }) => {
this.alertError(data.message);
Expand Down Expand Up @@ -109,14 +109,14 @@ export default class LogToCustomerTileCtrl {
`${this.logSubscriptionUrl}/${subscription.subscriptionId}`,
)
.then(({ data }) => {
this.LogToCustomerService.pollOperation(
return this.LogToCustomerService.pollOperation(
subscription.serviceName,
data,
).then(() => {
this.Alerter.success(
this.$translate.instant('logs_list_unsubscription_success'),
);
this.loadStreams();
return this.loadStreams();
});
})
.catch(({ data }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
variant="link"
class="d-block mt-1"
data-ng-click="$ctrl.deleteLogSubscription(subscription)"
data-disabled="subscription.isLoading"
>
<span
data-ng-if="!subscription.isLoading"
data-translate="log_title_subscriptions_unsubscribe"
></span>
<oui-spinner
Expand Down

0 comments on commit 081da67

Please sign in to comment.