-
Notifications
You must be signed in to change notification settings - Fork 19
[FEAT] : Added dynamic initial values in create modal #23
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
7d8d7b0
1a58780
cca74eb
c4ec6cc
d8ce982
9bf47bb
3a5355d
bf658de
69818f2
a275aea
aed5898
8a4b62a
1c9b802
30f37ab
b4e19a8
a42ce1c
f28fd6e
ca43cde
8f85896
22cd3c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import { settings } from './src/config/settings'; | |
export class QuickRepliesApp extends App { | ||
private elementBuilder: ElementBuilder; | ||
private blockBuilder: BlockBuilder; | ||
public params: Array<string>; | ||
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) { | ||
super(info, logger, accessors); | ||
} | ||
|
@@ -141,6 +142,7 @@ export class QuickRepliesApp extends App { | |
http, | ||
persistence, | ||
modify, | ||
this.params, | ||
|
||
context, | ||
); | ||
|
||
|
@@ -160,6 +162,7 @@ export class QuickRepliesApp extends App { | |
http, | ||
persistence, | ||
modify, | ||
this.params, | ||
context, | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ By selecting quick replies instead of typing manually, agents/users can respond | |
- **`/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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add SS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add SS man why you are not making requested changes before asking for review. |
||
### Using Placeholders: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ export class CommandUtility implements ICommandUtility { | |
triggerId: this.triggerId, | ||
threadId: this.threadId, | ||
language, | ||
args: this.params, | ||
|
||
}); | ||
|
||
switch (this.params.length) { | ||
|
@@ -77,6 +78,11 @@ export class CommandUtility implements ICommandUtility { | |
break; | ||
} | ||
default: { | ||
const subCommand = this.params[0].toLowerCase(); | ||
|
||
if (subCommand === CommandParam.CREATE){ | ||
await this.handleSingleParam(handler) | ||
break; | ||
} | ||
await handler.sendDefault(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ export interface IHandler extends Omit<ICommandUtilityParams, 'params'> { | |
|
||
export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & { | ||
language: Language; | ||
args : string[]; | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ export class ExecuteActionButtonHandler { | |
protected readonly http: IHttp, | ||
protected readonly persistence: IPersistence, | ||
protected readonly modify: IModify, | ||
protected readonly params: string[] = [], | ||
context: UIKitActionButtonInteractionContext, | ||
) { | ||
this.context = context; | ||
|
@@ -56,6 +57,7 @@ export class ExecuteActionButtonHandler { | |
persis: this.persistence, | ||
triggerId, | ||
language, | ||
args: this.params, | ||
|
||
}); | ||
|
||
switch (actionId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ export class ExecuteBlockActionHandler { | |
protected readonly http: IHttp, | ||
protected readonly persistence: IPersistence, | ||
protected readonly modify: IModify, | ||
protected readonly params: string[] = [], | ||
|
||
context: UIKitBlockInteractionContext, | ||
) { | ||
this.context = context; | ||
|
@@ -102,6 +103,7 @@ export class ExecuteBlockActionHandler { | |
persis: this.persistence, | ||
triggerId, | ||
language, | ||
args: this.params, | ||
}); | ||
|
||
switch (actionId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ export class Handler implements IHandler { | |
public triggerId?: string; | ||
public threadId?: string; | ||
public language: Language; | ||
public args? : string[]; | ||
|
||
|
||
constructor(params: IHanderParams) { | ||
this.app = params.app; | ||
|
@@ -47,6 +48,8 @@ export class Handler implements IHandler { | |
this.triggerId = params.triggerId; | ||
this.threadId = params.threadId; | ||
this.language = params.language; | ||
this.args = params.args; | ||
|
||
|
||
const persistenceRead = params.read.getPersistenceReader(); | ||
this.roomInteractionStorage = new RoomInteractionStorage( | ||
params.persis, | ||
|
@@ -62,15 +65,22 @@ export class Handler implements IHandler { | |
this.read, | ||
this.persis, | ||
this.modify, | ||
this.sender, | ||
this.room, | ||
this.language, | ||
this.args ?? [], | ||
|
||
); | ||
|
||
if (modal instanceof Error) { | ||
this.app.getLogger().error(modal.message); | ||
return; | ||
} | ||
|
||
if (!modal) { | ||
|
||
this.app.getLogger().error('Modal is undefined. Cannot open surface view.'); | ||
return; | ||
} | ||
|
||
const triggerId = this.triggerId; | ||
|
||
if (triggerId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,45 @@ import { | |
} from '@rocket.chat/apps-engine/definition/uikit'; | ||
import { CreateModalEnum } from '../enum/modals/createModal'; | ||
import { Language, t } from '../lib/Translation/translation'; | ||
import { ReplyStorage } from '../storage/ReplyStorage'; | ||
import { sendNotification } from '../helper/notification'; | ||
|
||
export async function CreateReplyModal( | ||
app: QuickRepliesApp, | ||
user: IUser, | ||
read: IRead, | ||
persistence: IPersistence, | ||
modify: IModify, | ||
sender : IUser, | ||
room: IRoom, | ||
language: Language, | ||
): Promise<IUIKitSurfaceViewParam | Error> { | ||
args: string[], | ||
|
||
): Promise<IUIKitSurfaceViewParam | Error | void> { | ||
|
||
if (args.length > 1) { | ||
const replyName = args[1]; | ||
const replyBody = args.slice(2).join(' '); | ||
|
||
const replyStorage = new ReplyStorage(persistence, read.getPersistenceReader()); | ||
|
||
const result = await replyStorage.createReply(sender, replyName, replyBody, language); | ||
|
||
if (!result.success) { | ||
const errorMessage = `${t('Fail_Create_Reply', language, { | ||
name: sender.name, | ||
})} \n\n ${result.error}`; | ||
await sendNotification(read, modify, sender, room, { message: errorMessage }); | ||
return; | ||
} | ||
|
||
const successMessage = `${t('Success_Create_Reply', language, { | ||
name: sender.name, | ||
replyname: replyName, | ||
})}`; | ||
await sendNotification(read, modify, sender, room, { message: successMessage }); | ||
return; | ||
} | ||
|
||
|
||
const { elementBuilder, blockBuilder } = app.getUtils(); | ||
|
||
const blocks: InputBlock[] = []; | ||
|
@@ -91,4 +120,4 @@ export async function CreateReplyModal( | |
close, | ||
submit, | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this ?