[FEAT] : Added dynamic initial values in create modal#23
[FEAT] : Added dynamic initial values in create modal#23not-meet wants to merge 20 commits intoRocketChat:mainfrom
Conversation
iam-vipin
left a comment
There was a problem hiding this comment.
There is alot of thing's that make no sense, try to make a PR that is clear and not bloated it, Ideally a PR should not have move then 200-300 line of code.
| IModify, | ||
| IPersistence, | ||
| IRead, | ||
| IHttp, |
| public persis: IPersistence; | ||
| public triggerId?: string; | ||
| public threadId?: string; | ||
| public app: QuickRepliesApp; |
| const subCommand = this.params[0].toLowerCase(); | ||
|
|
||
| if ( | ||
| subCommand === CommandParam.CREATE || |
There was a problem hiding this comment.
why are we creating team in all the command ? explain me this
| await this.handleSingleParam(handler); | ||
| break; | ||
| } | ||
| default: { |
There was a problem hiding this comment.
this should not be in default
| } | ||
| } | ||
| } | ||
| private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> { |
There was a problem hiding this comment.
we already handled default cases
| ); | ||
|
|
||
| if (args.length < 3) { | ||
| await sendUsageMessage(modify, room, sender); |
| return; | ||
| } | ||
| } | ||
| public app: QuickRepliesApp; |
There was a problem hiding this comment.
too much bloated code remove all these spaces
| room: IRoom, | ||
| user: IUser, | ||
| ): Promise<void> { | ||
| const text = '/quick-create <replyName> "<replyBody>"'; |
There was a problem hiding this comment.
why we have this code ?
iam-vipin
left a comment
There was a problem hiding this comment.
Make requested changes
9612a78 to
db79d2c
Compare
|
Hi @VipinDevelops so i reflected the changes you asked for and made them as per the requirements Note |
iam-vipin
left a comment
There was a problem hiding this comment.
There is still a lot of room for improvement basically you are repeating a lot of code and not following best practice.
| } | ||
| default: { | ||
| await handler.sendDefault(); | ||
| const subCommand = this.params[0].toLowerCase(); |
There was a problem hiding this comment.
you don't have to put this in switch case you can handle this in global
| } | ||
| } | ||
|
|
||
| private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> { |
There was a problem hiding this comment.
why dont use the function we already have for creating new replies ?
| return; | ||
| } | ||
|
|
||
| switch (args[0].toLowerCase()) { |
There was a problem hiding this comment.
why switch case in a function that is made to create a reply ?
| await handler.CreateQuickReply(args); | ||
| break; | ||
| } | ||
| default: { |
There was a problem hiding this comment.
this is the third place where you please .sendDefault() is there any other way to achieve check without repeating this
| return; | ||
| } | ||
| } | ||
| public async CreateQuickReply(args: string[]): Promise<void> { |
There was a problem hiding this comment.
we do have a method already for this
|
Also, update the documentation accordingly. |
db79d2c to
7d8d7b0
Compare
|
hey @VipinDevelops made changes as you asked..! now i believe the code looks much cleaner to be merged... |
|
Hey @not-meet Can you explain a little about changes you have made and use the code we have already for creating replies I have seen you writing some code again that already exist Either reuse the function we have or make something new that can be use in both old and new code. |
|
hey!! @VipinDevelops I wrote new logic instead of modifying the existing modal to avoid conflicts. While I understand the concern about calling the handler in the default switch case instead of passing it globally, doing so avoids issues where the global call still triggers the switch case unintentionally. |
|
Hey! @VipinDevelops i have made the changes as you asked! now i believe the code is much cleaner.... also added an example in readme to help user to get the context of quick create cli command! |
| export class QuickRepliesApp extends App { | ||
| private elementBuilder: ElementBuilder; | ||
| private blockBuilder: BlockBuilder; | ||
| public params: Array<string>; |
| http, | ||
| persistence, | ||
| modify, | ||
| this.params, |
| } | ||
| default: { | ||
| await handler.sendDefault(); | ||
| const subCommand = this.params[0].toLowerCase(); |
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| args : string[]; |
| room: IRoom, | ||
| language: Language, | ||
| ): Promise<IUIKitSurfaceViewParam | Error> { | ||
| args: string[], |
There was a problem hiding this comment.
why add this logic again we can just use the arguments to pass in the existing function
| break; | ||
| } | ||
| default: { | ||
| default: { |
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| args? : string[]; |
There was a problem hiding this comment.
why optional ? it will always be there
| this.modify, | ||
| this.room, | ||
| this.language, | ||
| this.args ?? [], |
| return; | ||
| } | ||
|
|
||
| if (!modal) { |
| language: Language, | ||
| ): Promise<IUIKitSurfaceViewParam | Error> { | ||
| args: string[], | ||
| ): Promise<IUIKitSurfaceViewParam | Error | void> { |
|
Again fix PR name , please follow the standard for everything you do |
iam-vipin
left a comment
There was a problem hiding this comment.
Alot of changes required
|
|
||
| const commandUtility = new CommandUtility(commandUtilityParams); | ||
| await commandUtility.resolveCommand(); | ||
| await new CommandUtility(commandUtilityParams).resolveCommand(); |
| label: labelReplyBody, | ||
| optional: false, | ||
| multiline: true, | ||
| initialValue: args.length > 2 ? args.slice(2).join(' ') : undefined, |
There was a problem hiding this comment.
i dont think that's how you should do this
| super(info, logger, accessors); | ||
| } | ||
|
|
||
| public setCommandParams(userId: string, params: string[]) { |
| persistence: IPersistence, | ||
| modify: IModify, | ||
| ) { | ||
| const userId = context.getInteractionData().user.id; |
| modify: IModify, | ||
| ) { | ||
| const userId = context.getInteractionData().user.id; | ||
| const storedParams = this.getCommandParams(userId); |
There was a problem hiding this comment.
why are you strong params makes no sense to me
| protected readonly http: IHttp, | ||
| protected readonly persistence: IPersistence, | ||
| protected readonly modify: IModify, | ||
| protected readonly params: ICommandUtilityParams['params'], |
| view, | ||
| language, | ||
| triggerId, | ||
| this.params |
| const name = nameStateValue ? nameStateValue.trim() : ''; | ||
| const body = bodyStateValue ? bodyStateValue.trim() : ''; | ||
|
|
||
| const argsName = params.length > 1 ? params[1] : undefined; |
There was a problem hiding this comment.
why undefined that should not be possible
|
|
||
| const argsName = params.length > 1 ? params[1] : undefined; | ||
| const argsBody = params.length > 2 ? params.slice(2).join(' ') : undefined; | ||
| const name = argsName ? argsName : nameStateValue ? nameStateValue.trim() : ''; |
There was a problem hiding this comment.
this ternary operator is doing simple thing in much complex way
| this.triggerId = params.triggerId; | ||
| this.threadId = params.threadId; | ||
| this.language = params.language; | ||
| this.args = params.args; |
|
hi! sorry for the delay for now i have changed the pr name and in the recent commit was just trying this approach, I will |
3f46624 to
bf658de
Compare
| - **`/quick ai`**: Use AI to generate replies | ||
| - **`/quick help`**: Get help with Quick Reply | ||
| - **`/qs <reply name>`**: Quickly search and send a reply by name | ||
| - **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message |
There was a problem hiding this comment.
put create command together , explain how double quotes works to name a reply
| break; | ||
| } | ||
| default: { | ||
| default: { |
| view.state?.[CreateModalEnum.REPLY_BODY_BLOCK_ID]?.[ | ||
| CreateModalEnum.REPLY_BODY_ACTION_ID | ||
| ]; | ||
| const nameStateValue = view.state && Object.values(view.state) |
There was a problem hiding this comment.
this code is so bad adding find don't make sense to me here and again you are not using enums , please find why enum are good and how we are using in this case.
| } | ||
|
|
||
| public async CreateReply(): Promise<void> { | ||
| const cliName = this.args?.[1] || ''; |
There was a problem hiding this comment.
could we give them better naems like initial name or something ? or can we just make one object that have both values
| - **`/quick ai`**: Use AI to generate replies | ||
| - **`/quick help`**: Get help with Quick Reply | ||
| - **`/qs <reply name>`**: Quickly search and send a reply by name | ||
| - **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message |
There was a problem hiding this comment.
double quotes ("") ? Explain double quote behavior here
| triggerId: this.triggerId, | ||
| threadId: this.threadId, | ||
| language, | ||
| args: this.params, |
There was a problem hiding this comment.
why not name it params only then ?
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| args? : string[]; |
There was a problem hiding this comment.
why optional ? it will always be there
| public triggerId?: string; | ||
| public threadId?: string; | ||
| public language: Language; | ||
| public args? : string[]; |
| } | ||
|
|
||
| public async CreateReply(): Promise<void> { | ||
| const initialReplyName = this.args?.[1] || ''; |
There was a problem hiding this comment.
initial values are optional why OR here ? just don't pass it if its not there
| text: label, | ||
| element: plainTextInputElement, | ||
| optional, | ||
| blockId, |
| modify: IModify, | ||
| room: IRoom, | ||
| language: Language, | ||
| initialReplyName: string, |
There was a problem hiding this comment.
we can make it a object but fine for now
iam-vipin
left a comment
There was a problem hiding this comment.
When you make requested changes also share about what you changed in comment or reply
|
|
||
| #### Example: | ||
| ```sh | ||
| /quick create "greeting" Hello! How have you been? |
There was a problem hiding this comment.
This is not what I ment
How double quotes make the multiple words a single text for body use
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| params?: string[]; |
|
hey @VipinDevelops i've added the comments with detailed explanation of what changes i have made |
iam-vipin
left a comment
There was a problem hiding this comment.
requested more changes
don't tag me before you reply to all the old messages
| #### Creating Quick Replies from Message Box | ||
| **`/quick create "<name>" <message>`**: Create a quick reply using the message box | ||
|
|
||
| When you use this command: | ||
| 1. A modal window opens automatically | ||
| 2. The name and replybody field is prefilled with your specified values | ||
| 3. Simply review and click the Submit button to save your quick reply | ||
|
|
||
| The command works as follows: | ||
| - The name must be enclosed in quotes `"..."` if it contains multiple words | ||
| - Everything after the name is treated as the message body | ||
| - Without quotes, only the first word would be taken as the name | ||
|
|
||
| #### Examples: | ||
| ```sh | ||
| # Single word name (quotes optional) | ||
| /quick create greeting Hello! How have you been? | ||
|
|
||
| # Multi-word name (quotes required) | ||
| /quick create "welcome message" Welcome to our channel! How can I help you? | ||
| ``` | ||
|
|
||
| Both examples will open a modal with the name and message already filled in. Just click Submit to save your quick reply, which can then be used with **`/qs <name>`**. | ||
|
|
There was a problem hiding this comment.
That is just to much for such simple thing
and can't we just do like
/quick create "you can use double quotes to write the name with spaces" you write everything else as a body ??
There was a problem hiding this comment.
this just looks like AI-generated markdown to me
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| params?: string[]; |
| public triggerId?: string; | ||
| public threadId?: string; | ||
| public language: Language; | ||
| public params?: string[]; |
|
I have also replied to the asked questions in the messages in the review section in each file still to ease it out why i added params as optional?
|
|
@VipinDevelops i was thinking about making a new pr for the same as this pr now has too many conversation messages and commits thus makes it a bit more clutterd and not easy to get through all the messages and conversation i am thinking if you allow me to make a new pr for this issue with the same commits and solution |
Just remove it if not needed why make it optional ? |
NO we won't make new PR's because of TOO MANY conversations |
iam-vipin
left a comment
There was a problem hiding this comment.
There are still a lot of changes needed for this.
We are just making it longer—try to fix it this time
| - **`/quick help`**: Get help with Quick Reply | ||
| - **`/qs <reply name>`**: Quickly search and send a reply by name | ||
| - **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message | ||
|
|
There was a problem hiding this comment.
add SS man why you are not making requested changes before asking for review.
| **`/quick create "<name>" <message>`**: "if your name has multiple words with space, use double quotes" and write everything else as a body! | ||
|
|
||
| Example: `/quick create "schedule meeting" let's have a quick meet in an hour!` | ||
|
|
There was a problem hiding this comment.
This is not what I meant.
Can you please avoid writing a lot in the README to explain really simple things?
|
|
||
| export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
| language: Language; | ||
| params?: string[]; |
| public triggerId?: string; | ||
| public threadId?: string; | ||
| public language: Language; | ||
| public params?: string[]; |
| text: label, | ||
| element: plainTextInputElement, | ||
| optional, | ||
| blockId, |
| modify: IModify, | ||
| room: IRoom, | ||
| language: Language, | ||
| initialReplyName?: string, |
There was a problem hiding this comment.
i said already we can make a new type for this or interface







Issue(s)
Closes #22
##This PR introduces a new feature that allows users to add the name and body of the new quick message from the rc rooms message box itself
Acceptance Criteria fulfillment
Proposed changes (including videos or screenshots)
/quick create "reply name" reply bodyto have the reply value in the modal
Demo
Screencast.from.2025-02-23.02-37-52.webm
here i have shown the demo of all three cases
up for any changes and learning :)