Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add suspend/resume buttons #81

Merged
merged 5 commits into from
Apr 8, 2024

Conversation

dzsak
Copy link
Contributor

@dzsak dzsak commented Mar 27, 2024

No description provided.

@dzsak
Copy link
Contributor Author

dzsak commented Mar 27, 2024

Screenshot 2024-03-27 at 14 20 53

@dzsak dzsak linked an issue Mar 27, 2024 that may be closed by this pull request
Comment on lines 60 to 70
<div className="grid grid-cols-1 text-right space-y-1">
<button className="bg-transparent hover:bg-neutral-100 font-medium text-sm text-neutral-700 py-1 px-2 border border-neutral-300 rounded"
onClick={() => capacitorClient.suspend("kustomization", item.metadata.namespace, item.metadata.name)}
>
Suspend
</button>
<button className="bg-transparent hover:bg-neutral-100 font-medium text-sm text-neutral-700 py-1 px-2 border border-neutral-300 rounded"
onClick={() => capacitorClient.resume("kustomization", item.metadata.namespace, item.metadata.name)}
>
Resume
</button>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just add one button depending on the state of the object?
If resource is already suspended, show resume
If resource is not suspended, show suspend

Something like this:

      <div className="grid-cols-1 text-right">
        <button className="bg-transparent hover:bg-neutral-100 font-medium text-sm text-neutral-700 py-1 px-2 border border-neutral-300 rounded"
          onClick={() => {
            if (source.spec.suspend) {
              capacitorClient.resume("kustomization", source.metadata.namespace, source.metadata.name);
            } else {
              capacitorClient.suspend("kustomization", source.metadata.namespace, source.metadata.name);
            }
          }}
        >
          {source.spec.suspend ? "Resume" : "Suspend"}
        </button>
      </div>

Of course would be needed for the other resource types as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-08 at 19 01 45

@adberger
Copy link

On ReadyWidget.jsx we could expand the checks:

  ...
  if (resource.kind === 'GitRepository' || resource.kind === "OCIRepository" || resource.kind === "Bucket") {
    color = suspended ? "bg-yellow-400" : fetchFailed ? "bg-orange-400 animate-pulse" : reconciling ? "bg-blue-400 animate-pulse" : ready ? "bg-teal-400" : "bg-orange-400 animate-pulse"
    statusLabel = suspended ? "Suspended" : fetchFailed ? "Error" : reconciling ?  "Reconciling" : ready ? readyLabel : "Error"
    messageColor = fetchFailed ? "bg-orange-400" : reconciling ?  "text-neutral-600" : ready ? "text-neutral-600 field" : "bg-orange-400"
  } else {
    color = suspended ? "bg-yellow-400" : ready ? "bg-teal-400" : (reconciling || dependencyNotReady) && !stalled ? "bg-blue-400 animate-pulse" : "bg-orange-400 animate-pulse"
    statusLabel = suspended ? "Suspended" : ready ? readyLabel : (reconciling || dependencyNotReady) && !stalled ? "Reconciling" : "Error"
    messageColor = ready ? "text-neutral-600 field" : (reconciling || dependencyNotReady) && !stalled ? "text-neutral-600" : "bg-orange-400"
  }

  return (
    <div className="relative">
      <div className='font-medium text-neutral-700'>
        <span className={`absolute -left-4 top-1 rounded-full h-3 w-3 ${color} inline-block`}></span>
        <span>{statusLabel}</span>
        {readyCondition && !suspended &&
          <span className='ml-1'><TimeLabel title={exactDate} date={parsed} /> ago</span>
        }
      </div>
      ...

Same on Summary.jsx:

  ...
  const readyCount = resources.filter(resource => {
    const readyConditions = jp.query(resource.status, '$..conditions[?(@.type=="Ready")]');
    const ready = readyConditions.length === 1 && readyConditions[0].status === "True"
    return ready
  }).length
  const dependencyNotReadyCount = resources.filter(resource => {
    const readyConditions = jp.query(resource.status, '$..conditions[?(@.type=="Ready")]');
    const dependencyNotReady = readyConditions.length === 1 && readyConditions[0].reason === "DependencyNotReady"
    return dependencyNotReady
  }).length
  const reconcilingCount = resources.filter(resource => {
    const readyConditions = jp.query(resource.status, '$..conditions[?(@.type=="Reconciling")]');
    const ready = readyConditions.length === 1 && readyConditions[0].status === "True"
    return ready
  }).length
  const stalledCount = resources.filter(resource => {
    const readyConditions = jp.query(resource.status, '$..conditions[?(@.type=="Ready")]');
    const ready = readyConditions.length === 1 && readyConditions[0].status === "True"
    if (ready) {
      return false
    }
  ...

What do you think?

@laszlocph laszlocph merged commit a989ed2 into main Apr 8, 2024
1 check passed
@laszlocph laszlocph deleted the 78-enhancement-suspend-resume-buttons branch April 8, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add suspend / resume / reconcile buttons
3 participants