-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal for handling of missing/removed modules (#310)
- Loading branch information
1 parent
73174d1
commit 14dd17b
Showing
3 changed files
with
81 additions
and
3 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
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
61 changes: 61 additions & 0 deletions
61
frontend/src/framework/internal/ModuleNotFoundPlaceholder.tsx
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,61 @@ | ||
import { ImportState, Module } from "@framework/Module"; | ||
import { ModuleInstance } from "@framework/ModuleInstance"; | ||
import { Button } from "@lib/components/Button"; | ||
import { Tag } from "@lib/components/Tag"; | ||
import { BugReport, Forum, WebAssetOff } from "@mui/icons-material"; | ||
|
||
export class ModuleNotFoundPlaceholder extends Module<Record<string, never>> { | ||
constructor(moduleName: string) { | ||
super(moduleName, moduleName, [], {}, null); | ||
this._importState = ImportState.Imported; | ||
} | ||
|
||
makeInstance(instanceNumber: number): ModuleInstance<Record<string, never>> { | ||
const instance = super.makeInstance(instanceNumber); | ||
instance.setDefaultState({}); | ||
return instance; | ||
} | ||
|
||
viewFC = () => { | ||
function reportIssue() { | ||
window.open("https://github.com/equinor/webviz/issues/new", "_blank"); | ||
} | ||
|
||
function startDiscussion() { | ||
window.open( | ||
"https://github.com/equinor/webviz/discussions/new?category=announcements&welcome_text=true", | ||
"_blank" | ||
); | ||
} | ||
|
||
return ( | ||
<div className="w-full h-full flex flex-col items-center justify-center gap-6"> | ||
<WebAssetOff fontSize="large" className="text-gray-400" /> | ||
<span className="text-lg text-red-500"> | ||
Module <Tag label={this.getName()} /> not found. | ||
</span> | ||
<span className="text-sm text-gray-600 text-center"> | ||
The module is no longer available and might have been removed from the application. You can safely | ||
remove the module instance by clicking on the cross in its header. If you are wondering why this | ||
module has been removed, please get in touch with us on GitHub. | ||
</span> | ||
<div className="flex gap-4"> | ||
<Button startIcon={<BugReport fontSize="small" />} onClick={reportIssue}> | ||
Report issue | ||
</Button> | ||
<Button startIcon={<Forum fontSize="small" />} onClick={startDiscussion}> | ||
Start discussion | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
settingsFC = () => { | ||
return ( | ||
<div> | ||
Module <Tag label={this.getName()} /> not found. | ||
</div> | ||
); | ||
}; | ||
} |