-
Notifications
You must be signed in to change notification settings - Fork 81
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: Taxonomy export menu [FC-0036] #645
Merged
ormsbee
merged 21 commits into
openedx:master
from
open-craft:chris/FAL-3528-taxonomy-export-menu
Nov 14, 2023
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4963124
feat: System-defined tooltip added
ChrisChV 4077397
feat: Taxonomy card menu added. Export menu item added
ChrisChV e87c545
feat: Modal for export taxonomy
ChrisChV 4922420
feat: Connect with export API
ChrisChV 5e12a8f
test: Tests for API and selectors
ChrisChV 09aa8b6
feat: Use windows.location.href to call the export endpoint
ChrisChV 1925fae
test: ExportModal.test added
ChrisChV 0be804c
style: Delete unnecesary code
ChrisChV da0156f
Merge branch 'master' into chris/FAL-3528-taxonomy-export-menu
rpenido 0cc473c
Merge branch 'master' into chris/FAL-3528-taxonomy-export-menu
ChrisChV 5af8d66
docs: README updated with taxonomy feature
ChrisChV a21fac2
style: TaxonomyCard updated to a better code style
ChrisChV 61864d3
style: injectIntl replaced by useIntl on taxonomy pages and components
ChrisChV b09b86a
refactor: Move and rename taxonomy UI components to match 0002 ADR
ChrisChV df8432d
refactor: Move api to data to match with 0002 ADR
ChrisChV 1abf034
test: Refactor ExportModal tests
1d6f9a5
chore: Merge conflicts solved
5c4c87a
chore: Fix validations
ChrisChV 7e514b6
chore: Lint
ChrisChV 080b03e
refactor: Moving hooks to apiHooks
ChrisChV 16233fb
style: Nit on return null
ChrisChV 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as taxonomyListMock } from './taxonomyListMock'; |
This file contains 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,50 @@ | ||
module.exports = { | ||
next: null, | ||
previous: null, | ||
count: 4, | ||
numPages: 1, | ||
currentPage: 1, | ||
start: 0, | ||
results: [ | ||
{ | ||
id: -2, | ||
name: 'Content Authors', | ||
description: 'Allows tags for any user ID created on the instance.', | ||
enabled: true, | ||
allowMultiple: false, | ||
allowFreeText: false, | ||
systemDefined: true, | ||
visibleToAuthors: false, | ||
}, | ||
{ | ||
id: -1, | ||
name: 'Languages', | ||
description: 'lang lang lang lang lang lang lang lang', | ||
enabled: true, | ||
allowMultiple: false, | ||
allowFreeText: false, | ||
systemDefined: true, | ||
visibleToAuthors: true, | ||
}, | ||
{ | ||
id: 1, | ||
name: 'Taxonomy', | ||
description: 'This is a Description', | ||
enabled: true, | ||
allowMultiple: false, | ||
allowFreeText: false, | ||
systemDefined: false, | ||
visibleToAuthors: true, | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Taxonomy long long long long long long long long long long long long long long long long long long long', | ||
description: 'This is a Description long lon', | ||
enabled: true, | ||
allowMultiple: false, | ||
allowFreeText: false, | ||
systemDefined: false, | ||
visibleToAuthors: true, | ||
}, | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,29 @@ | ||
// @ts-check | ||
import { camelCaseObject, getConfig } from '@edx/frontend-platform'; | ||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; | ||
|
||
const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; | ||
export const getTaxonomyListApiUrl = () => new URL('api/content_tagging/v1/taxonomies/?enabled=true', getApiBaseUrl()).href; | ||
export const getExportTaxonomyApiUrl = (pk, format) => new URL( | ||
`api/content_tagging/v1/taxonomies/${pk}/export/?output_format=${format}&download=1`, | ||
getApiBaseUrl(), | ||
).href; | ||
|
||
/** | ||
* Get list of taxonomies. | ||
* @returns {Promise<Object>} | ||
*/ | ||
export async function getTaxonomyListData() { | ||
const { data } = await getAuthenticatedHttpClient().get(getTaxonomyListApiUrl()); | ||
return camelCaseObject(data); | ||
} | ||
|
||
/** | ||
* Downloads the file of the exported taxonomy | ||
* @param {number} pk | ||
* @param {string} format | ||
* @returns {void} | ||
*/ | ||
export function getTaxonomyExportFile(pk, format) { | ||
window.location.href = getExportTaxonomyApiUrl(pk, format); | ||
} |
This file contains 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,61 @@ | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import { initializeMockApp } from '@edx/frontend-platform'; | ||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; | ||
|
||
import { taxonomyListMock } from '../__mocks__'; | ||
|
||
import { | ||
getTaxonomyListApiUrl, | ||
getExportTaxonomyApiUrl, | ||
getTaxonomyListData, | ||
getTaxonomyExportFile, | ||
} from './api'; | ||
|
||
let axiosMock; | ||
|
||
describe('taxonomy api calls', () => { | ||
const { location } = window; | ||
beforeEach(() => { | ||
initializeMockApp({ | ||
authenticatedUser: { | ||
userId: 3, | ||
username: 'abc123', | ||
administrator: true, | ||
roles: [], | ||
}, | ||
}); | ||
axiosMock = new MockAdapter(getAuthenticatedHttpClient()); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
beforeAll(() => { | ||
delete window.location; | ||
window.location = { | ||
href: '', | ||
}; | ||
}); | ||
|
||
afterAll(() => { | ||
window.location = location; | ||
}); | ||
|
||
it('should get taxonomy list data', async () => { | ||
axiosMock.onGet(getTaxonomyListApiUrl()).reply(200, taxonomyListMock); | ||
const result = await getTaxonomyListData(); | ||
|
||
expect(axiosMock.history.get[0].url).toEqual(getTaxonomyListApiUrl()); | ||
expect(result).toEqual(taxonomyListMock); | ||
}); | ||
|
||
it('should set window.location.href correctly', () => { | ||
const pk = 1; | ||
const format = 'json'; | ||
|
||
getTaxonomyExportFile(pk, format); | ||
|
||
expect(window.location.href).toEqual(getExportTaxonomyApiUrl(pk, format)); | ||
}); | ||
}); |
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.
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.
nit:
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.
This is correct, but all the other feature flags use
contentstore.new_studio_mfe...
so that was a small mistake on our part. Doesn't really matter though.