Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/dataset: Only reset collection index on actual dataset update #1511

Merged
merged 3 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ The types of changes are:

* Add unlinked docs and fix any remaining broken links [#1266](https://github.com/ethyca/fides/pull/1266)

### Fixed

* After editing a dataset, the table will stay on the previously selected collection instead of resetting to the first one. [#1511](https://github.com/ethyca/fides/pull/1511)

## [1.9.2](https://github.com/ethyca/fides/compare/1.9.1...1.9.2)

### Deprecated
Expand Down
20 changes: 18 additions & 2 deletions clients/admin-ui/cypress/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,31 @@ describe("Dataset", () => {
it("Can edit dataset fields", () => {
const newDescription = "new description";
cy.visit("/dataset/demo_users_dataset");
cy.getByTestId("field-row-uuid").click();
cy.getByTestId("collection-select").select("products");
cy.getByTestId("field-row-name").click();
cy.getByTestId("input-description").clear().type(newDescription);

// Updating the dataset will trigger a refresh of the GET request.
cy.fixture("dataset.json").then((draftDataset) => {
draftDataset.collections[1].fields[1].description = newDescription;
cy.intercept("GET", "/api/v1/dataset/*", {
body: { ...draftDataset },
}).as("getDataset");
});

cy.getByTestId("save-btn").click({ force: true });

cy.wait("@putDataset").then((interception) => {
const { body } = interception.request;
expect(body.collections[0].fields[5].description).to.eql(
expect(body.collections[1].fields[1].description).to.eql(
newDescription
);
});
cy.wait("@getDataset");

// The same dataset that was being edited should be shown in the table, updated.
cy.getByTestId("edit-drawer-content").should("not.exist");
cy.getByTestId("field-row-name").should("contain", newDescription);
});

it("Can edit dataset collections", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const DatasetCollectionView = ({ fidesKey }: Props) => {
useEffect(() => {
if (dataset) {
dispatch(setActiveDatasetFidesKey(dataset.fides_key));
dispatch(setActiveCollectionIndex(0));
}
}, [dispatch, dataset]);

Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/features/dataset/dataset.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const datasetSlice = createSlice({

// Clear out the related fields when the dataset is changed.
draftState.activeDatasetFidesKey = action.payload;
draftState.activeCollectionIndex = undefined;
draftState.activeCollectionIndex = 0;
draftState.activeFieldIndex = undefined;
},
setActiveCollectionIndex: (
Expand Down