Skip to content

Commit

Permalink
Rework grafana event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Matsuoka committed Dec 6, 2024
1 parent 7d8b30f commit 186038a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/app/Recordings/RecordingActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Recording, Target } from '@app/Shared/Services/api.types';
import { NotificationCategory, Recording, Target } from '@app/Shared/Services/api.types';
import { NotificationsContext } from '@app/Shared/Services/Notifications.service';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
Expand Down Expand Up @@ -59,20 +59,17 @@ export const RecordingActions: React.FC<RecordingActionsProps> = ({ recording, u

const grafanaUpload = React.useCallback(() => {
notifications.info('Upload Started', `Recording "${recording.name}" uploading...`);
uploadFn();
addSubscription(
uploadFn()
.pipe(first())
.subscribe((success) => {
if (success) {
notifications.success('Upload Success', `Recording "${recording.name}" uploaded`);
context.api
.grafanaDashboardUrl()
.pipe(first())
.subscribe((url) => window.open(url, '_blank'));
}
}),
context.notificationChannel.messages(NotificationCategory.GrafanaUploadSuccess).subscribe(() => {
notifications.success('Upload Success', `Recording "${recording.name}" uploaded`);
context.api
.grafanaDashboardUrl()
.pipe(first())
.subscribe((url) => window.open(url, '_blank'));
}),
);
}, [addSubscription, notifications, context.api, recording, uploadFn]);
}, [addSubscription, notifications, context.api, context.notificationChannel, recording, uploadFn]);

const handleDownloadRecording = React.useCallback(() => {
context.api.downloadRecording(recording);
Expand Down

0 comments on commit 186038a

Please sign in to comment.