Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lrasmus committed Mar 5, 2025
2 parents 1507b59 + 8fbccd9 commit cb3e972
Show file tree
Hide file tree
Showing 23 changed files with 1,470 additions and 380 deletions.
9 changes: 4 additions & 5 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": [
"stylelint-config-standard",
"stylelint-config-prettier",
"stylelint-config-standard-scss"
]
"extends": ["stylelint-config-standard", "stylelint-config-standard-scss"],
"rules": {
"selector-class-pattern": null
}
}
18 changes: 14 additions & 4 deletions app/components/Error/Error.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
display: flex;
padding: 6px 16px;
font-size: 0.75rem;
font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
font-family: Roboto, Helvetica, Arial, sans-serif;
font-weight: 400;
line-height: 1.43;
border-radius: 4px;
letter-spacing: 0.01071em;
color: rgb(97, 26, 21);
background-color: rgb(253, 236, 234);
letter-spacing: 0.0107em;
color: rgb(97 26 21);
background-color: rgb(253 236 234);
}

.container.sm {
padding: 3px;
line-height: 1;
}

.icon {
Expand All @@ -20,6 +25,11 @@
margin-right: 12px;
}

.icon.sm {
width: 14px;
height: 14px;
}

.message {
padding: 8px 0;
}
4 changes: 2 additions & 2 deletions app/components/Error/Error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import styles from './Error.css';

const error = (props) => {
return (
<div style={props.style} className={styles.container}>
<ErrorIcon className={styles.icon} />
<div style={props.style} className={[styles.container, (props.size && props.size === 'sm' ? styles.sm : "")].join(' ')}>
<ErrorIcon className={[styles.icon, (props.size && props.size === 'sm' ? styles.sm : "")].join(' ')} />
<div className={styles.message}>{props.children}</div>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions app/components/Loading/Loading.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
.childContainer {
margin-top: 15px;
}

.sm {
font-size: 0.8em;
}

.sm .childContainer {
margin-top: 5px;
}
2 changes: 1 addition & 1 deletion app/components/Loading/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styles from './Loading.css';

const loading = (props) => {
return (
<div className={styles.container}>
<div className={[styles.container, (props.size && props.size === 'sm' ? styles.sm : "")].join(' ')}>
<LinearProgress />
<div className={styles.childContainer}>{props.children}</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions app/components/Project/Assets/Assets.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@
.toolbarButton {
font-size: 0.8rem !important;
}

.bottom {
position: absolute;
bottom: 0;
width: 50%;
margin-bottom: 10px;
}
9 changes: 9 additions & 0 deletions app/components/Project/Assets/Assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const assetsComponent = (props) => {
onDeletedExternalAsset,
assetAttributes,
dynamicDetails,
scanStatus
} = props;
const [selectedAsset, setSelectedAsset] = useState();
const treeRef = React.useRef(null);
Expand Down Expand Up @@ -365,6 +366,13 @@ const assetsComponent = (props) => {
);
}

let assetScanStatus = null;
if (scanStatus === 'started') {
assetScanStatus = <div className={styles.bottom}><Loading size="sm">Additional details about the assets are still loading...</Loading></div>;
} else if (scanStatus === 'error') {
assetScanStatus = <div className={styles.bottom}><Error size="sm">There was an error loading additional details about the assets</Error></div>;
}

// Note that for the AssetFilter component, we always want that to be the original
// full list of assets. That's why we use project.assets for that component's
// propery, and the assets state variable for the AssetTree.
Expand Down Expand Up @@ -448,6 +456,7 @@ const assetsComponent = (props) => {
/>
{assetDetails}
</div>
{assetScanStatus}
<AssetGroupDialog
key={assetDialogKey}
open={editingGroup}
Expand Down
14 changes: 11 additions & 3 deletions app/components/Project/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ class Project extends Component<Props> {
onUpdatedAssetNote={this.assetUpsertNoteHandler}
onDeletedAssetNote={this.assetDeleteNoteHandler}
onUpdatedAssetAttribute={this.assetUpdateAttributeHandler}
onSelectedAsset={this.assetSelectedHandler}
onSelectedAsset={this.props.onAssetSelected}
onAddedAssetGroup={this.assetGroupAddedHandler}
onUpdatedAssetGroup={this.assetGroupUpdatedHandler}
onDeletedAssetGroup={this.assetGroupDeletedHandler}
Expand All @@ -835,6 +835,7 @@ class Project extends Component<Props> {
onDeletedExternalAsset={this.externalAssetDeletedHandler}
assetAttributes={this.props.configuration.assetAttributes}
dynamicDetails={this.props.assetDynamicDetails}
scanStatus={this.props.scanStatus}
/>
) : null;
const workflow = this.props.project ? <Workflow project={this.props.project} /> : null;
Expand Down Expand Up @@ -897,6 +898,7 @@ class Project extends Component<Props> {
onUpdatedNote={this.checklistUpsertNoteHandler}
onDeletedNote={this.checklistDeleteNoteHandler}
onSelectedAsset={this.props.onAssetSelected}
scanStatus={this.props.scanStatus}
/>
) : null;

Expand Down Expand Up @@ -983,7 +985,12 @@ Project.propTypes = {
// }
checklistResponse: PropTypes.object,
configuration: PropTypes.object,
assetDynamicDetails: PropTypes.object
assetDynamicDetails: PropTypes.object,
// This can have the following values:
// * null / '' - No scan is activate (not started or may be completed)
// * started - The scan is in progress
// * error - There was an error initiating or completing the scan. Display results to user
scanStatus: PropTypes.string
};

Project.defaultProps = {
Expand All @@ -995,7 +1002,8 @@ Project.defaultProps = {
logs: null,
checklistResponse: null,
configuration: null,
assetDynamicDetails: null
assetDynamicDetails: null,
scanStatus: null
};

Project.contextType = UserContext;
Expand Down
6 changes: 6 additions & 0 deletions app/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ module.exports = {
UPDATE_PROJECT_REQUEST: 'statwrap-update-project-request',
UPDATE_PROJECT_RESPONSE: 'statwrap-update-project-response',

// This message pair is used from the primary renderer -> main
SCAN_PROJECT_REQUEST: 'statwrap-scan-project-request',
SCAN_PROJECT_RESPONSE: 'statwrap-scan-project-response',
// This message pair is used from main -> worker renderer
SCAN_PROJECT_WORKER_REQUEST: 'statwrap-scan-project-worker-request',
SCAN_PROJECT_WORKER_RESPONSE: 'statwrap-scan-project-worker-response',
// This message is used from main -> primary renderer
SCAN_PROJECT_RESULTS_RESPONSE: 'statwrap-scan-project-results-request',

SCAN_ASSET_DYNAMIC_DETAILS_REQUEST: 'statwrap-scan-asset-dynamic-details-request',
SCAN_ASSET_DYNAMIC_DETAILS_RESPONSE: 'statwrap-scan-asset-dynamic-details-response',
Expand Down
29 changes: 25 additions & 4 deletions app/containers/ProjectPage/ProjectPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable prettier/prettier */
/* eslint-disable object-shorthand */
/* eslint-disable class-methods-use-this */
import React, { Component } from 'react';
import { ipcRenderer } from 'electron';
import ResizablePanels from 'resizable-panels-react';
Expand Down Expand Up @@ -52,6 +49,10 @@ class ProjectPage extends Component {
// tracks a sequential number that, when changed, signals React that the dialog can be
// recreated. We don't care what this key is, it just has to change.
createProjectDialogKey: 0,

// Show progress on scanning details about the project. Allows the user to access what information
// is available, yet be aware that more information may be arriving later.
projectScanStatus: '',
};

this.handleLoadProjectListResponse = this.handleLoadProjectListResponse.bind(this);
Expand All @@ -65,6 +66,7 @@ class ProjectPage extends Component {
this.handleClickProjectListMenu = this.handleClickProjectListMenu.bind(this);
this.handleSelectProjectListItem = this.handleSelectProjectListItem.bind(this);
this.handleScanProjectResponse = this.handleScanProjectResponse.bind(this);
this.handleScanProjectResultsResponse = this.handleScanProjectResultsResponse.bind(this);
this.handleProjectUpdate = this.handleProjectUpdate.bind(this);
this.handleChecklistUpdate = this.handleChecklistUpdate.bind(this);
this.handleUpdateProjectResponse = this.handleUpdateProjectResponse.bind(this);
Expand All @@ -89,6 +91,7 @@ class ProjectPage extends Component {
ipcRenderer.on(Messages.TOGGLE_PROJECT_FAVORITE_RESPONSE, this.refreshProjectsHandler);
ipcRenderer.on(Messages.REMOVE_PROJECT_LIST_ENTRY_RESPONSE, this.refreshProjectsHandler);
ipcRenderer.on(Messages.SCAN_PROJECT_RESPONSE, this.handleScanProjectResponse);
ipcRenderer.on(Messages.SCAN_PROJECT_RESULTS_RESPONSE, this.handleScanProjectResultsResponse);
ipcRenderer.on(Messages.UPDATE_PROJECT_RESPONSE, this.handleUpdateProjectResponse);

ipcRenderer.on(Messages.LOAD_PROJECT_LOG_RESPONSE, this.handleLoadProjectLogResponse);
Expand Down Expand Up @@ -126,6 +129,7 @@ class ProjectPage extends Component {
this.refreshProjectsHandler,
);
ipcRenderer.removeListener(Messages.SCAN_PROJECT_RESPONSE, this.handleScanProjectResponse);
ipcRenderer.removeListener(Messages.SCAN_PROJECT_RESULTS_RESPONSE, this.handleScanProjectResultsResponse);
ipcRenderer.removeListener(Messages.UPDATE_PROJECT_RESPONSE, this.handleUpdateProjectResponse);
ipcRenderer.removeListener(
Messages.LOAD_PROJECT_LOG_RESPONSE,
Expand Down Expand Up @@ -235,6 +239,12 @@ class ProjectPage extends Component {
return;
}

// If there is an error, we need to exit since there's nothing we can do for updates.
if (response.error) {
console.warn(response.errorMessage);
return;
}

// Initialize the checklist file if it doesn't exist, for all the already existing projects
const projectChecklist = ChecklistUtil.initializeChecklist();
if (response.checklist && response.checklist.length === 0) {
Expand Down Expand Up @@ -266,7 +276,17 @@ class ProjectPage extends Component {
}

handleScanProjectResponse(sender, response) {
if (response === null || response === undefined || response.error) {
this.setState({ projectScanStatus: 'error' });
} else {
this.setState({ projectScanStatus: 'started'});
}
}

handleScanProjectResultsResponse(sender, response) {
if (!response || !response.project) {
console.warn('Received an invalid response from the project asset scan.');
this.setState({ projectScanStatus: 'error' });
return;
}

Expand All @@ -287,7 +307,7 @@ class ProjectPage extends Component {
? { error: response.error, errorMessage: response.errorMessage }
: response.assets,
};
return { selectedProject: projectWithAssets };
return { selectedProject: projectWithAssets, projectScanStatus: null };
});
}

Expand Down Expand Up @@ -415,6 +435,7 @@ class ProjectPage extends Component {
onChecklistUpdated={this.handleChecklistUpdate}
configuration={{ assetAttributes: this.state.assetAttributes }}
assetDynamicDetails={this.state.assetDynamicDetails}
scanStatus={this.state.projectScanStatus}
/>
</ResizablePanels>
<CreateProjectDialog
Expand Down
Loading

0 comments on commit cb3e972

Please sign in to comment.