-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pramodcog/update-translation-key-string-ju…
…ne-release
- Loading branch information
Showing
45 changed files
with
1,231 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
react-components/src/architecture/base/concreteCommands/CopyToClipboardCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
* BaseTool: Base class for the tool are used to interact with the render target. | ||
*/ | ||
|
||
import { BaseCommand } from '../commands/BaseCommand'; | ||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
|
||
type GetStringDelegate = () => string; | ||
|
||
export class CopyToClipboardCommand extends BaseCommand { | ||
private readonly _getString: GetStringDelegate; | ||
|
||
// ================================================== | ||
// CONSTRUCTOR | ||
// ================================================== | ||
|
||
public constructor(getString: GetStringDelegate) { | ||
super(); | ||
this._getString = getString; | ||
} | ||
|
||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { key: 'COPY_TO_CLIPBOARD', fallback: 'Copy to clipboard' }; | ||
} | ||
|
||
public override get icon(): string { | ||
return 'Copy'; | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this._getString !== undefined; | ||
} | ||
|
||
public override get hasData(): boolean { | ||
return true; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
if (this._getString === undefined) { | ||
return false; | ||
} | ||
navigator.clipboard | ||
.writeText(this._getString()) | ||
.then((_result) => { | ||
return true; | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
return true; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
react-components/src/architecture/base/concreteCommands/DeleteDomainObjectCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
* BaseTool: Base class for the tool are used to interact with the render target. | ||
*/ | ||
|
||
import { BaseCommand } from '../commands/BaseCommand'; | ||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
import { type DomainObject } from '../domainObjects/DomainObject'; | ||
|
||
export class DeleteDomainObjectCommand extends BaseCommand { | ||
private readonly _domainObject: DomainObject | undefined = undefined; | ||
public constructor(domainObject: DomainObject) { | ||
super(); | ||
this._domainObject = domainObject; | ||
} | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { key: 'DELETE', fallback: 'Delete' }; | ||
} | ||
|
||
public override get icon(): string { | ||
return 'Delete'; | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this._domainObject !== undefined && this._domainObject.canBeRemoved; | ||
} | ||
|
||
public override get hasData(): boolean { | ||
return true; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
if (this._domainObject === undefined) { | ||
return false; | ||
} | ||
return this._domainObject.removeInteractive(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
react-components/src/architecture/base/concreteCommands/ToogleMetricUnitsCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
* BaseTool: Base class for the tool are used to interact with the render target. | ||
*/ | ||
|
||
import { RenderTargetCommand } from '../commands/RenderTargetCommand'; | ||
import { Changes } from '../domainObjectsHelpers/Changes'; | ||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
|
||
export class ToogleMetricUnitsCommand extends RenderTargetCommand { | ||
// ================================================== | ||
// OVERRIDES of BaseCommand | ||
// ================================================== | ||
|
||
public override get icon(): string { | ||
return 'RulerAlternative'; | ||
} | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { key: 'TOGGLE_METRIC_UNITS', fallback: 'm/ft' }; // Note: m/ft do not need to be translated! | ||
} | ||
|
||
public override get isChecked(): boolean { | ||
const { renderTarget } = this; | ||
return renderTarget.rootDomainObject.unitSystem.isMetric; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const { renderTarget } = this; | ||
const unitSystem = renderTarget.rootDomainObject.unitSystem; | ||
unitSystem.isMetric = !unitSystem.isMetric; | ||
renderTarget.rootDomainObject.notifyRecursive(Changes.unit); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.