Skip to content

Commit

Permalink
chore: lint fix + compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Nov 18, 2024
1 parent 63ea566 commit 1049eb2
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class CreatePoiCommentCommand extends BaseInputCommand {
}

const domainObject = this.rootDomainObject.getDescendantByType(PointsOfInterestDomainObject);
domainObject?.postCommentForPoi(this._poi, this._content).then(() => {
void domainObject?.postCommentForPoi(this._poi, this._content).then(() => {
this._onFinish?.();
domainObject?.notify(Changes.addedPart);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DeleteSelectedPointsOfInterestCommand<

pois.removePointsOfInterest(selectedOverlay);
pois.setSelectedPointOfInterest(undefined);
pois.save();
void pois.save();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/*!
* Copyright 2024 Cognite AS
*/
import {
type CommentProperties,
type PointsOfInterestInstance,
type PointsOfInterestProperties
} from './models';
import { type CommentProperties, type PointsOfInterestInstance } from './models';
import { type PointsOfInterestProvider } from './PointsOfInterestProvider';

/**
Expand Down Expand Up @@ -68,7 +64,7 @@ export class PointsOfInterestCache<PoiId> {
}

public async savePointsOfInterest(
pois: PointsOfInterestInstance<PoiId>[]
pois: Array<PointsOfInterestInstance<PoiId>>
): Promise<Array<PointsOfInterestInstance<PoiId>>> {
if (pois.length === 0) {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { partition, remove } from 'lodash';
import { type CommentProperties, type PointsOfInterestProperties } from './models';
import { Quantity } from '../../base/domainObjectsHelpers/Quantity';
import { type PointsOfInterestProvider } from './PointsOfInterestProvider';
import { isDefined } from '../../../utilities/isDefined';

export class PointsOfInterestDomainObject<PoiIdType> extends VisualDomainObject {
private _selectedPointsOfInterest: PointOfInterest<PoiIdType> | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {

export type PointsOfInterestProvider<ID> = {
createPointsOfInterest: (
pois: { id: ID; properties: PointsOfInterestProperties }[]
pois: Array<{ id: ID; properties: PointsOfInterestProperties }>
) => Promise<Array<PointsOfInterestInstance<ID>>>;
fetchAllPointsOfInterest: () => Promise<Array<PointsOfInterestInstance<ID>>>;
getPointsOfInterestComments: (poiId: ID) => Promise<CommentProperties[]>;
postPointsOfInterestComment: (poiId: ID, content: string) => Promise<CommentProperties>;
deletePointsOfInterest: (poiIds: ID[]) => Promise<void>;
createNewId(): ID;
createNewId: () => ID;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { SectionCommand } from '../../base/commands/SectionCommand';
import { TranslateKey } from '../../base/utilities/TranslateKey';
import { type TranslateKey } from '../../base/utilities/TranslateKey';

export class PointsOfInterestSectionCommand extends SectionCommand {
public override get isVisible(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { type AnchoredDialogContent } from '../../base/commands/BaseTool';
import { AnchoredDialogUpdater } from '../../base/reactUpdaters/AnchoredDialogUpdater';
import { NavigationTool } from '../../base/concreteCommands/NavigationTool';
import { CreatePointsOfInterestWithDescriptionCommand } from './CreatePointsOfInterestWithDescriptionCommand';
import { InitiatePointsOfInterestCommand } from './InitiatePointsOfInterestCommand';

export class PointsOfInterestTool<PoiIdType> extends NavigationTool {
private _isCreating: boolean = false;
Expand Down Expand Up @@ -110,7 +109,7 @@ export class PointsOfInterestTool<PoiIdType> extends NavigationTool {

this.setAnchoredDialogContent({
contentCommands: [createPointCommand],
position: position,
position,
onCloseCallback: onCancelCallback
});
}
Expand All @@ -133,7 +132,7 @@ export class PointsOfInterestTool<PoiIdType> extends NavigationTool {

private async initiateCreatPointOfInterest(event: PointerEvent): Promise<void> {
const intersection = await this.getIntersection(event);
if (!intersection || isPointsOfInterestIntersection(intersection)) {
if (intersection === undefined || isPointsOfInterestIntersection(intersection)) {
this.closeCreateCommandDialog();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SetPointsOfInterestVisibleCommand<
return true;
}

private get poiDomainObject() {
private get poiDomainObject(): PointsOfInterestDomainObject<PoiIdType> | undefined {
return this.rootDomainObject.getDescendantByType(PointsOfInterestDomainObject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class PointsOfInterestAdsProvider implements PointsOfInterestProvider<Ext
constructor(private readonly _sdk: CogniteClient) {}

async createPointsOfInterest(
pois: { id: ExternalId; properties: PointsOfInterestProperties }[]
pois: Array<{ id: ExternalId; properties: PointsOfInterestProperties }>
): Promise<Array<PointsOfInterestInstance<ExternalId>>> {
const result = await this._sdk.put<{ items: PoiItem[] }>(
`${this._sdk.getBaseUrl()}/${this._createUrl(this._sdk.project)}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class PointsOfInterestFdmProvider implements PointsOfInterestProvider<Dms
constructor(private readonly _fdmSdk: FdmSDK) {}

async createPointsOfInterest(
pois: { id: DmsUniqueIdentifier; properties: PointsOfInterestProperties }[]
pois: Array<{ id: DmsUniqueIdentifier; properties: PointsOfInterestProperties }>
): Promise<Array<PointsOfInterestInstance<DmsUniqueIdentifier>>> {
return await createPointsOfInterestInstances(this._fdmSdk, pois);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '../../../../data-providers/FdmSDK';
import { type PointsOfInterestInstance, type PointsOfInterestProperties } from '../models';

import { v4 as uuid } from 'uuid';
import { POI_SOURCE } from './view';
import { restrictToDmsId } from '../../../../utilities/restrictToDmsId';

Expand All @@ -30,7 +29,7 @@ export async function fetchPointsOfInterest(

export async function createPointsOfInterestInstances(
fdmSdk: FdmSDK,
poiOverlays: { id: DmsUniqueIdentifier; properties: PointsOfInterestProperties }[]
poiOverlays: Array<{ id: DmsUniqueIdentifier; properties: PointsOfInterestProperties }>
): Promise<Array<PointsOfInterestInstance<DmsUniqueIdentifier>>> {
const chunks = chunk(poiOverlays, 100);
const resultPromises = chunks.map(async (chunk) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { Image360ActionCommand } from '../../architecture/base/concreteCommands/
import { type PlacementType } from './types';
import { type Vector3 } from 'three';
import { InitiatePointsOfInterestCommand } from '../../architecture/concrete/pointsOfInterest/InitiatePointsOfInterestCommand';
import { PoiInfoPanelContent } from './pointsOfInterest';
import { DeleteSelectedPointsOfInterestCommand } from '../../architecture/concrete/pointsOfInterest/DeletePointsOfInterestCommand';

export class RevealButtons {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/*!
* Copyright 2024 Cognite AS
*/
import { type PointsOfInterestDomainObject } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject';
import {
Accordion,
Avatar,
Breadcrumbs,
Button,
Divider,
Flex,
Expand Down Expand Up @@ -111,7 +109,3 @@ export const CreateCommentField = ({
const CommentFieldContainer = styled.div`
margin-top: 8px;
`;

const StyledBreadcrumbs = styled(Breadcrumbs)`
overflow: hidden;
`;
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*!
* Copyright 2024 Cognite AS
*/
import { type ReactElement, ReactNode, useMemo, useState } from 'react';
import { type PointsOfInterestDomainObject } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject';
import { type ReactNode, useMemo, useState } from 'react';
import { type PointOfInterest } from '../../../architecture/concrete/pointsOfInterest/types';
import { useOnUpdateDomainObject } from '../useOnUpdate';
import { DataGrid, DatagridColumn } from '@cognite/cogs-lab';
import { DataGrid, type DatagridColumn } from '@cognite/cogs-lab';
import { usePoiDomainObject } from './usePoiDomainObject';
import { EMPTY_ARRAY } from '../../../utilities/constants';
import { useTranslation } from '../../i18n/I18n';
Expand All @@ -31,14 +30,14 @@ export const PoiList = (): ReactNode => {
const rowData = useMemo(
() =>
pois.map((poi) => ({
id: poi.id,
id: JSON.stringify(poi.id),
name: poi.id,
poi
})),
[pois]
);

const columns: DatagridColumn<RowType>[] = [
const columns: Array<DatagridColumn<RowType>> = [
{
field: 'name',
headerName: t('NAME', 'Name'),
Expand All @@ -57,7 +56,7 @@ export const PoiList = (): ReactNode => {
}}
columns={columns}
data={rowData}
selectedRows={[selectedPoi?.id]}
selectedRows={[JSON.stringify(selectedPoi?.id)]}
pagination={false}
disableColumnResize
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { CollapsablePanel } from '@cognite/cogs.js';
import { type PropsWithChildren, type ReactNode, useState } from 'react';
import { useRenderTarget } from '../../RevealCanvas';
import { PointsOfInterestTool } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestTool';
import { type PointOfInterest } from '../../../architecture/concrete/pointsOfInterest/types';
import styled from 'styled-components';
import { useOnUpdate, useOnUpdateDomainObject } from '../useOnUpdate';
import { type PointsOfInterestDomainObject } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject';
import { useOnUpdate } from '../useOnUpdate';
import { PoiInfoPanelContent } from './PoiInfoPanelContent';
import { PoiList } from './PoiList';
import { useSelectedPoi } from './useSelectedPoi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*!
* Copyright 2024 Cognite AS
*/
export { PoiInfoPanelContent } from './PoiInfoPanelContent';
export { useSyncSelectedPoi } from './useSyncSelectedPoi';
export { usePoiDomainObject } from './usePoiDomainObject';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2024 Cognite AS
*/
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
import { type PointOfInterest, type PointsOfInterestDomainObject } from '../../../architecture';
import { type PointOfInterest } from '../../../architecture';
import { type CommentProperties } from '../../../architecture/concrete/pointsOfInterest/models';
import { queryKeys } from '../../../utilities/queryKeys';
import { usePoiDomainObject } from './usePoiDomainObject';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/*!
* Copyright 2024 Cognite AS
*/
import { useState } from 'react';
import { PointsOfInterestDomainObject } from '../../../architecture';
import { type PointsOfInterestDomainObject } from '../../../architecture';
import { PointsOfInterestTool } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestTool';
import { useRenderTarget } from '../../RevealCanvas';
import { useOnUpdate } from '../useOnUpdate';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*!
* Copyright 2024 Cognite AS
*/
import { useState } from 'react';
import { PointOfInterest, PointsOfInterestDomainObject } from '../../../architecture';
import { PointsOfInterestTool } from '../../../architecture/concrete/pointsOfInterest/PointsOfInterestTool';
import { useRenderTarget } from '../../RevealCanvas';
import { type PointOfInterest } from '../../../architecture';
import { useOnUpdateDomainObject } from '../useOnUpdate';
import { usePoiDomainObject } from './usePoiDomainObject';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/*!
* Copyright 2024 Cognite AS
*/
import { useEffect, useRef } from 'react';
import { PointOfInterest } from '../../../architecture';
import { type PointOfInterest } from '../../../architecture';
import { useOnUpdateDomainObject } from '../useOnUpdate';
import { useRenderTarget } from '../../RevealCanvas';
import { usePoiDomainObject } from './usePoiDomainObject';

export const useSyncSelectedPoi = (
selectedPoi: PointOfInterest<unknown> | undefined,
setSelectedPoi: (poi: PointOfInterest<unknown> | undefined) => void
) => {
): void => {
const renderTarget = useRenderTarget();
const domainObject = usePoiDomainObject();

Expand All @@ -26,7 +29,7 @@ export const useSyncSelectedPoi = (

useEffect(() => {
domainObject?.setSelectedPointOfInterest(selectedPoi);
if (selectedPoi) {
if (selectedPoi !== undefined) {
domainObject?.setVisibleInteractive(true, renderTarget);
}
}, [selectedPoi, domainObject]);
Expand Down

0 comments on commit 1049eb2

Please sign in to comment.