-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2084] Enable Self Service Data Upload (Dromo) #692
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
Merged
mazursasha1990
merged 29 commits into
main
from
OSDEV-2084-enable-self-service-data-upload-dromo
Jul 18, 2025
Merged
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9538958
Integrate Dromo uploader with correct CDN and initialization
wonderchook 8009e71
Add Beta Self Service Upload button and separate upload methods
wonderchook 875c95f
Update Beta Self Service Upload button styling to green with white text
wonderchook b6dbdd4
Merge branch 'main' into OSDEV-2084-enable-self-service-data-upload-d…
mazursasha1990 05cbb3a
Merge branch 'main' into OSDEV-2084-enable-self-service-data-upload-d…
mazursasha1990 2ccadb4
Add dromo-uploader-react package
mazursasha1990 6944991
Add SelfServiceUploader component
mazursasha1990 3f62904
Add processDromoResults util function
mazursasha1990 80e5b7e
Revert changes from index.html
mazursasha1990 01c9e24
Use SelfServiceUploader in the ContributeForm.jsx
mazursasha1990 e8a22b9
Revert "Add dromo-uploader-react package"
mazursasha1990 dc63113
Add dromo-uploader-react package
mazursasha1990 55b5cfa
Merge branch 'main' into OSDEV-2084-enable-self-service-data-upload-d…
mazursasha1990 ea1f52e
Add migration that creates enable_dromo_uploading switch
mazursasha1990 21c7d9f
Use enable_dromo_uploading switch in the ContribureForm component
mazursasha1990 a1c1fbe
Format 0176_introduce_enable_dromo_uploading_switch migration
mazursasha1990 57fd331
Rename SelfServiceUploader to SelfServiceDromoUploader
mazursasha1990 a64afa2
Add tests for the processDromoResults util function
mazursasha1990 7a4d40f
Add tests for SelfServiceDromoUploader component
mazursasha1990 bf91bee
Add additional spaces to the SelfServiceDromoUploader.test.jsx
mazursasha1990 2ae5b66
Rename local variable Switch to switch in the 0176_introduce_enable_d…
mazursasha1990 dd29b98
Fix linter issues
mazursasha1990 f7f62e5
Fix linter issue in SelfServiceDromoUploader.jsx
mazursasha1990 14a8530
Fix migration name
mazursasha1990 ef8e04e
Add release notes
mazursasha1990 7430a64
Remove extra space before .py in the release notes
mazursasha1990 9c71c88
Add dromo keys to the environment variables
mazursasha1990 11bdab4
Modify .env.sample and remove redundant console.log statement
mazursasha1990 df25344
Mark dromo_license_key and dromo_schema_id variables as sensitive
mazursasha1990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/django/api/migrations/0176_introduce_enable_dromo_uploading_switch .py
This file contains hidden or 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,28 @@ | ||
| from django.db import migrations | ||
|
|
||
|
|
||
| def create_enable_dromo_uploading_switch(apps, schema_editor): | ||
| switch = apps.get_model('waffle', 'Switch') | ||
| switch.objects.create(name='enable_dromo_uploading', active=False) | ||
|
|
||
|
|
||
| def delete_enable_dromo_uploading_switch(apps, schema_editor): | ||
| switch = apps.get_model('waffle', 'Switch') | ||
| switch.objects.get(name='enable_dromo_uploading').delete() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| """ | ||
| Migration to introduce a switch for enabling Dromo uploading. | ||
| """ | ||
|
|
||
| dependencies = [ | ||
| ('api', '0175_increase_path_max_length'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| create_enable_dromo_uploading_switch, | ||
| delete_enable_dromo_uploading_switch, | ||
| ) | ||
| ] | ||
This file contains hidden or 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
90 changes: 90 additions & 0 deletions
90
src/react/src/__tests__/components/SelfServiceDromoUploader.test.jsx
This file contains hidden or 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,90 @@ | ||
| import React from 'react'; | ||
| import { render, fireEvent } from '@testing-library/react'; | ||
| import SelfServiceDromoUploader from '../../components/SelfServiceDromoUploader'; | ||
| import { processDromoResults } from '../../util/util'; | ||
|
|
||
| jest.mock('dromo-uploader-react', () => function MockDromoUploader({ open, onCancel, onResults }) { | ||
| return ( | ||
| <div data-testid="dromo-uploader" data-open={open ? 'true' : 'false'}> | ||
| <button | ||
| type='button' | ||
| data-testid="dromo-cancel-button" | ||
| onClick={onCancel} | ||
| > | ||
| Cancel | ||
| </button> | ||
| {onResults && ( | ||
| <button | ||
| type='button' | ||
| data-testid="dromo-results-button" | ||
| onClick={() => onResults([{ foo: 'bar' }], { filename: 'test.csv' })} | ||
| > | ||
| Simulate Results | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| }); | ||
|
|
||
| jest.mock('@material-ui/core/Button', () => (props) => ( | ||
| <button type='button' {...props}>{props.children}</button> | ||
| )); | ||
|
|
||
| jest.mock('../../util/util', () => ({ | ||
| processDromoResults: jest.fn(), | ||
| })); | ||
|
|
||
|
|
||
| describe('SelfServiceDromoUploader component', () => { | ||
| const fileInput = {}; | ||
| const updateFileName = jest.fn(); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('renders the upload button', () => { | ||
| const { getByText } = render(<SelfServiceDromoUploader fileInput={fileInput} updateFileName={updateFileName} />); | ||
|
|
||
| expect(getByText('Beta Self Service Upload')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('opens the uploader when button is clicked', () => { | ||
| const { getByText, getByTestId } = render( | ||
| <SelfServiceDromoUploader fileInput={fileInput} updateFileName={updateFileName} /> | ||
| ); | ||
|
|
||
| fireEvent.click(getByText('Beta Self Service Upload')); | ||
|
|
||
| expect(getByTestId('dromo-uploader')).toHaveAttribute('data-open', 'true'); | ||
| }); | ||
|
|
||
| it('calls onCancel and closes uploader', () => { | ||
| const { getByText, getByTestId } = render( | ||
| <SelfServiceDromoUploader fileInput={fileInput} updateFileName={updateFileName} /> | ||
| ); | ||
|
|
||
| fireEvent.click(getByText('Beta Self Service Upload')); | ||
| fireEvent.click(getByTestId('dromo-cancel-button')); | ||
|
|
||
| expect(getByTestId('dromo-uploader')).toHaveAttribute('data-open', 'false'); | ||
| }); | ||
|
|
||
| it('handles Dromo results and calls processDromoResults', () => { | ||
| const { getByText, getByTestId } = render( | ||
| <SelfServiceDromoUploader fileInput={fileInput} updateFileName={updateFileName} /> | ||
| ); | ||
|
|
||
| fireEvent.click(getByText('Beta Self Service Upload')); | ||
| fireEvent.click(getByTestId('dromo-results-button')); | ||
|
|
||
| expect(processDromoResults).toHaveBeenCalledWith( | ||
| [{ foo: 'bar' }], | ||
| 'test.csv', | ||
| fileInput, | ||
| updateFileName | ||
| ); | ||
|
|
||
| expect(getByTestId('dromo-uploader')).toHaveAttribute('data-open', 'false'); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
| import React, { useState } from 'react'; | ||
| import { object, func } from 'prop-types'; | ||
| import DromoUploader from 'dromo-uploader-react'; | ||
| import MaterialButton from '@material-ui/core/Button'; | ||
| import { processDromoResults } from '../util/util'; | ||
|
|
||
| const uploaderButtonStyle = Object.freeze({ | ||
| backgroundColor: '#62CC74', | ||
| color: 'white', | ||
| }); | ||
|
|
||
| const SelfServiceDromoUploader = ({ fileInput, updateFileName }) => { | ||
| const [isUploaderOpen, setIsUploaderOpen] = useState(false); | ||
|
|
||
| const openUploader = () => setIsUploaderOpen(true); | ||
| const closeUploader = () => setIsUploaderOpen(false); | ||
|
|
||
| const handleDromoResults = (results, metadata) => { | ||
| const { filename } = metadata; | ||
|
|
||
| processDromoResults(results, filename, fileInput, updateFileName); | ||
| closeUploader(); | ||
| }; | ||
mazursasha1990 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <> | ||
| <MaterialButton | ||
| onClick={openUploader} | ||
| type="button" | ||
| variant="contained" | ||
| style={uploaderButtonStyle} | ||
| disableRipple | ||
| > | ||
| Beta Self Service Upload | ||
| </MaterialButton> | ||
|
|
||
| <DromoUploader | ||
| licenseKey="ee427cf5-da27-4f28-a260-c9a17d02ad30" | ||
vladsha-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| schemaId="6f3e129c-d724-4b80-b2c9-8e54b47e8017" | ||
mazursasha1990 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| open={isUploaderOpen} | ||
| onCancel={closeUploader} | ||
| onResults={handleDromoResults} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| SelfServiceDromoUploader.propTypes = { | ||
| fileInput: object.isRequired, | ||
| updateFileName: func.isRequired, | ||
| }; | ||
|
|
||
| export default SelfServiceDromoUploader; | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.