Skip to content
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

feat: Various fixes for Windows production deployment: Enable sentry,… #52

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ jobs:
- name: Tauri build
uses: tauri-apps/tauri-action@v0
env:
VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
VITE_SENTRY_DSN: ${{ steps.import-secrets.outputs.TROKK_VITE_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_VITE_SENTRY_ENVIRONMENT }}
RUST_SENTRY_DSN: ${{ steps.import-secrets.outputs.TROKK_RUST_SENTRY_DSN }}
RUST_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_RUST_SENTRY_ENVIRONMENT }}
id: tauri_build

- name: Setup JFrog CLI
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
fail-fast: false
matrix:
platform:
- [ self-hosted ]
- [ self-hosted-linux ]
- [ self-hosted, Windows ]
include:
- platform: [ self-hosted ]
- platform: [ self-hosted-linux ]
linux: true
- platform: [ self-hosted, Windows ]
windows: true
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/rust-check-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
fail-fast: false
matrix:
platform:
- [ self-hosted ]
- [ self-hosted-linux ]
- [ self-hosted, Windows ]
include:
- platform: [ self-hosted ]
- platform: [ self-hosted-linux ]
linux: true
- platform: [ self-hosted, Windows ]
windows: true
Expand All @@ -24,8 +24,10 @@ jobs:
VAULT_BASE_URL: "placeholder"
VAULT_ROLE_ID: "placeholder"
VAULT_SECRET_ID: "placeholder"
SENTRY_ENVIRONMENT: "placeholder"
SENTRY_URL: "placeholder"
VITE_SENTRY_ENVIRONMENT: "placeholder"
VITE_SENTRY_DSN: "placeholder"
RUST_SENTRY_ENVIRONMENT: "placeholder"
RUST_SENTRY_DSN: "placeholder"
steps:
# Git fix for Windows, workaround for permission issues regarding self-hosted runners
- name: Windows; Git fix
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For installasjon av nødvendige pakker og oppstart:
Appen er nå hardkodet til å hente filer fra ```$DOCUMENT/trokk/files```, så lag en mappe der med noen filer.

### Telemetri

Appen bruker Sentry for feillogging.
Dette medfører at konsollen blir wrappet i en Sentry-klient.
Som gjør at alle `console.<ANYTHING>` ser ut som det kommer fra Sentry-pakken.
Expand All @@ -36,10 +37,10 @@ Sett disse environment variablene for å få appen til å fungere:
| `VAULT_BASE_URL` | URL til VAULT instans. |
| `VAULT_ROLE_ID` | Vault rolle_id for app-role innlogging. |
| `VAULT_SECRET_ID` | Vault secret_id for app-role innlogging. |
| `SENTRY_ENVIRONMENT` | "Environment" string som sendes til Sentry. |
| `SENTRY_URL` | Generert Sentry URL for Rust prosjekt. |
| `VITE_SENTRY_DSN` | Generert Sentry URL for React prosjekt (Vite). |
| `VITE_SENTRY_ENVIRONMENT` | "Environment" string som sendes til Sentry. (for vite) |
| `VITE_SENTRY_URL` | Generert Sentry URL for Rust prosjekt. (for vite) |
| `RUST_SENTRY_DSN` | Generert Sentry URL for Rust prosjekt. |
| `RUST_SENTRY_ENVIRONMENT` | "Environment" string som sendes til Sentry. |

### Forventede variabler fra Vault

Expand Down
Binary file added public/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions public/tauri.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

Binary file added src-tauri/installer/assets/dialog_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src-tauri/installer/assets/installer_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src-tauri/src/image_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn list_tif_files_in_directory<P: AsRef<Path>>(
for entry in fs::read_dir(directory_path)? {
let entry = entry?;
let path = entry.path();
if path.is_file() && path.extension().map_or(false, |ext| ext == "tif") {
if path.is_file() && path.extension().is_some_and(|ext| ext == "tif") {
files.push(path);
}
}
Expand Down
10 changes: 4 additions & 6 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::ffi::OsString;
use std::sync::Mutex;

use gethostname::gethostname;
use once_cell::sync::Lazy;
use std::ffi::OsString;
use std::sync::Mutex;
use tauri::Manager;
use tauri::Window;
use tokio::sync::OnceCell;
Expand All @@ -27,8 +26,8 @@ pub static ENVIRONMENT_VARIABLES: RequiredEnvironmentVariables = RequiredEnviron
vault_base_url: env!("VAULT_BASE_URL"),
vault_role_id: env!("VAULT_ROLE_ID"),
vault_secret_id: env!("VAULT_SECRET_ID"),
sentry_environment: env!("SENTRY_ENVIRONMENT"),
sentry_url: env!("SENTRY_URL"),
sentry_environment: env!("RUST_SENTRY_ENVIRONMENT"),
sentry_dsn: env!("RUST_SENTRY_DSN"),
};

// Use Tokio's OnceCell to fetch secrets from Vault only once
Expand Down Expand Up @@ -179,7 +178,6 @@ pub fn run() {
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_oauth::init())
.setup(|app| {
#[cfg(debug_assertions)]
app.get_webview_window("main").unwrap().open_devtools();
{
let handle = app.handle();
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::borrow::Cow;
fn main() {
// Initialize Sentry
let _guard = sentry::init((
env!("SENTRY_URL"),
env!("RUST_SENTRY_DSN"),
sentry::ClientOptions {
release: sentry::release_name!(),
environment: Some(Cow::from(env!("SENTRY_ENVIRONMENT"))),
environment: Some(Cow::from(env!("RUST_SENTRY_ENVIRONMENT"))),
debug: true,
..Default::default()
},
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct RequiredEnvironmentVariables {
pub(crate) vault_base_url: &'static str,
pub(crate) vault_role_id: &'static str,
pub(crate) vault_secret_id: &'static str,
pub(crate) sentry_url: &'static str,
pub(crate) sentry_dsn: &'static str,
pub(crate) sentry_environment: &'static str,
}

Expand Down
8 changes: 7 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
"devUrl": "http://localhost:1420"
},
"bundle": {
"publisher": "Team Tekst",
"active": true,
"targets": "all",
"windows": {
"webviewInstallMode": {
"type": "offlineInstaller"
},
"wix": {
"bannerPath": "installer/assets/installer_banner.png",
"dialogImagePath": "installer/assets/dialog_image.png",
"language": "nb-NO"
}
},
"shortDescription": "Filflytting og registrering fra skannermaskiner",
Expand Down Expand Up @@ -43,7 +49,7 @@
},
"enable": true
},
"csp": "default-src 'self'; img-src 'self' asset: https://asset.localhost; connect-src ipc: http://ipc.localhost"
"csp": "default-src 'self'; img-src 'self' asset: https://asset.localhost; connect-src 'self' https://sentry.nb.no ipc: http://ipc.localhost; worker-src 'self' blob: http://tauri.localhost"
},
"windows": [
{
Expand Down
82 changes: 29 additions & 53 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,75 +1,51 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color: #0f0f0f;
background-color: #f6f6f6;
color: #f6f6f6;
background-color: #2f2f2f;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #ffffff;
background-color: #0f0f0f98;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

button {
cursor: pointer;
cursor: pointer;
}

button:hover {
border-color: #396cd8;
border-color: #396cd8;
}

button:active {
border-color: #396cd8;
background-color: #e8e8e8;
border-color: #396cd8;
background-color: #0f0f0f69;
}

@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}

a:hover {
a:hover {
color: #24c8db;
}

input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
button:active {
background-color: #0f0f0f69;
}
}

@media (prefers-color-scheme: dark) {
.errorColor {
.errorColor {
background-color: #aa0000;
color: white;
}
}

@media (prefers-color-scheme: light) {
.errorColor {
background-color: #ff7373;
color: black;
}
}
}
36 changes: 18 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useState } from 'react';
import { FolderOpen, User } from 'lucide-react';
import React, {useState} from 'react';
import {FolderOpen, User} from 'lucide-react';
import './App.css';
import { AuthContextType, AuthProvider, useAuth } from './context/auth-context.tsx';
import { TrokkFilesProvider } from './context/trokk-files-context.tsx';
import {AuthContextType, AuthProvider, useAuth} from './context/auth-context.tsx';
import {TrokkFilesProvider} from './context/trokk-files-context.tsx';
import MainLayout from './components/layouts/main-layout.tsx';
import Modal from './components/ui/modal.tsx';
import SettingsForm from './features/settings/settings.tsx';
import { UploadProgressProvider } from './context/upload-progress-context.tsx';
import {UploadProgressProvider} from './context/upload-progress-context.tsx';
import Button from './components/ui/button.tsx';
import { SecretProvider } from './context/secret-context.tsx';
import { SettingProvider, useSettings } from './context/setting-context.tsx';
import {SecretProvider} from './context/secret-context.tsx';
import {SettingProvider, useSettings} from './context/setting-context.tsx';

function App() {
// TODO figure out what is making that "Unhandled Promise Rejection: window not found" error
window.addEventListener('unhandledrejection', function(event) {
window.addEventListener('unhandledrejection', function (event) {
console.error('Unhandled rejection (promise: ', event.promise, ', reason: ', event.reason, ').');
console.error(event);
throw event;
Expand All @@ -32,7 +32,7 @@ function App() {
/>
</main>
<Modal isOpen={openSettings} onClose={() => setOpenSettings(false)}>
<SettingsForm />
<SettingsForm/>
</Modal>
</SettingProvider>
</AuthProvider>
Expand All @@ -45,9 +45,9 @@ interface ContentProps {
setOpenSettings: React.Dispatch<React.SetStateAction<boolean>>;
}

const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
const { authResponse, loggedOut, isLoggingIn, fetchSecretsError, login, logout } = useAuth() as AuthContextType;
const { scannerPath } = useSettings();
const Content: React.FC<ContentProps> = ({openSettings, setOpenSettings}) => {
const {authResponse, loggedOut, isLoggingIn, fetchSecretsError, login, logout} = useAuth() as AuthContextType;
const {scannerPath} = useSettings();

if (fetchSecretsError) {
return (
Expand All @@ -68,7 +68,7 @@ const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
if (loggedOut && !isLoggingIn) {
return (
<div className={'w-screen h-screen flex flex-col justify-center items-center text-center'}>
<img alt={'Trøkk logo'} src="banner.png" className={'w-96 pb-10'}></img>
<img alt={'Trøkk logo'} src="/banner.png" className={'w-96 pb-10'}></img>
<Button className={'w-[150px] h-[75px] text-2xl'} onClick={login}>Logg inn</Button>
</div>
);
Expand All @@ -77,7 +77,7 @@ const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
if (isLoggingIn && !authResponse) {
return (
<div className={'w-screen h-screen flex flex-col justify-center items-center text-center'}>
<img alt={'Trøkk logo'} src="banner.png" className={'w-96 pb-10'}></img>
<img alt={'Trøkk logo'} src="/banner.png" className={'w-96 pb-10'}></img>
<h2 className={'h-[75px]'}>Nytt innloggingsvindu åpnet, vennligst logg inn der...</h2>
</div>
);
Expand All @@ -86,7 +86,7 @@ const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
if (!authResponse) {
return (
<div className={'w-screen h-screen flex flex-col justify-center items-center text-center'}>
<img alt={'Trøkk logo'} src="banner.png" className={'w-96 pb-10'}></img>
<img alt={'Trøkk logo'} src="/banner.png" className={'w-96 pb-10'}></img>
<Button className={'w-[150px] h-[75px] text-2xl'} onClick={login}>Logg inn</Button>
</div>
);
Expand All @@ -96,12 +96,12 @@ const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
<>
<div className="grid grid-cols-3 mt-2 sticky top-0">
<h2 className="text-xl flex items-center pl-4">
<FolderOpen size="32" className="-ml-3 mr-1 mb-2 flex-shrink-0" />{scannerPath}
<FolderOpen size="32" className="-ml-3 mr-1 mb-2 flex-shrink-0"/>{scannerPath}
</h2>
<h1 className="text-4xl content-end text-center">Trøkk</h1>
<div className="flex justify-end gap-2">
<div className="flex pr-2 pt-3">
<User />
<User/>
<p className="pt-0.5">{authResponse!.userInfo.givenName}</p>
</div>
<Button onClick={() => setOpenSettings(!openSettings)}>Innstillinger</Button>
Expand All @@ -110,7 +110,7 @@ const Content: React.FC<ContentProps> = ({ openSettings, setOpenSettings }) => {
</div>
<TrokkFilesProvider scannerPath={scannerPath}>
<UploadProgressProvider>
<MainLayout />
<MainLayout/>
</UploadProgressProvider>
</TrokkFilesProvider>
</>
Expand Down
Loading