diff --git a/VERSION b/VERSION index 7b52f5e517..731b95d7fc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.35.0 +0.35.1 diff --git a/cli/pkg/helm/helm.go b/cli/pkg/helm/helm.go index 8c0172c59f..e4a75d4682 100644 --- a/cli/pkg/helm/helm.go +++ b/cli/pkg/helm/helm.go @@ -79,7 +79,7 @@ func (h *Helm) Setup() error { } func (h *Helm) InstallCharts() error { - chartURL := "https://airy-core-helm-charts.s3.amazonaws.com/stable/airy-0.33.0.tgz" + chartURL := "https://airy-core-helm-charts.s3.amazonaws.com/stable/airy-" + h.version + ".tgz" return h.runHelm(append([]string{"install", "--values", "/apps/config/airy-config-map.yaml", "--namespace", h.namespace, diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index 4d160d770c..2870bac4a2 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -3,53 +3,83 @@ title: Changelog sidebar_label: 📝 Changelog --- -## 0.35.0 - -#### Changes - -- [[#2503](https://github.com/airyhq/airy/issues/2503)] Add capability for resource limits for components [[#2541](https://github.com/airyhq/airy/pull/2541)] - -#### 🚀 Features - -- Custom message colors chatplugin + Documentation [[#2585](https://github.com/airyhq/airy/pull/2585)] -- [[#2108](https://github.com/airyhq/airy/issues/2108)] render attachments via whatsapp [[#2574](https://github.com/airyhq/airy/pull/2574)] -- [[#2518](https://github.com/airyhq/airy/issues/2518)] Add terraform code for core deployment [[#2555](https://github.com/airyhq/airy/pull/2555)] -- [[#2563](https://github.com/airyhq/airy/issues/2563)] Allow for disabling emojis in the chatplugin [[#2564](https://github.com/airyhq/airy/pull/2564)] -- [[#2560](https://github.com/airyhq/airy/issues/2560)] Dev\_cli.sh fails to apply the config [[#2561](https://github.com/airyhq/airy/pull/2561)] -- Print airy core version with version command [[#2537](https://github.com/airyhq/airy/pull/2537)] - -#### 🐛 Bug Fixes - -- fixed input accept formatting [[#2584](https://github.com/airyhq/airy/pull/2584)] -- [[#2576](https://github.com/airyhq/airy/issues/2576)] Render Survey response Google Business Messages [[#2578](https://github.com/airyhq/airy/pull/2578)] -- [[#2544](https://github.com/airyhq/airy/issues/2544)] Include the analytics demo files in the jupyter hub [[#2545](https://github.com/airyhq/airy/pull/2545)] -- [[#2557](https://github.com/airyhq/airy/issues/2557)] Fix jumping conversationlist [[#2558](https://github.com/airyhq/airy/pull/2558)] -- [[#2548](https://github.com/airyhq/airy/issues/2548)] Use the cli with helm [[#2551](https://github.com/airyhq/airy/pull/2551)] -- [[#2511](https://github.com/airyhq/airy/issues/2511)] Fix Airy status command [[#2542](https://github.com/airyhq/airy/pull/2542)] - -#### 📚 Documentation +## 0.35.1 -- [[#2511](https://github.com/airyhq/airy/issues/2511)] Fix docs for helm upgrade [[#2547](https://github.com/airyhq/airy/pull/2547)] - -#### 🧰 Maintenance - -- Bump @types/react-dom from 17.0.10 to 17.0.11 [[#2572](https://github.com/airyhq/airy/pull/2572)] -- Bump style-loader from 3.3.0 to 3.3.1 [[#2573](https://github.com/airyhq/airy/pull/2573)] -- Bump cypress from 8.6.0 to 8.7.0 [[#2567](https://github.com/airyhq/airy/pull/2567)] -- Bump babel-loader from 8.2.2 to 8.2.3 [[#2568](https://github.com/airyhq/airy/pull/2568)] -- Bump @types/react from 17.0.20 to 17.0.34 [[#2553](https://github.com/airyhq/airy/pull/2553)] -- Bump sass from 1.43.2 to 1.43.4 [[#2565](https://github.com/airyhq/airy/pull/2565)] -- Bump node-fetch from 2.6.2 to 3.0.0 [[#2450](https://github.com/airyhq/airy/pull/2450)] -- Bump html-webpack-plugin from 5.3.2 to 5.5.0 [[#2552](https://github.com/airyhq/airy/pull/2552)] -- Bump prettier from 2.3.2 to 2.4.1 [[#2532](https://github.com/airyhq/airy/pull/2532)] - -#### Airy CLI +#### 🚀 Features + +- [[#2586](https://github.com/airyhq/airy/issues/2586)] Terraform core module has wrong Helm link [[#2587](https://github.com/airyhq/airy/pull/2587)] +- [[#2119](https://github.com/airyhq/airy/issues/2119)] Send/render attachments chatplugin [[#2603](https://github.com/airyhq/airy/pull/2603)] + +#### 🐛 Bug Fixes + +- [[#2605](https://github.com/airyhq/airy/issues/2605)] Fix predefined cli version [[#2607](https://github.com/airyhq/airy/pull/2607)] +- [[#2591](https://github.com/airyhq/airy/issues/2591)] Inbox counter not updating properly [[#2606](https://github.com/airyhq/airy/pull/2606)] +- [[#2536](https://github.com/airyhq/airy/issues/2536)] Fix chatplugin customization bug [[#2592](https://github.com/airyhq/airy/pull/2592)] + +#### 📚 Documentation + +- [[#1294](https://github.com/airyhq/airy/issues/1294)] Add monitoring docs [[#2569](https://github.com/airyhq/airy/pull/2569)] + +#### 🧰 Maintenance + +- Bump @babel/core from 7.15.8 to 7.16.0 [[#2595](https://github.com/airyhq/airy/pull/2595)] +- Bump redux from 4.1.1 to 4.1.2 [[#2566](https://github.com/airyhq/airy/pull/2566)] +- Bump react-i18next from 11.12.0 to 11.14.2 [[#2581](https://github.com/airyhq/airy/pull/2581)] +- Bump eslint-plugin-react from 7.26.1 to 7.27.0 [[#2588](https://github.com/airyhq/airy/pull/2588)] + +#### Airy CLI + +You can download the Airy CLI for your operating system from the following links: + +[MacOS](https://airy-core-binaries.s3.amazonaws.com/0.35.1/darwin/amd64/airy) +[Linux](https://airy-core-binaries.s3.amazonaws.com/0.35.1/linux/amd64/airy) +[Windows](https://airy-core-binaries.s3.amazonaws.com/0.35.1/windows/amd64/airy.exe) -You can download the Airy CLI for your operating system from the following links: +## 0.35.0 -[MacOS](https://airy-core-binaries.s3.amazonaws.com/0.34.1/darwin/amd64/airy) -[Linux](https://airy-core-binaries.s3.amazonaws.com/0.34.1/linux/amd64/airy) -[Windows](https://airy-core-binaries.s3.amazonaws.com/0.34.1/windows/amd64/airy.exe) +#### 🚀 Features + +- [[#2455](https://github.com/airyhq/airy/issues/2455)] Custom message colors chatplugin [[#2585](https://github.com/airyhq/airy/pull/2585)] +- [[#2108](https://github.com/airyhq/airy/issues/2108)] Render attachments via whatsapp [[#2574](https://github.com/airyhq/airy/pull/2574)] +- [[#2518](https://github.com/airyhq/airy/issues/2518)] Add terraform code for core deployment [[#2555](https://github.com/airyhq/airy/pull/2555)] +- [[#2563](https://github.com/airyhq/airy/issues/2563)] Allow for disabling emojis in the chatplugin [[#2564](https://github.com/airyhq/airy/pull/2564)] +- [[#2560](https://github.com/airyhq/airy/issues/2560)] Dev_cli.sh fails to apply the config [[#2561](https://github.com/airyhq/airy/pull/2561)] +- [[#2537](https://github.com/airyhq/airy/issues/2537)] Print airy core version with version command [[#2537](https://github.com/airyhq/airy/pull/2537)] +- [[#2503](https://github.com/airyhq/airy/issues/2503)] Add capability for resource limits for components [[#2541](https://github.com/airyhq/airy/pull/2541)] + +#### 🐛 Bug Fixes + +- [[#2583](https://github.com/airyhq/airy/issues/2583)] Fixed input accept formatting [[#2584](https://github.com/airyhq/airy/pull/2584)] +- [[#2576](https://github.com/airyhq/airy/issues/2576)] Render Survey response Google Business Messages [[#2578](https://github.com/airyhq/airy/pull/2578)] +- [[#2544](https://github.com/airyhq/airy/issues/2544)] Include the analytics demo files in the jupyter hub [[#2545](https://github.com/airyhq/airy/pull/2545)] +- [[#2557](https://github.com/airyhq/airy/issues/2557)] Fix jumping conversationlist [[#2558](https://github.com/airyhq/airy/pull/2558)] +- [[#2548](https://github.com/airyhq/airy/issues/2548)] Use the cli with helm [[#2551](https://github.com/airyhq/airy/pull/2551)] +- [[#2511](https://github.com/airyhq/airy/issues/2511)] Fix Airy status command [[#2542](https://github.com/airyhq/airy/pull/2542)] + +#### 📚 Documentation + +- [[#2511](https://github.com/airyhq/airy/issues/2511)] Fix docs for helm upgrade [[#2547](https://github.com/airyhq/airy/pull/2547)] +- [[#2455](https://github.com/airyhq/airy/issues/2455)] Documentation for custom message colors chatplugin [[#2585](https://github.com/airyhq/airy/pull/2585)] + +#### 🧰 Maintenance + +- Bump @types/react-dom from 17.0.10 to 17.0.11 [[#2572](https://github.com/airyhq/airy/pull/2572)] +- Bump style-loader from 3.3.0 to 3.3.1 [[#2573](https://github.com/airyhq/airy/pull/2573)] +- Bump cypress from 8.6.0 to 8.7.0 [[#2567](https://github.com/airyhq/airy/pull/2567)] +- Bump babel-loader from 8.2.2 to 8.2.3 [[#2568](https://github.com/airyhq/airy/pull/2568)] +- Bump @types/react from 17.0.20 to 17.0.34 [[#2553](https://github.com/airyhq/airy/pull/2553)] +- Bump sass from 1.43.2 to 1.43.4 [[#2565](https://github.com/airyhq/airy/pull/2565)] +- Bump node-fetch from 2.6.2 to 3.0.0 [[#2450](https://github.com/airyhq/airy/pull/2450)] +- Bump html-webpack-plugin from 5.3.2 to 5.5.0 [[#2552](https://github.com/airyhq/airy/pull/2552)] +- Bump prettier from 2.3.2 to 2.4.1 [[#2532](https://github.com/airyhq/airy/pull/2532)] + +#### Airy CLI + +You can download the Airy CLI for your operating system from the following links: + +[MacOS](https://airy-core-binaries.s3.amazonaws.com/0.35.0/darwin/amd64/airy) +[Linux](https://airy-core-binaries.s3.amazonaws.com/0.35.0/linux/amd64/airy) +[Windows](https://airy-core-binaries.s3.amazonaws.com/0.35.0/windows/amd64/airy.exe) ## 0.34.0 @@ -1184,61 +1214,3 @@ You can download the Airy CLI for your operating system from the following links [Linux](https://airy-core-binaries.s3.amazonaws.com/0.14.0/linux/amd64/airy) [Windows](https://airy-core-binaries.s3.amazonaws.com/0.14.0/windows/amd64/airy.exe) -## 0.13.0 - -#### Changes -- Bump typesafe-actions from 4.4.2 to 5.1.0 [[#1210](https://github.com/airyhq/airy/pull/1210)] -- [[#783](https://github.com/airyhq/airy/issues/783)] Introduce changelog [[#1221](https://github.com/airyhq/airy/pull/1221)] -- Bump yargs-parser from 5.0.0 to 5.0.1 [[#1213](https://github.com/airyhq/airy/pull/1213)] -- Bump react-dom from 16.12.0 to 16.14.0 [[#1188](https://github.com/airyhq/airy/pull/1188)] -- [[#773](https://github.com/airyhq/airy/issues/773)] change searchbar to the left [[#1192](https://github.com/airyhq/airy/pull/1192)] - -#### 🚀 Features -- [[#1247](https://github.com/airyhq/airy/issues/1247)] Optional variables for templates creation [[#1248](https://github.com/airyhq/airy/pull/1248)] -- [[#656](https://github.com/airyhq/airy/issues/656)] Enable users to connect via Twilio Sms and Whatsapp [[#1223](https://github.com/airyhq/airy/pull/1223)] -- [[#659](https://github.com/airyhq/airy/issues/659)] Enable to connect via facebook [[#1130](https://github.com/airyhq/airy/pull/1130)] -- [[#871](https://github.com/airyhq/airy/issues/871)] Httpclient methods need return value [[#1199](https://github.com/airyhq/airy/pull/1199)] -- [[#868](https://github.com/airyhq/airy/issues/868)] Templates manager [[#1123](https://github.com/airyhq/airy/pull/1123)] -- [[#1228](https://github.com/airyhq/airy/issues/1228)] Scope templates list by source type [[#1230](https://github.com/airyhq/airy/pull/1230)] -- [[#1204](https://github.com/airyhq/airy/issues/1204)] Add sourceType to templates API [[#1208](https://github.com/airyhq/airy/pull/1208)] -- [[#1047](https://github.com/airyhq/airy/issues/1047)] Chatplugin testing [[#1087](https://github.com/airyhq/airy/pull/1087)] -- [[#1022](https://github.com/airyhq/airy/issues/1022)] Change ingress hostnames and deploy traefik ingress controller [[#1122](https://github.com/airyhq/airy/pull/1122)] -- [[#1055](https://github.com/airyhq/airy/issues/1055)] Expired Websocket Connection [[#1181](https://github.com/airyhq/airy/pull/1181)] - -#### 🐛 Bug Fixes -- [[#1236](https://github.com/airyhq/airy/issues/1236)] Fixed issues with filter by channel [[#1253](https://github.com/airyhq/airy/pull/1253)] -- [[#1249](https://github.com/airyhq/airy/issues/1249)]fixed templates modal and fixed type template with api change [[#1251](https://github.com/airyhq/airy/pull/1251)] -- [[#1241](https://github.com/airyhq/airy/issues/1241)] Fix chatplugin ui path collision. Follow up fix. [[#1245](https://github.com/airyhq/airy/pull/1245)] -- [[#1241](https://github.com/airyhq/airy/issues/1241)] Fix chatplugin ui path collision [[#1243](https://github.com/airyhq/airy/pull/1243)] -- [[#1018](https://github.com/airyhq/airy/issues/1018)]Fix Golang dependencies, upgrade Gazelle [[#1231](https://github.com/airyhq/airy/pull/1231)] -- [[#1217](https://github.com/airyhq/airy/issues/1217)] Make validation work for auth app [[#1225](https://github.com/airyhq/airy/pull/1225)] -- [[#677](https://github.com/airyhq/airy/issues/677)] add missing ingress definition for suggest replies endpoint [[#1224](https://github.com/airyhq/airy/pull/1224)] -- [[#1214](https://github.com/airyhq/airy/issues/1214)] Duplicate messages in the redux store [[#1216](https://github.com/airyhq/airy/pull/1216)] -- [[#1205](https://github.com/airyhq/airy/issues/1205)] Fix update deps command and the gazelle repositories [[#1209](https://github.com/airyhq/airy/pull/1209)] -- Fix chat plugin build by upgrading bazel-tools #2 [[#1203](https://github.com/airyhq/airy/pull/1203)] -- Fix chatplugin build by upgrading bazel-tools [[#1202](https://github.com/airyhq/airy/pull/1202)] -- [[#1047](https://github.com/airyhq/airy/issues/1047)] Fix ui baseUrl [[#1200](https://github.com/airyhq/airy/pull/1200)] -- [[#1174](https://github.com/airyhq/airy/issues/1174)] Follow up of the follow up of the fix [[#1198](https://github.com/airyhq/airy/pull/1198)] -- [[#1174](https://github.com/airyhq/airy/issues/1174)] Follow up fix to bug introduced by PR #1177 [[#1196](https://github.com/airyhq/airy/pull/1196)] -- [[#1101](https://github.com/airyhq/airy/issues/1101)] Filtering by channel not functioning [[#1194](https://github.com/airyhq/airy/pull/1194)] - -#### 📚 Documentation -- More readable examples [[#1233](https://github.com/airyhq/airy/pull/1233)] -- Chatplugin overview section [[#1207](https://github.com/airyhq/airy/pull/1207)] -- [[#1105](https://github.com/airyhq/airy/issues/1105)] New structure for chatplugin docs [[#1180](https://github.com/airyhq/airy/pull/1180)] - -#### 🧰 Maintenance -- Bump @stomp/stompjs from 6.0.0 to 6.1.0 [[#1227](https://github.com/airyhq/airy/pull/1227)] -- [[#1197](https://github.com/airyhq/airy/issues/1197)] Rename chat\_plugin to chatplugin everywhere [[#1234](https://github.com/airyhq/airy/pull/1234)] -- Bump @bazel/typescript from 3.2.1 to 3.2.2 [[#1187](https://github.com/airyhq/airy/pull/1187)] -- Bump copy-webpack-plugin from 5.1.1 to 6.4.1 [[#1158](https://github.com/airyhq/airy/pull/1158)] -- [[#1183](https://github.com/airyhq/airy/issues/1183)] Bring back the prettier config [[#1184](https://github.com/airyhq/airy/pull/1184)] - -#### Airy CLI - -You can download the Airy CLI for your operating system from the following links: - -[MacOS](https://airy-core-binaries.s3.amazonaws.com/0.13.0/darwin/amd64/airy) -[Linux](https://airy-core-binaries.s3.amazonaws.com/0.13.0/linux/amd64/airy) -[Windows](https://airy-core-binaries.s3.amazonaws.com/0.13.0/windows/amd64/airy.exe) - diff --git a/docs/docs/guides/operations.md b/docs/docs/guides/monitoring.md similarity index 50% rename from docs/docs/guides/operations.md rename to docs/docs/guides/monitoring.md index 25a1781f99..088861d504 100644 --- a/docs/docs/guides/operations.md +++ b/docs/docs/guides/monitoring.md @@ -1,23 +1,23 @@ --- -title: How to monitor Airy Core -sidebar_label: Operations +title: Monitoring +sidebar_label: Monitoring --- ## Why Prometheus -Prometheus has become the mainstream monitoring tool of choice in the container -and microservice world. +Prometheus has become the mainstream open source monitoring tool of choice in +the container and microservice world. It provides ready-to-use [Exporters](https://prometheus.io/docs/instrumenting/exporters/) for all services that our system provides and implements a pull mechanism that is better suited for microservice architecture. -Furthermore, it supports additional components like the [Alert +Furthermore, it supports additional features like the [Alert Manager](https://prometheus.io/docs/alerting/latest/alertmanager/), [a query language](https://prometheus.io/docs/prometheus/latest/querying/basics/) to -retrieve the data and visualization tools like +retrieve the data and the visualization tool [Grafana](https://prometheus.io/docs/visualization/grafana/) ![image](https://user-images.githubusercontent.com/54705263/111768039-b2772200-88a7-11eb-9635-020895eb0c72.png) @@ -40,18 +40,26 @@ helm install prometheus prometheus-community/kube-prometheus-stack ### Customizing Prometheus +In this section you can customize the Prometheus chart by changing the defaults +in `infrastructure/tools/prometheus/values.yaml` to ones that suite your +requirements. + To access Prometheus, Grafana and Alertmanager from outside the cluster you have -to put your hostname in the respective `hosts: []` variable in -`infrastructure/tools/prometheus/values.yaml` and then create the Kubernetes ingress with: +to put your hostname in the respective `hosts: []` variable. -`helm upgrade prometheus --values infrastructure/tools/prometheus/values.yaml` +In the case that you make Grafana publicly accessible you should also set the +`adminPassword` to something secure. + +You can apply those changes by running: -Now you can access Prometheus under `/prometheus`. +`helm upgrade prometheus --values infrastructure/tools/prometheus/values.yaml` ### Grafana Dashboards [Grafana](https://grafana.com/) is a very powerful visualization tool which can -be used for all sorts of dashboard and monitoring requirements. +be used for all sorts of dashboarding and monitoring tasks. + +For Grafana there is one more step to do before you can access it. `k edit cm prometheus-grafana` @@ -62,19 +70,29 @@ be used for all sorts of dashboard and monitoring requirements. serve_from_sub_path = true ``` -Access Grafana under `/grafana` and login with the -`adminPassword` you set in the `values.yaml`. +Access Grafana under `/grafana` and login with the `adminPassword` you set in +the `values.yaml`. #### Access Predefined Dashboards If the `defaultDashboardsEnabled` is set to true you can find the default Kubernetes dashboards under `/grafana/dashboards` -For the spring apps we recommend to import this -(dashboard)[https://grafana.com/grafana/dashboards/12464]. +The Grafana website provides a lot more dashboards that can be added to your +instance by +[importing](https://grafana.com/docs/grafana/latest/dashboards/export-import/#import-dashboard) +them. + +Here is a list of dashboard we recommend to add to monitor your Airy Core +instance -And for Kafka this (dashboard)[https://grafana.com/grafana/dashboards/7589]. +- [Spring apps](https://grafana.com/grafana/dashboards/12464) +- [Apache Kafka](https://grafana.com/grafana/dashboards/7589) -### Monitoring with alerts +### Receiving alerts -Access the Alertmanager under `/alertmanager`. +To get notifications for the default alerts all you have to do is set up a +receiver like described +[here](https://grafana.com/docs/grafana/latest/dashboards/export-import/#import-dashboard). +That way you can get notified on Slack or PagerDuty on issues like crashing +components and nodes running out of free storage space. diff --git a/docs/sidebars.js b/docs/sidebars.js index c7e4f07b8c..184e44c1da 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -85,7 +85,7 @@ module.exports = { ], }, { - '📚 Guides': ['guides/contributing', 'guides/analytics-demo', 'guides/backup'], + '📚 Guides': ['guides/contributing', 'guides/analytics-demo', 'guides/monitoring', 'guides/backup'], }, 'changelog', ], diff --git a/frontend/chat-plugin/dev/config.ts b/frontend/chat-plugin/dev/config.ts index ca6c8921d7..72c836c59e 100644 --- a/frontend/chat-plugin/dev/config.ts +++ b/frontend/chat-plugin/dev/config.ts @@ -29,8 +29,4 @@ export const config: Config = { }, }, showMode: false, - inboundMessageColor: '#B8E986', - inboundMessageTextColor: '#BD10E0', - outboundMessageColor: '#7ED321', - outboundMessageTextColor: '#F8E71C', }; diff --git a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.module.scss b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.module.scss new file mode 100644 index 0000000000..40579179e7 --- /dev/null +++ b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.module.scss @@ -0,0 +1,46 @@ +@import 'assets/scss/colors.scss'; + +.container { + max-width: 550px; + position: relative; + margin: 0px 0px 5px 10px; + animation: fadeIn 3s linear forwards; +} + +@keyframes fadeIn { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.removeButton { + position: absolute; + right: 5px; + top: 7px; + padding: 8px; + margin: 0; + line-height: 0; + border-radius: 50%; + border: 1px solid var(--color-light-gray); + background-color: var(--color-template-highlight); + cursor: pointer; + outline: none; + z-index: 1; + + svg { + height: 10px; + width: 10px; + } +} + +.removeButton:after { + content: ''; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; +} diff --git a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.tsx b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.tsx new file mode 100644 index 0000000000..4c8dad1e68 --- /dev/null +++ b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/InputSelector/index.tsx @@ -0,0 +1,84 @@ +import React, {useRef, useEffect, useState} from 'react'; +import styles from './index.module.scss'; +import {ReactComponent as Close} from 'assets/images/icons/close.svg'; +import {SourceMessage} from 'render'; +import {Message} from 'model'; + +type InputSelectorProps = { + message: Message; + removeElementFromInput?: () => void; + contentResizedHeight?: number; +}; + +const textareaHeight = 40; +const minImageHeight = 50; + +export const InputSelector = (props: InputSelectorProps) => { + const {message, removeElementFromInput, contentResizedHeight} = props; + const [closeIconWidth, setCloseIconWidth] = useState(''); + const [closeIconHeight, setCloseIconHeight] = useState(''); + const [selectorPreviewCloseButton, setSelectorPreviewCloseButton] = useState(false); + + const fileSelectorDiv = useRef(null); + const removeFileButton = useRef(null); + + const resizeObserver = new ResizeObserver(entries => { + for (const entry of entries) { + const fileSelectorHeight = entry.contentRect.height; + const fileSelectorWidth = entry.contentRect.width; + + if (fileSelectorHeight > contentResizedHeight) { + scaleDownInputSelector(fileSelectorHeight); + } else if (fileSelectorHeight >= textareaHeight && fileSelectorWidth > minImageHeight) { + setSelectorPreviewCloseButton(true); + } + } + }); + + useEffect(() => { + resizeObserver.observe(fileSelectorDiv?.current); + }, [fileSelectorDiv?.current]); + + const scaleDownInputSelector = (fileSelectorHeight: number) => { + const scaleRatio = Number(Math.min(contentResizedHeight / fileSelectorHeight).toFixed(2)); + let iconSize = '24px'; + let buttonSize = '48px'; + + if (scaleRatio <= 0.9) { + if (scaleRatio < 0.5) { + iconSize = scaleRatio > 0.3 ? '24px' : '60px'; + buttonSize = scaleRatio > 0.3 ? '48px' : '120px'; + } else { + iconSize = '18px'; + buttonSize = '36px'; + } + + setCloseIconHeight(iconSize); + setCloseIconWidth(iconSize); + + if (removeFileButton && removeFileButton.current) { + removeFileButton.current.style.width = buttonSize; + removeFileButton.current.style.height = buttonSize; + } + } + + fileSelectorDiv.current.style.transform = `scale(${scaleRatio})`; + setSelectorPreviewCloseButton(true); + }; + + return ( +
+ {selectorPreviewCloseButton && ( + + )} + +
+ ); +}; diff --git a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.module.scss b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.module.scss index ad1257e581..e17a01a048 100644 --- a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.module.scss +++ b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.module.scss @@ -3,11 +3,13 @@ .inputBar { display: flex; - justify-content: space-between; + justify-content: flex-end; align-items: center; padding: 8px 0; margin: 0 8px; border-top: 1px solid var(--color-template-gray); + max-height: 100px; + min-height: 42px; } .textArea { @@ -144,7 +146,6 @@ align-items: center; position: relative; height: 30px; - margin-right: 4px; background: transparent; border: none; cursor: pointer; @@ -175,11 +176,27 @@ } } +.iconContainer { + display: flex; + flex-direction: row; + margin-right: 8px; +} + .smileyIcon { height: 20px; width: 20px; } +.paperclipIcon { + height: 24px; + width: 24px; + + svg { + height: 24px; + width: 24px; + } +} + .iconButton:hover { background-color: var(--color-background-blue); border-radius: 50%; @@ -194,3 +211,20 @@ display: block; } } + +.fileInput { + display: none; +} + +.selectorLoader { + position: absolute; + left: 25px; + display: flex; + justify-content: center; + align-items: center; +} + +.selectorLoader span { + @include font-base; + color: var(--color-text-gray); +} diff --git a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.tsx b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.tsx index 8022027af0..91cfe095f8 100644 --- a/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.tsx +++ b/frontend/chat-plugin/lib/src/airyRenderProps/AiryInputBar/index.tsx @@ -6,14 +6,21 @@ import {useTranslation} from 'react-i18next'; import {ReactComponent as AiryIcon} from 'assets/images/icons/airy-icon.svg'; import style from './index.module.scss'; import {ReactComponent as Smiley} from 'assets/images/icons/smiley.svg'; +import {ReactComponent as PaperClip} from 'assets/images/icons/paperclipChatplugin.svg'; import {ReactComponent as Paperplane} from 'assets/images/icons/paperplane.svg'; +import {getAttachmentType, getOutboundMapper} from 'render'; +import {InputSelector} from './InputSelector'; +import {uploadMedia} from '../../api'; +import {SimpleLoader} from 'components'; type AiryInputBarProps = { sendMessage: (text: string) => void; + sendMedia: (fileType: string, mediaUrl: string) => void; messageString: string; setMessageString: (text: string) => void; config?: Config; setNewConversation: React.Dispatch>; + dragDropFile: File; }; const AiryInputBar = (props: AiryInputBarProps) => { @@ -21,7 +28,13 @@ const AiryInputBar = (props: AiryInputBarProps) => { const {t} = useTranslation(); const [isShowingEmojiDrawer, setIsShowingEmojiDrawer] = useState(false); + const [uploadedFileUrl, setUploadedFileUrl] = useState(null); + const [loadingFile, setLoadingFile] = useState(false); + const [mediaType, setMediaType] = useState(null); const emojiDiv = useRef(null); + const fileRef = useRef(null); + const outboundMapper: any = getOutboundMapper('chatplugin'); + const contentResizedHeight = 100; const textInputRef = createRef(); const dataCyButtonId = cyInputbarButton; @@ -29,10 +42,14 @@ const AiryInputBar = (props: AiryInputBarProps) => { const isMobileDevice = window.innerHeight < 1200 || window.innerWidth < 1000; useEffect(() => { - textInputRef.current.selectionStart = props.messageString.length; - textInputRef.current.selectionEnd = props.messageString.length; + textInputRef.current.selectionStart = props.messageString?.length ?? 0; + textInputRef.current.selectionEnd = props.messageString?.length ?? 0; }, []); + useEffect(() => { + props.dragDropFile && uploadFile(props.dragDropFile); + }, [props.dragDropFile]); + const resizeTextarea = () => { const textArea = textInputRef.current; if (textArea) { @@ -50,6 +67,11 @@ const AiryInputBar = (props: AiryInputBarProps) => { props.setMessageString(''); props.sendMessage(props.messageString); } + + if (uploadedFileUrl) { + props.sendMedia(mediaType, uploadedFileUrl); + setUploadedFileUrl(null); + } }; const handleChange = (event: ChangeEvent) => { @@ -69,6 +91,21 @@ const AiryInputBar = (props: AiryInputBarProps) => { } }; + const removeElementFromInput = () => { + setUploadedFileUrl(null); + }; + + const uploadFile = (file: File) => { + const fileType = getAttachmentType(file.name, 'chatplugin'); + setMediaType(fileType); + setLoadingFile(true); + uploadMedia(file).then((mediaUrl: string) => { + setUploadedFileUrl(mediaUrl); + props.setMessageString(''); + setLoadingFile(false); + }); + }; + const InputOptions = () => { const handleEmojiDrawer = () => { if (isShowingEmojiDrawer) { @@ -114,19 +151,46 @@ const AiryInputBar = (props: AiryInputBarProps) => { handleEmojiDrawer(); }; + const openFileSelector = () => { + fileRef.current.click(); + }; + + const selectedFile = (event: React.ChangeEvent) => { + if (uploadedFileUrl) setUploadedFileUrl(null); + const file = event.target.files[0]; + uploadFile(file); + }; + return ( -
- <> - {isShowingEmojiDrawer && ( -
- -
- )} - - +
+ {isShowingEmojiDrawer && ( +
+ +
+ )} + {!uploadedFileUrl && ( +
+ + + + +
+ )}
); }; @@ -134,17 +198,39 @@ const AiryInputBar = (props: AiryInputBarProps) => { return ( <> {!(config.hideInputBar === true) && ( -
-