-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(checkpoints): stubs for checkpoints & storybook
- Loading branch information
1 parent
33b940a
commit 383dd05
Showing
9 changed files
with
291 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { CheckpointsMeta } from "../features/Checkpoints/checkpointsSlice"; | ||
import { RestoreCheckpointsResponse } from "../features/Checkpoints/types"; | ||
|
||
export const STUB_RESTORED_CHECKPOINT_DATA: RestoreCheckpointsResponse = { | ||
reverted_to: "2025-01-24T17:44:08Z", | ||
checkpoints_for_undo: [], | ||
error_log: [], | ||
reverted_changes: [ | ||
{ | ||
files_changed: [ | ||
{ | ||
absolute_path: "test.txt", | ||
relative_path: "test.txt", | ||
status: "MODIFIED", | ||
}, | ||
{ | ||
absolute_path: | ||
"\\?\\\\C:\\\\Users\\\\andre\\\\Desktop\\\\work\\\\refact.ai\\\\refact-lsp\\\\src\\\\main.rs", | ||
relative_path: "src/main.rs", | ||
status: "DELETED", | ||
}, | ||
], | ||
workspace_folder: "refact-lsp", | ||
}, | ||
], | ||
}; | ||
|
||
export const STUB_RESTORED_CHECKPOINTS_STATE: CheckpointsMeta = { | ||
isVisible: true, | ||
latestCheckpointResult: STUB_RESTORED_CHECKPOINT_DATA, | ||
}; | ||
|
||
export const STUB_RESTORED_CHECKPOINTS_STATE_WITH_NO_CHANGES: CheckpointsMeta = | ||
{ | ||
isVisible: true, | ||
latestCheckpointResult: { | ||
reverted_to: "2024-01-20T15:30:00Z", | ||
checkpoints_for_undo: [], | ||
reverted_changes: [], | ||
error_log: [], | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
.CheckpointsDialog { | ||
width: calc(100vw - var(--space-8)); | ||
max-width: 500px; | ||
padding-top: var(--space-7); | ||
position: relative; | ||
} | ||
|
||
.CheckpointsRevertedDate { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
} |
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,64 @@ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { setUpStore } from "../../app/store"; | ||
import { Provider } from "react-redux"; | ||
import { Theme } from "../../components/Theme"; | ||
import { Checkpoints } from "./Checkpoints"; | ||
import { CheckpointsMeta } from "./checkpointsSlice"; | ||
import { | ||
STUB_RESTORED_CHECKPOINTS_STATE, | ||
STUB_RESTORED_CHECKPOINTS_STATE_WITH_NO_CHANGES, | ||
} from "../../__fixtures__/checkpoints"; | ||
|
||
const Template: React.FC<{ initialState?: CheckpointsMeta }> = ({ | ||
initialState, | ||
}) => { | ||
const store = setUpStore({ | ||
tour: { | ||
type: "finished", | ||
}, | ||
config: { | ||
apiKey: "foo", | ||
addressURL: "Refact", | ||
host: "web", | ||
lspPort: 8001, | ||
themeProps: { | ||
appearance: "dark", | ||
}, | ||
}, | ||
checkpoints: initialState ?? STUB_RESTORED_CHECKPOINTS_STATE, | ||
}); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<Theme> | ||
<Checkpoints /> | ||
</Theme> | ||
</Provider> | ||
); | ||
}; | ||
|
||
const meta = { | ||
title: "Features/Checkpoints", | ||
component: Template, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
} satisfies Meta<typeof Template>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Template>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const WithNoChanges: Story = { | ||
args: { | ||
initialState: STUB_RESTORED_CHECKPOINTS_STATE_WITH_NO_CHANGES, | ||
}, | ||
}; | ||
|
||
export const DialogClosed: Story = { | ||
args: { | ||
initialState: STUB_RESTORED_CHECKPOINTS_STATE_WITH_NO_CHANGES, | ||
}, | ||
}; |
Oops, something went wrong.