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

Deleting cards that have an error #2056

Merged

Conversation

jurgenwerk
Copy link
Contributor

@jurgenwerk jurgenwerk commented Jan 17, 2025

This PR:

  1. Adds an option to delete an error card when it's on the stack
image
  1. Fixes deleting such items from the index card (previously this wasn't working due to a card loading error - it wanted to load the card but this is not possible because the card has an error)
image

This needed a refactor in the card deletion logic where previously these functions were accepting a CardDef–but in case when card has an error we do not actually have a CardDef since the card cannot be loaded. So we simply pass down the card's id instead.

Copy link

github-actions bot commented Jan 17, 2025

Host Test Results

    1 files  ±0      1 suites  ±0   22m 20s ⏱️ +40s
731 tests +2  729 ✔️ +2  2 💤 ±0  0 ±0 
736 runs  +2  734 ✔️ +2  2 💤 ±0  0 ±0 

Results for commit 8db0daf. ± Comparison against base commit cc54e6e.

This pull request removes 2 and adds 4 tests. Note that renamed tests count towards both.
Chrome 131.0 ‑ Acceptance | operator mode tests: index card shows last known good state for instances that have an error
Chrome 131.0 ‑ Integration | operator-mode: it renders a card with an error that has a last known good state
Chrome 131.0 ‑ Acceptance | operator mode tests > card with an error that has a last known good state: can delete a card
Chrome 131.0 ‑ Acceptance | operator mode tests > card with an error that has a last known good state: index card shows last known good state for instances that have an error
Chrome 131.0 ‑ Integration | operator-mode > card with an error that has a last known good state: it has the ability to delete the card that has an error
Chrome 131.0 ‑ Integration | operator-mode > card with an error that has a last known good state: it renders a card with an error that has a last known good state

♻️ This comment has been updated with latest results.

const stackItem = here.allStackItems.find(
(item) => item.card === loadedCard,
);
// if is workspace index card, do not allow deletion
Copy link
Contributor Author

@jurgenwerk jurgenwerk Jan 20, 2025

Choose a reason for hiding this comment

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

We're not even showing a button to delete the card when the card is an index card, and that is covered with tests, so this check here is probably not needed.

@@ -172,27 +175,32 @@ export default class OperatorModeStateService extends Service {
}
}

async deleteCard(card: CardDef) {
async deleteCard(cardId: string) {
Copy link
Contributor Author

@jurgenwerk jurgenwerk Jan 20, 2025

Choose a reason for hiding this comment

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

the parameter changed from CardDef to a cardId because we want to support deleting a card that has an error, but in this case it is not possible to load the card so we only have its id. Card's id is the lowest common denonimator of a loaded card and the card's error response, so we use that.

@jurgenwerk jurgenwerk changed the title Deleting faulty cards Deleting cards that have an error Jan 20, 2025
@@ -152,6 +153,7 @@ export class RealmIndexQueryEngine {
errorDetail: instance.error,
scopedCssUrls,
lastKnownGoodHtml: instance.isolatedHtml ?? null,
cardTitle: instance.searchDoc?.title ?? null,
Copy link
Contributor Author

@jurgenwerk jurgenwerk Jan 20, 2025

Choose a reason for hiding this comment

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

I'm adding this so that we can show the card's title in the delete modal (when the card has an error):

image

@jurgenwerk jurgenwerk marked this pull request as ready for review January 20, 2025 09:45
@jurgenwerk jurgenwerk requested a review from a team January 20, 2025 09:47
@jurgenwerk jurgenwerk merged commit d00a7f3 into main Jan 20, 2025
47 checks passed
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.

3 participants