Skip to content

Commit

Permalink
Create docs for public platform
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Apr 1, 2024
1 parent eda4110 commit a9682dc
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 15 deletions.
28 changes: 28 additions & 0 deletions docs/configurations/config_build_mobile_app_for_public_platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Configuring apps with compilation environment declarations

### Context

- Twake Chat app can use the values of environment declarations to change its functionality or behavior.
Dart compilers can eliminate the code made unreachable due to
control flow using the environment declaration values.
- Only support for mobile app.

### How to config

1.Flutter
- To specify environment declarations to the Flutter tool, use the `--dart-define` option instead:

```
flutter run --dart-define=REGISTRATION_URL=https://example.com/
--dart-define=TWAKE_WORKPLACE_HOMESERVER=https://example.com/
--dart-define=PLATFORM=platfomrm
--dart-define=HOME_SERVER=https://example.com/
```

- `REGISTRATION_URL`: Registration URL for public platform
- `TWAKE_WORKPLACE_HOMESERVER`: Twake workplace homeserver
- `PLATFORM`: Platform, `saas` for the case of public platform
- `HOME_SERVER`: Homeserver

If you want to disable it, please change the value or remove when use `--dart-define` option
47 changes: 47 additions & 0 deletions docs/configurations/config_web_app_for_public_platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Configuration for config.json

### Context

- Twake Chat need to config env for Twake Chat service on web version
- Now only support to web

### How to config

1.Add environment
in [config.sample.json](https://github.com/linagora/twake-on-matrix/blob/main/config.sample.json)

- Env for Twake Chat service:

```
{
"application_name": "Twake Chat",
"application_welcome_message": "Welcome to Twake Chat!",
"default_homeserver": "matrix.linagora.com",
"privacy_url": "https://twake.app/en/privacy/",
"render_html": true,
"hide_redacted_events": false,
"hide_unknown_events": false,
"issue_id": "",
"registration_url": "https://example.com/",
"twake_workplace_homeserver": "https://example.com/",
"app_grid_dashboard_available": true,
"homeserver": "https://example.com/",
"platform": "platform"
}
```

- `application_name`: The name will be showed in App Grid
- `application_welcome_message`: The welcome message will be showed in App Grid
- `default_homeserver`: The default homeserver
- `privacy_url`: The privacy policy URL
- `render_html`: Render HTML in messages
- `hide_redacted_events`: Hide redacted events
- `hide_unknown_events`: Hide unknown events
- `issue_id`: Issue ID
- `registration_url`: Registration URL for public platform
- `twake_workplace_homeserver`: Twake workplace homeserver
- `app_grid_dashboard_available`: Enable App Grid
- `homeserver`: Homeserver
- `platform`: Platform, `saas` for the case of public platform

If you want to disable it, please change the value or remove this from `config.sample.json`
51 changes: 37 additions & 14 deletions lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,53 @@ abstract class AppConfig {
static const String appGridConfigurationPath =
"configurations/app_dashboard.json";

static const String _platformEnv = String.fromEnvironment(
'PLATFORM',
defaultValue: 'platform',
);

static const String _twakeWorkplaceHomeserverEnv = String.fromEnvironment(
'TWAKE_WORKPLACE_HOMESERVER',
defaultValue: 'https://example.com/',
);

static const String _registrationUrlEnv = String.fromEnvironment(
'REGISTRATION_URL',
defaultValue: 'https://example.com/',
);

static const String _homeserverEnv = String.fromEnvironment(
'HOME_SERVER',
defaultValue: 'https://example.com/',
);

static void loadEnvironment() {
twakeWorkplaceHomeserver = const String.fromEnvironment(
'TWAKE_WORKPLACE_HOMESERVER',
defaultValue: 'https://example.com/',
twakeWorkplaceHomeserver = _twakeWorkplaceHomeserverEnv;

Logs().i(
'[Public Platform] AppConfig():: TWAKE_WORKPLACE_HOMESERVER $_twakeWorkplaceHomeserverEnv',
);

registrationUrl = const String.fromEnvironment(
'REGISTRATION_URL',
defaultValue: 'https://example.com/',
registrationUrl = _registrationUrlEnv;

Logs().i(
'[Public Platform] AppConfig():: REGISTRATION_URL $_registrationUrlEnv',
);

platform = const String.fromEnvironment(
'PLATFORM',
defaultValue: 'platform',
platform = _platformEnv;

Logs().i(
'[Public Platform] AppConfig():: Platform $_platformEnv',
);

homeserver = const String.fromEnvironment(
'HOME_SERVER',
defaultValue: 'https://example.com/',
homeserver = _homeserverEnv;

Logs().i(
'[Public Platform] AppConfig():: HOME_SERVER $_homeserverEnv',
);
}

static bool get isSaasPlatForm =>
platform != null && platform!.isNotEmpty && platform == 'saas';
static bool get isSaasPlatForm => _platformEnv == 'saas';

static void loadFromJson(Map<String, dynamic> json) {
if (json['homeserver'] != null && json['homeserver'] is String) {
Expand Down
2 changes: 1 addition & 1 deletion macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WindowToFrontPlugin.register(with: registry.registrar(forPlugin: "WindowToFrontPlugin"))
}
}

0 comments on commit a9682dc

Please sign in to comment.