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-storagebrowser] adds file preview and save for files #3869

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ramprasadagarwal
Copy link
Collaborator

What changes were proposed in this pull request?

  • This PR adds the preview of different files types in the file browser

How was this patch tested?

  • Added unit tests for each file type

};

const handleSave = () =>
save({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now if we are establishing a pattern it is reasonable be a bit more picky than usual :-)

I thought about this during the other PR review. Doesn't it make more sense to handle the save success and failure here instead of at the top where we get the save function from the hook? That way the logic is grouped together.

save({...}).then(()=>{do stuff}).catch(...)

or if the error handling is done by the hook like in this example

const success = await save({...});
if (success ) {...}


const StorageFilePage = ({ fileData }: { fileData: PathAndFileData }): JSX.Element => {
const { t } = i18nReact.useTranslation();
const [isEditing, setIsEditing] = React.useState(false);
const [fileContent, setFileContent] = React.useState(fileData.view?.contents);
const fileMetaData = useMemo(() => getFileMetaData(t, fileData), [t, fileData]);

const { loading: isSaving, save } = useSaveData(SAVE_FILE_API_URL, {
onSuccess: () => {
setIsEditing(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would disable editing as soon as the save button was clicked, not when successful. If save failed I would enable the editing again.

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

Successfully merging this pull request may close these issues.

2 participants