-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
feat: add loading state for import actions #4217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
All the relevant importer types (
HoppPostmanImporter
,HoppInsomniaImporter
andHoppOpenAPImporter
) need to be updated similar to the updates proposed toHoppRESTImporter
:- Remove the
try/finally
block. - Wait for the promise from
handleImportToStore()
to resolve. - Add a new metadata entry
isLoading
.
- Remove the
-
Since we're adding a new
isLoading
metadata field for theFileSource
helper function, we'll have to make the following changes to its source.
import FileImportVue from "~/components/importExport/ImportExportSteps/FileImpor
import { defineStep } from "~/composables/step-components"
import { v4 as uuidv4 } from "uuid"
+import { Ref } from "vue"
export function FileSource(metadata: {
acceptedFileTypes: string
caption: string
onImportFromFile: (content: string[]) => any | Promise<any>
+ isLoading?: Ref<boolean>
}) {
const stepID = uuidv4()
export function FileSource(metadata: {
acceptedFileTypes: metadata.acceptedFileTypes,
caption: metadata.caption,
onImportFromFile: metadata.onImportFromFile,
+ loading: metadata.isLoading?.value,
}))
}
- A new prop
loading
has to be added for the FileImport component and the import CTA that is rendered viaHoppButtonPrimary
needs to be supplied aloading
prop attaching to the newly added prop. Also, the disable logic should be updated to account for the loading state.
hoppscotch/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/FileImport.vue
Lines 47 to 52 in 4fd6d6d
<HoppButtonPrimary | |
class="w-full" | |
:label="t('import.title')" | |
:disabled="!hasFile || showFileSizeLimitExceededWarning" | |
@click="emit('importFromFile', fileContent)" | |
/> |
- We'll also need to account for
Import from Personal collections
represented by theHoppMyCollectionImporter
importer. A new reactive state variable has to be added to track the loading state. TheMyCollectionImport
component will require updates similar to theFileSource
component.
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
packages/hoppscotch-common/src/components/collections/ImportExport.vue
Outdated
Show resolved
Hide resolved
778a85f
to
283e4b8
Compare
Import/Export
modals
Import/Export
modals283e4b8
to
abd8163
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add loading state for gist and har importer as well
abd8163
to
64656c8
Compare
Accounted for OpenAPI import via URL step as well. |
64656c8
to
bb96bd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯
`Import/Export` environments modal
bb96bd5
to
45886a0
Compare
This PR addresses the need for a loading state in the
Import/Export
modals that includes collections and environments in scope.Closes #4145 HFE-594.
What's changed
handleImportToStore
function promise resolution is awaited.loading
prop to theFileImport
&UrlImport
components that default tofalse
- toggles theImport
CTA loading state accordingly. The import CTA stays disabled during a loading state.loading
prop to theMyCollectionImport
component to handle the loading state with import from personal collections flow while at a team workspace.FileSource()
&UrlSource()
functions now include a newisLoading
parameter via which the above state variables are supplied from the respective component.Note to reviewers
Please verify the import collections/environments flow e2e.