Skip to content

Commit 22a6006

Browse files
Slashekz-xdamcik
authored
Get rid of dependencies in Chat module and prepare a simple app page (#2)
* setup app and add readme * remove community module dependence * Working chat with updated ActionCable * Node deps cleanup * Working import maps * Fixed missing var, chat works now * Clean up node modules * Initial styling * Header styling * Styling further * Inbox styling * Basic conversation styling * Textarea styling * Updated layout not to overflow viewport height * Intro page styling * Use HTML template from BE instead of HTML hardcoded in JS files * Fixed loading previous messages page * Forms styling * add playwright * delete playwright.yml * Cleanup * make seed.sh executable * fix MPKIT_TOKEN * fix data path in seed.sh * fix path * add seed * add new users * Mobile view * Hide back arrow on desktop * add messaging test * Renamed the styles module * Use default pOS brand colors in config and overwrite them in app * Updated Readme * Updated reset to be scroped only to .pos-app * Updated modules deps * Updated readme * Disable debug mode * use current profile helper * Sth * Use new current profile helper * Removed components deps * make the find by uuid more reliable * New namespacing * Moved profile data from HTML input to JS vars * Idk * Updated * Updated common-styling * Updated common-styling * Fix timezone JS var * Fixed width for conversations * Cleanup * Updated readme * Updated the components module and overwritten the button * Bump version * Fixed <small> not being resseted * Updated common-styling * Bump common-styling deps * Update chat message input radius * Bump version --------- Co-authored-by: Łukasz Krysiewicz <[email protected]> Co-authored-by: damcik <[email protected]>
1 parent dc858a9 commit 22a6006

File tree

389 files changed

+16570
-13395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

389 files changed

+16570
-13395
lines changed

.github/workflows/e2e_tests.yml

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: E2E tests
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
- 'main'
7+
paths-ignore:
8+
- ".github/**"
9+
pull_request:
10+
branches:
11+
- 'main'
12+
paths-ignore:
13+
- ".github/**"
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
pre_job:
19+
# continue-on-error: true # Uncomment once integration is finished
20+
runs-on: ubuntu-latest
21+
# Map a step output to a job output
22+
outputs:
23+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
24+
steps:
25+
- id: skip_check
26+
uses: fkirc/skip-duplicate-actions@master
27+
with:
28+
github_token: ${{ github.token }}
29+
paths_ignore: '["**/README.md"]'
30+
do_not_skip: '["push"]'
31+
32+
reserve-ci-instance:
33+
needs: pre_job
34+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
35+
runs-on: ubuntu-latest
36+
container: alpine:3.20
37+
outputs:
38+
mpkit-url: ${{ steps.reserve.outputs.mpkit-url }}
39+
report-path: ${{ steps.reserve.outputs.report-path }}
40+
steps:
41+
- name: Get ci-instance-url
42+
id: reserve
43+
uses: Platform-OS/[email protected]
44+
with:
45+
repository-url: ${{ vars.CI_REPOSITORY_URL }}
46+
method: reserve
47+
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
48+
49+
deploy:
50+
needs: ["reserve-ci-instance"]
51+
runs-on: ubuntu-latest
52+
container: platformos/playwright:5.1.5-1.47.2
53+
strategy:
54+
matrix:
55+
node-version: [20.x]
56+
timeout-minutes: 5
57+
env:
58+
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
59+
MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
60+
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
61+
CI: true
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- uses: actions/setup-node@v4
66+
with:
67+
node-version: ${{ matrix.node-version }}
68+
69+
- name: Deploy
70+
timeout-minutes: 6
71+
shell: sh
72+
run: |
73+
set -eu
74+
./tests/data/seed/seed.sh
75+
76+
test:
77+
needs: ["reserve-ci-instance", "deploy"]
78+
runs-on: ubuntu-latest
79+
container: platformos/playwright:5.1.5-1.47.2
80+
timeout-minutes: 35
81+
env:
82+
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
83+
#MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
84+
MPKIT_TOKEN: ${{ secrets.QA0_ACCESS_TOKEN }}
85+
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
86+
REPORT_PATH: ${{ needs.reserve-ci-instance.outputs.report-path }}
87+
E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }}
88+
UPLOAD_HOST: https://test-reports.platformos.dev
89+
CI: true
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Run Playwright tests
94+
if: success() || failure()
95+
run: |
96+
npm run pw-tests
97+
env:
98+
HOME: /root
99+
100+
cleanup:
101+
if: ${{ always() }}
102+
needs: ["reserve-ci-instance", "deploy", "test"]
103+
runs-on: ubuntu-latest
104+
container: alpine:3.20
105+
steps:
106+
- name: release ci-instance-url
107+
uses: Platform-OS/[email protected]
108+
with:
109+
method: release
110+
repository-url: ${{ vars.CI_REPOSITORY_URL }}
111+
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
node_modules
22
.pos
33
tmp
4+
test/pictures/
5+
test/screenshots
6+
test/reports/video/
7+
seed/data.csv
8+
seed/models.csv
9+
test-report.html
10+
test-report.json
11+
/test-results/
12+
/playwright-report/
13+
/blob-report/
14+
/playwright/.cache/
415
modules/core
516
modules/tests

README.md

+124-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,124 @@
1-
# pos-module-chat
1+
# Chat Module
2+
3+
This module serves as a starting point for adding real time chat to your application. Before using the module for the first time, we recommend reading the official platformOS documentation on [WebSockets](https://documentation.platformos.com/use-cases/using-websockets) and on [Example Application](#example-application).
4+
5+
This module follows the [platformOS DevKit best practices](https://documentation.staging.oregon.platform-os.com/developer-guide/modules/platformos-modules) and includes the [core module](https://github.com/Platform-OS/pos-module-core) as a dependency, enabling you to implement patterns such as [Commands](https://github.com/Platform-OS/pos-module-core?tab=readme-ov-file#commands--business-logic) and [Events](https://github.com/Platform-OS/pos-module-core?tab=readme-ov-file#events). It also includes the [user module](https://github.com/Platform-OS/pos-module-user) and [profile module](https://github.com/Platform-OS/pos-module-profile) as a dependency.
6+
7+
For more information,
8+
- read the documentation about the [built-in User table](https://documentation.platformos.com/developer-guide/users/user),
9+
- learn about [how platformOS manages sessions](https://documentation.platformos.com/developer-guide/users/session),
10+
- and gain a high-level overview of [authentication strategies in platformOS](https://documentation.platformos.com/developer-guide/users/authentication).
11+
12+
## Installation
13+
14+
The platformOS Chat Module is available on the [Partner Portal Modules Marketplace](https://partners.platformos.com/marketplace/pos_modules/152).
15+
16+
### Prerequisites
17+
18+
Before installing the module, ensure that you have [pos-cli](https://github.com/mdyd-dev/pos-cli#overview) installed. This tool is essential for managing and deploying platformOS projects.
19+
20+
The platformOS Chat Module is fully compatible with [platformOS Check](https://github.com/Platform-OS/platformos-lsp#platformos-check----a-linter-for-platformos), a linter and language server that supports any IDE with Language Server Protocol (LSP) integration. For Visual Studio Code users, you can enhance your development experience by installing the [VSCode platformOS Check Extension](https://marketplace.visualstudio.com/items?itemName=platformOS.platformos-check-vscode).
21+
22+
### Installation Steps
23+
24+
1. **Navigate to your project directory** where you want to install the Chat Module.
25+
26+
2. **Run the installation command**:
27+
28+
```bash
29+
pos-cli modules install chat
30+
```
31+
32+
This command installs the Chat Module along with its dependencies (such as [pos-module-core](https://github.com/Platform-OS/pos-module-core)) and updates or creates the `app/pos-modules.json` file in your project directory to track module configurations.
33+
34+
### Setup
35+
36+
1. **Install the module** using the [pos-cli](https://github.com/Platform-OS/pos-cli).
37+
38+
2. If you haven't done it already, follow the instructions to setup [pos-module-user-](https://github.com/Platform-OS/pos-module-user?tab=readme-ov-file#setup). During this process, you will create an overwrite of the permissions file `app/modules/user/public/lib/queries/role_permissions/permissions.liquid`
39+
40+
3. Overwrite default views that you would like to customize by following the guide on [overwriting a module file](https://documentation.platformos.com/developer-guide/modules/modules#overwritting-a-module-file). This allows you to add functionality based on your project requirements. At a minimum, you should overwrite the [permissions file](modules/user/public/lib/queries/role_permissions/permissions.liquid), where you will configure [RBAC authorization](#rbac-authorization) roles and permissions for your application - add `chat.inbox` permission to the role(s) that you would like to have access to the chat available at `/inbox`. In our example, the `inbox.chat` permission was added to `authenticated` role, meaning all signed in users have access to the chat. Snippet to create an overwrite to copy-paste into your terminal:
41+
42+
```
43+
mkdir -p app/modules/user/public/lib/queries/role_permissions
44+
cp modules/user/public/lib/queries/role_permissions/permissions.liquid app/modules/user/public/lib/queries/role_permissions/permissions.liquid
45+
```
46+
47+
4. Add the following to the `<head>` section of your application layout to get the basic styling provided with the module. To overwrite the colors and spacings you can overwrite the CSS variables in `pos-config.css`.
48+
49+
```
50+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-reset.css' | asset_url }}">
51+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-config.css' | asset_url }}">
52+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-button.css' | asset_url }}">
53+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-typography.css' | asset_url }}">
54+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-avatar.css' | asset_url }}">
55+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-forms.css' | asset_url }}">
56+
<link rel="stylesheet" href="{{ 'modules/common-styling/style/pos-page.css' | asset_url }}">
57+
<link rel="stylesheet" href="{{ 'modules/chat/style/pos-chat-inbox.css' | asset_url }}">
58+
```
59+
60+
5. Add the following to the `<head>` section of your application layout **before any other `<script>` tag on the page**. Or - if you already using an import map, just extend it with the following:
61+
62+
```
63+
<script type="importmap">
64+
{
65+
"imports": {
66+
"/": "{{ 'modules/chat/js/' | asset_url }}",
67+
"pos-chat.js": "{{ 'modules/chat/js/pos-chat.js' | asset_url }}",
68+
"pos-chat-consumer.js": "{{ 'modules/chat/js/pos-chat-consumer.js' | asset_url }}",
69+
"pos-chat-csrfToken.js": "{{ 'modules/chat/js/pos-chat-csrfToken.js' | asset_url }}",
70+
"pos-chat-notifications.js": "{{ 'modules/chat/js/pos-chat-notifications.js' | asset_url }}",
71+
"./": "./"
72+
}
73+
}
74+
</script>
75+
```
76+
77+
### Managing Module Files
78+
79+
The default behavior of modules is that **the files are never deleted**. It is assumed that developers might not have access to all of the files, and thanks to this feature, they can still overwrite some of the module's files without breaking them. Since the User Module is fully public, it is recommended to delete files on deployment. To do this, ensure your `app/config.yml` includes the User Module and its dependencies in the list `modules_that_allow_delete_on_deploy`:
80+
81+
``` yaml
82+
modules_that_allow_delete_on_deploy:
83+
- core
84+
- user
85+
- profile
86+
- chat
87+
```
88+
89+
## Example application
90+
91+
We recommend creating a [new Instance](https://partners.platformos.com/instances/new) and deploying this module as an application to get a better understanding of the basics and the functionality this module provides. When you install the module using `pos-cli modules install chat`, only the contents of the `modules/chat` will be available in your project. The `app` directory serves as an example of how you could incorporate the Chat Module into your application. When analyzing the code in the `app` directory, pay attention to the following files:
92+
93+
* ** `app/config.yml`** and **`app/user.yml`**: These files are defined according to the [Setup](#setup) instructions.
94+
* ** `app/modules/user/public/lib/queries/role_permissions/permissions.liquid`**: Demonstrates how to configure permissions in your application by [overwriting a module file](https://documentation.platformos.com/developer-guide/modules/modules#overwriting-a-module-file).
95+
96+
## Functionality provided by the chat module:
97+
98+
Once the module is installed and you have completed the [setup](#setup), you will immediately gain access to the new endpoints created by this module. For example, you can navigate to `/inbox` for the chat window.
99+
100+
- [x] **[Inbox](#inbox)**:
101+
102+
TODO (Upcoming Features)
103+
104+
105+
### Inbox
106+
107+
Inbox
108+
109+
#### Endpoints for the registration
110+
111+
The table below outlines the [resourceful routes](https://documentation.platformos.com/developer-guide/modules/platformos-modules#resourceful-route-naming-convention) provided for registration functionality:
112+
113+
| HTTP method | slug | page file path | description
114+
|---|---|---|---|---|
115+
| GET | /inbox | `modules/chat/public/views/pages/inbox.liquid` | Renders a chat |
116+
117+
#### CRUD commands
118+
119+
...
120+
121+
122+
## Customizing the looks
123+
124+
The chat module by default uses styling provided by the platformOS Common Styling module. It's built with the intention to easily overwrite the colors, fonts and spacings by overwriting the CSS variables stored in `modules/common-styling/style/pos-config.css`. You can create your own `.css` file and just overwrite any value of any variable. If you need more CSS customization you can obviously just use standard styling techniques and if you need to change the HTML structure even further, you can overwrite any liquid partial used in the chat.
Binary file not shown.
Binary file not shown.

app/assets/images/pos-sign.svg

+76
Loading

app/assets/js/app.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
initializes the application
3+
*/
4+
5+
6+
// purpose: main application namespace object
7+
// ************************************************************************
8+
const application = {};
9+
// stores each module instance and it's api
10+
application.module = {};

0 commit comments

Comments
 (0)