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

Admin notifications #36

Merged
merged 13 commits into from
Sep 14, 2019
Merged

Conversation

sakeerthy
Copy link
Contributor

Created pull request to see conflicts easier, not ready for review.

Suneeth Keerthy added 3 commits August 28, 2019 14:19
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Suneeth Keerthy added 2 commits August 28, 2019 15:20
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Suneeth Keerthy added 2 commits September 5, 2019 16:10
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
this.notificationCache.push(notification);
for (let i = 0; i < this.handlers.length; i++) {
this.handlers[i].handleMessageAdded();
_setURL(url: string): void {
Copy link
Member

@1000TurquoisePogs 1000TurquoisePogs Sep 6, 2019

Choose a reason for hiding this comment

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

This should be made more tamper-proof. If you put a var at the top of the file, outside the class, which is false but made true when _setURL is called for the first time, then you can keep url locally here rather than assigning it to this.url, and all future calls to _setURL can be made to fail on purpose due to checking that you already id setURL once.

Copy link
Member

Choose a reason for hiding this comment

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

Update: please just change this.ws to 'let ws' so it is private.

Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
getAll(): Notification[] | void;
getAllByCategory(type: MVDHosting.NotificationType): Notification[] | void;
export interface ZoweNotificationManagerInterface {
push(notification: ZoweNotification): void;
Copy link
Member

@1000TurquoisePogs 1000TurquoisePogs Sep 11, 2019

Choose a reason for hiding this comment

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

get rid of push, updateHandlers, and removeFromCache
Instead, do this

  • notify(message): number = you give it a message, and it notifies handlers that the message has been added
  • serverNotify(message): promise = this goes to the server, so you dont really get a number, but you do need to know if you succeed or not.
  • dismissNotification(id: number) = notifies handlers that the message has been dismissed by the user
  • make a removeMessageHandler since you had an addMessageHandler

Copy link
Member

@1000TurquoisePogs 1000TurquoisePogs left a comment

Choose a reason for hiding this comment

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

Refactor this a bit so that notifications can be local, not touching the server, and that people can choose ot directly touch the notification cache, and that people can be notificed of cache item removal, and that people can unsubscribe entirely rather than just subscribe.

export interface NotificationWatcher {
handleMessageAdded(): void;
export interface ZoweNotificationWatcher {
handleMessageAdded(data: any, index: number): void;
Copy link
Member

Choose a reason for hiding this comment

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

Add handleMessageRemoved

// }

push(notification: ZoweNotification): void {
this.ws.send(JSON.stringify(notification))
Copy link
Member

Choose a reason for hiding this comment

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

Change this, there should be no ws.send in this file

Suneeth Keerthy added 2 commits September 12, 2019 13:21
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>

createNotification(title: string, message: string, type: number, plugin: string, config?: any): ZoweNotification {
let notification = new ZoweNotification(this.idCount, title, message, type, plugin, config)
this.idCount = this.idCount + 1;
Copy link
Member

Choose a reason for hiding this comment

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

You can allow people to call this function but they should know it does not include an ID because it is meant to be used by notify.

addMessageHandler(object: ZoweNotificationWatcher): void;
removeMessageHandler(object: ZoweNotificationWatcher): void;
}

export interface ZoweNotificationWatcher {
handleMessageAdded(data: any, index: number): void;
Copy link
Member

Choose a reason for hiding this comment

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

This should be "id" since the other one is too. "index" has a similar but different meaning


constructor(title: string, message: string, type: MVDHosting.ZoweNotificationType, plugin: string, config?: any) {
constructor(id: number, title: string, message: string, type: MVDHosting.ZoweNotificationType, plugin: string, config?: any) {
Copy link
Member

Choose a reason for hiding this comment

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

Need a note that id is "optional" because it will be filled in by the framework later, but at the time the manager broadcasts this object it WILL have an id.

Suneeth Keerthy added 3 commits September 13, 2019 16:21
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
Signed-off-by: Suneeth Keerthy <skeerthy@rocketsoftware.com>
@1000TurquoisePogs 1000TurquoisePogs merged commit f5084d9 into zowe:staging Sep 14, 2019
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