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

Add flash messages when viewed model is deleted #5759

Closed
wants to merge 24 commits into from

Conversation

backspace
Copy link
Contributor

This is another approach to #5753, still a prototype. The flash message structure and CSS are hackishly taken from Vault and need to be refined.

backspace added 21 commits May 24, 2019 09:29
The element structure and CSS is taken from Vault; it’s
a hack-job inclusion that still needs to be generalised.
This is only applied to jobs:job:index at the moment as
the other places I tried it didn’t work… to be examined.
Unlike the job endpoint, the allocation endpoint doesn’t
404 when it’s been stopped, but instead times out. This
requires different handling. I’ve inquired whether it’s
possible to have the endpoint respond similarly.
This may need tweaking as the flash message refers to a
“node” rather than a client…??

This has the same timeout situation as an allocation, but
discussion suggests maybe that‘s not actually a problem.
This includes a hackish way to run watcher tests in testing.
There’s surely a better approach.

I’m actually unable to run the tests at all at the moment
so I’m only making this commit to run them in CI!
It’s definitely undesirable to have this kind of waiter in
the tests… hopefully there’s another way.
I’m leaning toward extracting more extensive flash message
tests into their own file or PR even, but for now I’m
doing it all here.
This will allow another flag to be passed in.
It feels a bit awkward to be reaching into the route and
controller like this in tests, but it seems preferable to
me over mutating a global flag in a semi-related service.
Copy link
Contributor

@DingoEatingFuzz DingoEatingFuzz left a comment

Choose a reason for hiding this comment

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

This is coming together!

One last note that didn't fit anywhere inline: the toast/flash notifications represent a new component and should be added to freestyle.

if (statusIs404 || errorIsEmptyResponse) {
this.flashMessages.warning(`This ${modelName} no longer exists`, { sticky: true });
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I recall talking about pushing this logic into the with-watchers by making these tasks evented.

Did that not pan out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that out in this branch, what do you think? There’s some awkwardness involving bundling the modelName along with the error because otherwise the error handler doesn’t know what to put in the flash message. Another approach would be to use the args on the task, as the model is passed in to perform, but given that the signature is id vs model, it seems questionable.

I also tried making it an encapsulated task so it could contain modelName for future reference, but that seemed to require passing in the Ember Data store because this would therefore be the task instance and not the containing model 😞

One significant problem is that the tests no longer pass:

image

That could be partially addressed by ignoring the uncaught exception, hopefully in a more targeted way to avoid how that burned me in the past.

BUT it’s not just that; the assertion that a flash message is displayed is also failing, despite me being able to see that it’s there 🤔 (that’s the inscrutable failed error 8 which I opened this PR to improve so we don’t need to write custom assertion failure messages)

I can hopefully address these problems but I wanted to check in on what you thought of the modelName weirdness and the general approach before sinking more time into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this could perhaps be revived as it’s not a huge change and would still be nice to have, maybe the above weirdness is a non-problem now 🤞

@@ -215,6 +216,42 @@ module('Acceptance | allocation detail', function(hooks) {
});
});

// This is a separate module only because of the watchInTesting adjustment, hopefully that can change
Copy link
Contributor

Choose a reason for hiding this comment

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

What is watchInTesting used for? It doesn't seem wired up to anything.


const controller = this.owner.lookup('controller:allocations/allocation');
const route = this.owner.lookup('route:allocations/allocation');
controller.watcher = route.watch.perform(controller.model, { throttle: 0, runInTests: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

As you know, these are distinctly not acceptance tests since they invoke methods on objects rather than treating the app like a black box.

I'm fine with running with this as-is and adding an overarching acceptance testing + watching task to the backlog.

To ramble for a minute...

I think the best solution will make use of either ember-concurrency-test-waiter or some abstraction over run.cancelTimers like I experimented with over here: d5e4117

The dream is to have a test that is easy to write, reads well, and works via a series of button clicks and waiting. Which is a tall order given the inner workings of Ember concurrency.

@@ -0,0 +1,76 @@
.global-flash {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are existing notification styles that at the very least the flash notifications should look like. Ideally they would use the same styles via some sass pattern or composition.

Base automatically changed from master to main March 8, 2021 19:25
@backspace backspace closed this May 19, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants