summaryrefslogtreecommitdiff
path: root/source/features/hide-inactive-deployments.tsx
blob: 4f762c293e918140285ea30fd67619a9cd22fd0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';

// This feature doesn't need an active observer
function init(): void {
	// Selects all the deployments first so that we can leave the last one on the page
	const deployments = select.all('.js-socket-channel[data-url*="/partials/deployed_event/"]');
	deployments.pop(); // Don't hide the last deployment, even if it is inactive

	for (const deployment of deployments) {
		// TODO: Rewrite with :has selector, CSS-only feature
		if (select.exists('[title="Deployment Status Label: Inactive"]', deployment)) {
			deployment.remove();
		}
	}
}

void features.add(import.meta.url, {
	include: [
		pageDetect.isPRConversation,
	],
	awaitDomReady: true, // TODO: Rewrite with :has selector, CSS-only feature
	init,
});