<commit_before>import { pick } from 'lodash-es';
import React, { useCallback } from 'react';
import { kilnSuspend } from '@urbit/api/hood';
import { AppList } from '../../components/AppList';
import { Button } from '../../components/Button';
import { Dialog, DialogClose, DialogContent, DialogTrigger } from '../../components/Dialog';
import { Elbow } from '../../components/icons/Elbow';
import api from '../../state/api';
import { useCharges } from '../../state/docket';
import { BaseBlockedNotification as BaseBlockedNotificationType } from '../../state/hark-types';

import { NotificationButton } from './NotificationButton';
import { disableDefault } from '../../state/util';

interface BaseBlockedNotificationProps {
  notification: BaseBlockedNotificationType;
}

export const RuntimeLagNotification = () => (
  <section
    className="notification pl-12 space-y-2 text-black bg-orange-50"
    aria-labelledby="runtime-lag"
  >
    <header id="system-updates-blocked" className="relative -left-8 space-y-2">
      <div className="flex space-x-2">
        <span className="inline-block w-6 h-6 bg-orange-500 rounded-full" />
        <span className="font-medium">Landscape</span>
      </div>
      <div className="flex space-x-2">
        <Elbow className="w-6 h-6 text-gray-300" />
        <h2 id="runtime-lag">The runtime blocked a System Update</h2>
      </div>
    </header>
    <div className="space-y-6">
      <p>
        In order to proceed with the System Update, you’ll need to upgrade the runtime. If you are
        using a hosted ship, you should contact your hosting provider.
      </p>
    </div>
  </section>
);

export const BaseBlockedNotification = ({ notification }: BaseBlockedNotificationProps) => {
  const { desks } = notification;
  const charges = useCharges();
  const blockedCharges = Object.values(pick(charges, desks));
  const count = blockedCharges.length;

  const handlePauseOTAs = useCallback(() => {}, []);

  const handleArchiveApps = useCallback(async () => {
    await Promise.all(desks.map((d) => api.poke(kilnSuspend(d))));
    // TODO: retrigger OTA?
  }, [desks]);

  return (
    <section
      className="notification pl-12 space-y-2 text-black bg-orange-50"
      aria-labelledby="system-updates-blocked"
    >
      <header id="system-updates-blocked" className="relative -left-8 space-y-2">
        <div className="flex space-x-2">
          <span className="inline-block w-6 h-6 bg-orange-500 rounded-full" />
          <span className="font-medium">Landscape</span>
        </div>
        <div className="flex space-x-2">
          <Elbow className="w-6 h-6 text-gray-300" />
          <h2 id="blocked-apps">The following ({count}) apps blocked a System Update:</h2>
        </div>
      </header>
      <AppList apps={blockedCharges} labelledBy="blocked-apps" size="xs" className="font-medium" />
      <div className="space-y-6">
        <p><commit_msg>grid: bump desk from ui<commit_after>import { pick } from 'lodash-es';
import React, { useCallback } from 'react';
import { kilnBump } from '@urbit/api/hood';
import { AppList } from '../../components/AppList';
import { Button } from '../../components/Button';
import { Dialog, DialogClose, DialogContent, DialogTrigger } from '../../components/Dialog';
import { Elbow } from '../../components/icons/Elbow';
import api from '../../state/api';
import { useCharges } from '../../state/docket';
import { BaseBlockedNotification as BaseBlockedNotificationType } from '../../state/hark-types';

import { NotificationButton } from './NotificationButton';
import { disableDefault } from '../../state/util';

interface BaseBlockedNotificationProps {
  notification: BaseBlockedNotificationType;
}

export const RuntimeLagNotification = () => (
  <section
    className="notification pl-12 space-y-2 text-black bg-orange-50"
    aria-labelledby="runtime-lag"
  >
    <header id="system-updates-blocked" className="relative -left-8 space-y-2">
      <div className="flex space-x-2">
        <span className="inline-block w-6 h-6 bg-orange-500 rounded-full" />
        <span className="font-medium">Landscape</span>
      </div>
      <div className="flex space-x-2">
        <Elbow className="w-6 h-6 text-gray-300" />
        <h2 id="runtime-lag">The runtime blocked a System Update</h2>
      </div>
    </header>
    <div className="space-y-6">
      <p>
        In order to proceed with the System Update, you’ll need to upgrade the runtime. If you are
        using a hosted ship, you should contact your hosting provider.
      </p>
    </div>
  </section>
);

export const BaseBlockedNotification = ({ notification }: BaseBlockedNotificationProps) => {
  const { desks } = notification;
  const charges = useCharges();
  const blockedCharges = Object.values(pick(charges, desks));
  const count = blockedCharges.length;

  const handlePauseOTAs = useCallback(() => {}, []);

  const handleArchiveApps = useCallback(async () => {
    api.poke(kilnBump(true));
  }, []);

  return (
    <section
      className="notification pl-12 space-y-2 text-black bg-orange-50"
      aria-labelledby="system-updates-blocked"
    >
      <header id="system-updates-blocked" className="relative -left-8 space-y-2">
        <div className="flex space-x-2">
          <span className="inline-block w-6 h-6 bg-orange-500 rounded-full" />
          <span className="font-medium">Landscape</span>
        </div>
        <div className="flex space-x-2">
          <Elbow className="w-6 h-6 text-gray-300" />
          <h2 id="blocked-apps">The following ({count}) apps blocked a System Update:</h2>
        </div>
      </header>
      <AppList apps={blockedCharges} labelledBy="blocked-apps" size="xs" className="font-medium" />
      <div className="space-y-6">
        <p>
{'fraction_non_alphanumeric': 0.15628794449262792, 'fraction_numerical': 0.015264527320034691, 'mean_word_length': 3.1362984218077474, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 80, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387054', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1738, 'n_words': 429}