Skip to content

Commit

Permalink
Make object tabs extendable via plugins (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
yankovs committed Jan 15, 2024
1 parent 16bbb2c commit 4fb4370
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 82 deletions.
57 changes: 30 additions & 27 deletions mwdb/web/src/components/Blob/Views/ShowTextBlobView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { TextBlobDetails } from "../common/TextBlobDetails";
import { TextBlobPreview } from "../common/TextBlobPreview";
import { BlobDiffAction } from "../common/BlobDiffAction";
import { ObjectOrConfigOrBlobData } from "@mwdb-web/types/types";
import { Extendable } from "@mwdb-web/commons/plugins";

export function ShowTextBlobView() {
const params = useParams();
Expand All @@ -46,33 +47,35 @@ export function ShowTextBlobView() {
headerCaption="Blob details"
defaultTab="preview"
>
<ObjectTab
tab="details"
icon={faFingerprint}
component={TextBlobDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<BlobDiffAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={TextBlobPreview}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<BlobDiffAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<Extendable ident="blobTabs">
<ObjectTab
tab="details"
icon={faFingerprint}
component={TextBlobDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<BlobDiffAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={TextBlobPreview}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<BlobDiffAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
</Extendable>
<LatestConfigTab label="Parsed blob" />
</ShowObject>
);
Expand Down
53 changes: 28 additions & 25 deletions mwdb/web/src/components/Config/Views/ShowConfigView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useRemotePath } from "@mwdb-web/commons/remotes";
import { ConfigDetails } from "../common/ConfigDetails";
import { ConfigPreview } from "../common/ConfigPreview";
import { ObjectOrConfigOrBlobData } from "@mwdb-web/types/types";
import { Extendable } from "@mwdb-web/commons/plugins";

export function ShowConfigView() {
const params = useParams();
Expand All @@ -47,31 +48,33 @@ export function ShowConfigView() {
headerIcon={faTable}
headerCaption="Config details"
>
<ObjectTab
tab="details"
icon={faFingerprint}
component={ConfigDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={ConfigPreview}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<Extendable ident="configTabs">
<ObjectTab
tab="details"
icon={faFingerprint}
component={ConfigDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={ConfigPreview}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<FavoriteAction />,
<DownloadAction download={downloadTextBlob} />,
]}
/>
</Extendable>
</ShowObject>
);
}
2 changes: 1 addition & 1 deletion mwdb/web/src/components/ShowObject/common/ShowObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function objectReducer(state: ObjectStateReducer, action: ObjectActionReducer) {

type Props = {
ident: string;
children: JSX.Element[];
children: JSX.Element | JSX.Element[];
objectType: ObjectType;
headerIcon: IconDefinition;
objectId: string;
Expand Down
61 changes: 32 additions & 29 deletions mwdb/web/src/components/Views/ShowSampleView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { SampleDetails } from "../SampleDetails";
import { SamplePreview } from "../SamplePreview";
import { PreviewSwitchAction } from "../PreviewSwitchAction";
import { ObjectOrConfigOrBlobData } from "@mwdb-web/types/types";
import { Extendable } from "@mwdb-web/commons/plugins";

export function ShowSampleView() {
const api = useContext(APIContext);
Expand Down Expand Up @@ -56,35 +57,37 @@ export function ShowSampleView() {
headerIcon={faFile}
headerCaption="File details"
>
<ObjectTab
tab="details"
icon={faFingerprint}
component={SampleDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<UploadChildAction />,
<FavoriteAction />,
<ZipAction zip={zipSample} />,
<DownloadAction download={downloadSample} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={SamplePreview}
actions={[
<PreviewSwitchAction />,
<RemoveAction />,
<PushAction />,
<PullAction />,
<UploadChildAction />,
<FavoriteAction />,
<DownloadAction download={downloadSample} />,
]}
/>
<Extendable ident="sampleTabs">
<ObjectTab
tab="details"
icon={faFingerprint}
component={SampleDetails}
actions={[
<RemoveAction />,
<PushAction />,
<PullAction />,
<UploadChildAction />,
<FavoriteAction />,
<ZipAction zip={zipSample} />,
<DownloadAction download={downloadSample} />,
]}
/>
<RelationsTab />
<ObjectTab
tab="preview"
icon={faSearch}
component={SamplePreview}
actions={[
<PreviewSwitchAction />,
<RemoveAction />,
<PushAction />,
<PullAction />,
<UploadChildAction />,
<FavoriteAction />,
<DownloadAction download={downloadSample} />,
]}
/>
</Extendable>
<LatestConfigTab label="Static config" />
</ShowObject>
);
Expand Down

0 comments on commit 4fb4370

Please sign in to comment.