Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Conversation

VirginiaBalseiro
Copy link
Contributor

Image component delete functionality

This PR adds an optional allowDelete prop to the Image component which renders a default delete button that will remove the image value from the dataset.

It is also possible to pass a deleteComponent to render a custom delete button.

Checklist

  • All acceptance criteria are met.
  • Relevant documentation, if any, has been written/updated.
  • The changelog has been updated, if applicable.
  • New functions/types have been exported in index.ts, if applicable.
  • New modules (i.e. new .ts files) are listed in the exports field in package.json, if applicable.
  • New modules (i.e. new .ts files) are listed in the typedocOptions.entryPoints field in tsconfig.json, if applicable.
  • Commits in this PR are minimal and have descriptive commit messages.

it("Should call saveSolidDatasetAt when clicking delete button", async () => {
jest
.spyOn(SolidFns, "saveSolidDatasetAt")
.mockResolvedValue(mockDataset as any);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding

import type {
  SolidDataset,
  WithChangeLog,
  WithServerResourceInfo,
} from "@inrupt/solid-client";

in the imports and replacing this with mockDataset as SolidDataset & WithServerResourceInfo & WithChangeLog should remove the warning.

Comment on lines +127 to +129
await saveSolidDatasetAt(datasetSourceUrl, updatedDataset, {
fetch,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this only happen when autosave is set ? Or is it by design that when deleting an image you're automatically deleting it from the remote storage ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I am not sure but I have added a check for autosave since it is what we do with other operations as well.

const handleDelete = async () => {
if (!propThing || !solidDataset || !propProperty || !value) return;
try {
const updatedThing = removeUrl(propThing, propProperty, value as string);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the preceding if was changed so that it tests typeof value === 'string' rather than !value, would the type assertions still be needed ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants