Skip to content

Only allow one open model alerts view#3461

Merged
shati-patel merged 4 commits intomainfrom
shati-patel/one-alerts-view
Mar 13, 2024
Merged

Only allow one open model alerts view#3461
shati-patel merged 4 commits intomainfrom
shati-patel/one-alerts-view

Conversation

@shati-patel
Copy link
Copy Markdown
Contributor

@shati-patel shati-patel commented Mar 12, 2024

There should only ever be one model alerts view open, so this PR adds some logic to check that we don't already have one! 👀

The second commit is a related tweak that makes sure we can't open the model alerts view until the variant analysis has kicked off. (This is similar to the MRVA results view, which only opens once the actual workflow run has been triggered, since there's nothing to show otherwise.)

Checklist

N/A—feature-flagged for internal use/testing 🏴

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@shati-patel shati-patel force-pushed the shati-patel/one-alerts-view branch from d7c8afe to 1241fbf Compare March 12, 2024 11:26
@shati-patel shati-patel marked this pull request as ready for review March 12, 2024 11:31
@shati-patel shati-patel requested a review from a team as a code owner March 12, 2024 11:31
Copy link
Copy Markdown
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

Generally looking good, just a question around where the information will be stored

export interface ModelEvaluationRun {
isPreparing: boolean;
variantAnalysisId: number | undefined;
isModelAlertsViewOpen?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we make this a non-optional boolean to avoid having to deal with undefined?

I'm in two minds about whether the ModelEvaluationRun domain entity is the right place to hold information around whether a view is open or not. It feels a bit wrong because it's not a property of the evaluation run, just some information around the user's modeling setup. So it could be information we have in the InternalDbModelingState instead. Any thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I agree that ModelEvaluationRun feels wrong 🤔 I hadn't thought of InternalDbModelingState, but will try adding it there instead!

Comment thread extensions/ql-vscode/src/model-editor/model-evaluator.ts Outdated
@shati-patel
Copy link
Copy Markdown
Contributor Author

Pushed a new commit to add isModelAlertsViewOpen to (Internal)DbModelingState instead. It works as expected (from testing manually), but I'm not 100% sure I've done things correctly about when to use public/private/internal... 🤔 😅

Copy link
Copy Markdown
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

LGTM!

selectedMethod: Method | undefined;
selectedUsage: Usage | undefined;
modelEvaluationRun: ModelEvaluationRun | undefined;
isModelAlertsViewOpen: boolean | undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we drop the possibility of this being undefined?

return this.getState(dbItem).isModelAlertsViewOpen ?? false;
}

public updateIsModelAlertsViewOpen(dbItem: DatabaseItem, isOpen: boolean) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we follow the pattern we use elsewhere for update methods?

@shati-patel shati-patel merged commit 84a8ffd into main Mar 13, 2024
@shati-patel shati-patel deleted the shati-patel/one-alerts-view branch March 13, 2024 14:05
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.

2 participants