Skip to content

Commit

Permalink
Merge branch 'master' into build-cli-tool
Browse files Browse the repository at this point in the history
  • Loading branch information
AmmarAbouZor committed Aug 9, 2024
2 parents aeb2a2c + 2c213a7 commit 513ebe0
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 30 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/pullrequest_check.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Checks

on: [pull_request]
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
ts_lint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -26,6 +33,7 @@ jobs:
- name: JS/TS linting
run: rake lint:js
rust_lint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -48,6 +56,7 @@ jobs:
- name: Rust linting
run: rake lint:rust
integration_tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -74,6 +83,7 @@ jobs:
- name: Run integration tests
run: rake test:js
unit_tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion application/apps/indexer/addons/dlt-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn extract_dlt_ft(
}

let mut out = BufWriter::new(
File::create(&output.join(name)).map_err(|e| format!("Error opening file: {e}"))?,
File::create(output.join(name)).map_err(|e| format!("Error opening file: {e}"))?,
);

let data = &file.data;
Expand Down
12 changes: 6 additions & 6 deletions application/apps/indexer/processor/src/export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ pub enum ExportError {
/// # Arguments
/// * `s` - instance of MessageProducer stream
/// * `destination_path` - destination path to a target file. If the file doesn't
/// exist it would be created; if exists - it will be opened to append new
/// content to the end of the file
/// exist it would be created; if exists - it will be opened to append new
/// content to the end of the file
/// * `sections` - an array of ranges, which should be written into destination
/// file
/// file
/// * `read_to_end` - in "true" will continue iterating stream after all ranges
/// are processed; in "false" will stop listening to a stream as soon as all ranges
/// are processed. It should be used in "true" for example if exporting applied
/// to concatenated files.
/// are processed; in "false" will stop listening to a stream as soon as all ranges
/// are processed. It should be used in "true" for example if exporting applied
/// to concatenated files.
/// * `cancel` - cancellation token to stop operation
///
/// # Errors
Expand Down
8 changes: 0 additions & 8 deletions application/apps/indexer/session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
events::{CallbackEvent, ComputationError},
operations,
operations::Operation,
progress::Severity,
state,
state::{AttachmentInfo, GrabbedElement, IndexesMode, SessionStateAPI, SourceDefinition},
tracker,
Expand All @@ -11,7 +10,6 @@ use crate::{
use futures::Future;
use log::{debug, error, warn};
use processor::{grabber::LineRange, search::filter::SearchFilter};
use serde::Serialize;
use sources::{factory::ObserveOptions, sde};
use std::{ops::RangeInclusive, path::PathBuf};
use tokio::{
Expand Down Expand Up @@ -519,9 +517,3 @@ impl Session {
.map_err(ComputationError::NativeError)
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct GeneralError {
severity: Severity,
message: String,
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class LayoutSnackBarMessage {
.then((response) => {
if (response.error !== undefined) {
this.log().error(
`Fail to proccess action ${action.name} (${action.uuid}); error: ${response.error}`,
`Fail to process action ${action.name} (${action.uuid}); error: ${response.error}`,
);
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<div class="message">
<p>{{data.notification.message()}}</p>
<p>{{ data.notification.message() }}</p>
</div>
<div class="controlls">
<button mat-stroked-button
[attr.title]="action.description"
(click)="ngOnAction(action)"
*ngFor="let action of data.notification.actions()">{{action.name}}</button>
<button mat-stroked-button
style="pointer-events: all;"
[attr.title]="action.description"
(click)="ngOnAction(action)"
[disabled]="action.disabled"
*ngFor="let action of data.notification.actions()">{{ action.name }}</button>
</div>
<button class="material-mofication-mini" data-controll="close" mat-icon-button (click)="ngDismiss()">
<mat-icon>close</mat-icon>
Expand Down
21 changes: 21 additions & 0 deletions application/client/src/app/ui/styles/material.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ mat-form-field.material-mofication-normal {
}
}

button[mat-stroked-button][disabled] {
background: @scheme-color-3-15;
border-color: @scheme-color-3-15;
cursor: default;
& * {
color: @scheme-color-3;
}
& .mat-mdc-button-persistent-ripple,
& .mat-mdc-focus-indicator,
& .mat-mdc-button-touch-target,
& .mat-mdc-button-ripple {
display: none;
}
&:hover {
background: @scheme-color-3-15;
border-color: @scheme-color-3-15;
& * {
color: @scheme-color-3;
}
}
}

& mat-error {
color: @scheme-color-warning!important;
Expand Down
30 changes: 25 additions & 5 deletions application/holder/src/env/os/platform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as os from 'os';
import { execSync } from 'child_process';
import { scope } from 'platform/env/scope';
import { error } from 'platform/log/utils';

export enum Platform {
aix = 'aix',
Expand All @@ -15,6 +18,24 @@ export enum Platform {
undefined = 'undefined',
}

let cachedCpuBrandString: string | null = null;

function safeExecSync(command: string, timeout: number): string {
try {
return execSync(command, { timeout }).toString().trim().toLowerCase();
} catch (err) {
scope.getLogger('PlatformChecker').warn(`Fail to detect arch for darwin. Command '${command}' gives error: ${error(err)}`);
return '';
}
}

function getCpuBrandString(): string {
if (cachedCpuBrandString === null) {
cachedCpuBrandString = safeExecSync('sysctl -n machdep.cpu.brand_string', 200);
}
return cachedCpuBrandString;
}

export function getPlatform(win32Only = false): Platform {
switch (os.platform()) {
case Platform.aix:
Expand All @@ -25,16 +46,16 @@ export function getPlatform(win32Only = false): Platform {
} else {
return Platform.linux;
}
break;
case Platform.openbsd:
return Platform.linux;
case Platform.darwin:
if (os.arch() === 'arm64') {
case Platform.darwin: {
const result = getCpuBrandString();
if (os.arch() === 'arm64' || (!result.includes('intel') && result !== '')) {
return Platform.darwinaarch64;
} else {
return Platform.darwin;
}
break;
}
case Platform.win32:
if (win32Only) {
return Platform.win32;
Expand All @@ -44,7 +65,6 @@ export function getPlatform(win32Only = false): Platform {
} else if (os.arch() === 'x64') {
return Platform.win64;
}
break;
}
return Platform.undefined;
}
Expand Down
4 changes: 4 additions & 0 deletions application/holder/src/service/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class Service extends Implementation {
uuid: unique(),
name: 'Ok',
description: ``,
disabled: false,
},
handler: () =>
Promise.resolve(),
Expand All @@ -98,6 +99,7 @@ export class Service extends Implementation {
uuid: unique(),
name: 'Ok',
description: ``,
disabled: false,
},
handler: () =>
Promise.resolve(),
Expand Down Expand Up @@ -214,6 +216,7 @@ export class Service extends Implementation {
uuid: unique(),
name: 'Ok',
description: ``,
disabled: false,
},
handler: () =>
Promise.resolve(),
Expand All @@ -235,6 +238,7 @@ export class Service extends Implementation {
uuid: unique(),
name: 'Ok',
description: ``,
disabled: false,
},
handler: () =>
Promise.resolve(),
Expand Down
22 changes: 19 additions & 3 deletions application/holder/src/service/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,19 @@ export class Service extends Implementation {
filename,
};
}
notifications.send(`New version (${this.candidate.release.name}) is available`, [
// Check folder access
const hasAccess = this.checkFolderAccess();
this.log().debug(`Chipmunk location sufficiently accessible for update : ${hasAccess}.`);
notifications.send(`New version (${this.candidate.release.name}) is available${!hasAccess ? '; insufficient access to update' : ''}`, [
{
action: {
uuid: unique(),
name: 'Restart & Update',
description: `Update to ${this.candidate.release.name}`,
description: !hasAccess ? `Unable to update` : `Update to ${this.candidate.release.name}`,
disabled: !hasAccess, // Disable the button if access is not available
},
handler: () => {
if (!hasAccess) return Promise.reject(new Error('No access to the current folder'));
return this._delivery().then((updater: string) => {
global.application
.shutdown('Updating')
Expand All @@ -329,13 +334,24 @@ export class Service extends Implementation {
action: {
uuid: unique(),
name: 'Cancel',
description: `Update to ${(candidate.release as IReleaseData).name}`,
description: '',
disabled: false,
},
handler: () => Promise.resolve(),
},
]);
}

// Function to check access to the current folder
private checkFolderAccess(): boolean {
try {
fs.accessSync(paths.getExec(true), fs.constants.R_OK | fs.constants.W_OK | fs.constants.X_OK);
return true;
} catch (err) {
return false;
}
}

private async _delivery(): Promise<string> {
const updater = {
src: path.resolve(paths.getBin(), getExecutable(UPDATER)),
Expand Down
1 change: 1 addition & 0 deletions application/platform/types/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface Action {
uuid: string;
name: string;
description: string;
disabled: boolean;
}

0 comments on commit 513ebe0

Please sign in to comment.