-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
834 additions
and
41 deletions.
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
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,7 @@ | ||
| import * as FileSaver from 'file-saver'; | ||
|
|
||
| export const downloadAsXml = (entity, xml) => { | ||
| const name = entity.name ? entity.name : entity.serviceProviderName; | ||
| const blob = new Blob([xml], { type: 'text/xml;charset=utf-8' }); | ||
| FileSaver.saveAs(blob, `${name}.xml`); | ||
| } |
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 |
|---|---|---|
| @@ -1,13 +1,85 @@ | ||
| import React from 'react'; | ||
| import { useParams } from 'react-router'; | ||
| import { Link } from 'react-router-dom'; | ||
| import FormattedDate from '../../core/components/FormattedDate'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
| import { useMetadataHistory } from '../hooks/api'; | ||
|
|
||
| export function MetadataHistory () { | ||
| const { type, id } = useParams(); | ||
|
|
||
| const { data, loading } = useMetadataHistory(type, id, {}, []); | ||
|
|
||
| const toggleVersionSelected = () => {}; | ||
| const restore = () => {}; | ||
| const compare = () => {}; | ||
|
|
||
| const selected = []; | ||
|
|
||
| return ( | ||
| <> | ||
| <h2 className="mb-4"> | ||
| <Translate value={`label.version-history`}>version history</Translate> | ||
| <Translate value="label.version-history">version history</Translate> | ||
| </h2> | ||
| {data && !loading && <div className="container"> | ||
| <> | ||
| <table className="table"> | ||
| <caption className="sr-only"><Translate value="label.name-and-entityid">Metadata Version History</Translate></caption> | ||
| <thead> | ||
| <tr> | ||
| <th scope="col"> | ||
| <span className="sr-only"><Translate value="label.select-version">Select Version</Translate></span> | ||
| </th> | ||
| <th scope="col"><Translate value="label.save-date">Save Date</Translate></th> | ||
| <th scope="col"><Translate value="label.changed-by">Changed By</Translate></th> | ||
| <th scope="col"><Translate value="label.actions">Actions</Translate></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {data.map((version, i) => | ||
| <tr key={i}> | ||
| <td> | ||
| <div className="custom-control custom-checkbox" onClick={() => toggleVersionSelected(version)}> | ||
| <input title={`check-${i}`} type="checkbox" className="custom-control-input" checked={selected.indexOf(version) > -1} onChange={() => {}} /> | ||
| <label className="custom-control-label" htmlFor={`check-${i}`}> | ||
| <span className="sr-only"><Translate value="label.check-to-select">Check to select</Translate></span> | ||
| </label> | ||
| </div> | ||
| </td> | ||
| <td> | ||
| {i === 0 ? <Link to="['../', 'options']"> | ||
| <FormattedDate date={version.date} /> (<Translate value="label.current">Current</Translate>) | ||
| </Link> | ||
| : | ||
| <Link to="['../', 'version', version.id, 'options']"> | ||
| <FormattedDate date={version.date} /> | ||
| </Link> | ||
| } | ||
| </td> | ||
| <td>{ version.creator }</td> | ||
| <td> | ||
| {i > 0 && | ||
| <button className="btn btn-text btn-link" onClick={ () => restore(version) }> | ||
| <i className="fa fa-undo"></i> | ||
| <Translate value="action.restore">Restore</Translate> | ||
| </button> | ||
| } | ||
| </td> | ||
| </tr> | ||
| )} | ||
| </tbody> | ||
| </table> | ||
| <button className="btn btn-primary" onClick={ () => compare() } disabled={!selected.length}> | ||
| <Translate value="label.compare-selected">Compare Selected</Translate> | ||
| {selected.length > 0 && <span>({ selected.length })</span> } | ||
| </button> | ||
| </> | ||
| </div>} | ||
| {loading && <div className="d-flex justify-content-center"> | ||
| <i className="fa fa-spinner fa-pulse fa-4x fa-fw"></i> | ||
| <span className="sr-only">Loading...</span> | ||
| </div>} | ||
| </> | ||
| ); | ||
| } |
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,26 @@ | ||
| import React from 'react'; | ||
| import { NavLink } from 'react-router-dom'; | ||
|
|
||
| import {Translate} from '../../i18n/components/translate'; | ||
| import { MetadataXmlContext } from '../hoc/MetadataXmlLoader'; | ||
|
|
||
| export function MetadataViewToggle () { | ||
| const xml = React.useContext(MetadataXmlContext); | ||
|
|
||
| return ( | ||
| <> | ||
| {xml ? | ||
| <div className="btn-group" role="group" aria-label="Options selected"> | ||
| <NavLink className="btn" to="options" activeClassName="btn-primary" aria-pressed="true"> | ||
| <span className="sr-only"><Translate value="action.toggle-view">Toggle view:</Translate></span> | ||
| Options | ||
| </NavLink> | ||
| <NavLink className="btn" to="xml" activeClassName="btn-primary"> | ||
| <span className="sr-only"><Translate value="action.toggle-view">Toggle view:</Translate></span> | ||
| XML | ||
| </NavLink> | ||
| </div> | ||
| : ''} | ||
| </> | ||
| ); | ||
| } |
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,45 @@ | ||
| import { faSave } from '@fortawesome/free-solid-svg-icons'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import React from 'react'; | ||
|
|
||
| import { useParams } from 'react-router'; | ||
| import Translate from '../../i18n/components/translate'; | ||
| import { MetadataObjectContext } from '../hoc/MetadataSelector'; | ||
|
|
||
| import { MetadataXmlContext } from '../hoc/MetadataXmlLoader'; | ||
| import { MetadataViewToggle } from './MetadataViewToggle'; | ||
| import { downloadAsXml } from '../../core/utility/download_as_xml'; | ||
|
|
||
| export function MetadataXml () { | ||
| const xml = React.useContext(MetadataXmlContext); | ||
| const entity = React.useContext(MetadataObjectContext); | ||
| const { type } = useParams(); | ||
|
|
||
| const download = () => downloadAsXml(entity, xml); | ||
|
|
||
| return ( | ||
| <> | ||
| <h2 className="mb-4"> | ||
| <Translate value={type === 'source' ? 'label.source' : 'label.provider'}>Source</Translate> Configuration | ||
| </h2> | ||
| <div className="container-fluid"> | ||
| <div className="px-3 my-3 d-flex justify-content-end"> | ||
| <MetadataViewToggle /> | ||
| </div> | ||
| <div className="px-3 my-3"> | ||
| <figure role="img" aria-labelledby="pre-caption" tabIndex="0"> | ||
| <pre className="border p-2 bg-light rounded"><code>{xml}</code></pre> | ||
| <figcaption id="pre-caption" className="sr-only"> | ||
| { xml } | ||
| </figcaption> | ||
| </figure> | ||
|
|
||
| <button type="button" className="btn btn-primary" onClick={() => download()}> | ||
| <FontAwesomeIcon icon={faSave} /> | ||
| <Translate value="action.download-file">Download File</Translate> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } |
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
26 changes: 26 additions & 0 deletions
26
ui/src/app/metadata/domain/provider/BaseProviderDefinition.js
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,26 @@ | ||
| import { metadataFilterProcessor } from './utility/providerFilterProcessor'; | ||
|
|
||
| export const BaseProviderDefinition = { | ||
| schemaPreprocessor: metadataFilterProcessor, | ||
| parser: (changes) => (changes.metadataFilters ? ({ | ||
| ...changes, | ||
| metadataFilters: [ | ||
| ...Object.keys(changes.metadataFilters).reduce((collection, filterName) => ([ | ||
| ...collection, | ||
| { | ||
| ...changes.metadataFilters[filterName], | ||
| '@type': filterName | ||
| } | ||
| ]), []) | ||
| ] | ||
| }) : changes), | ||
| formatter: (changes) => (changes.metadataFilters ? ({ | ||
| ...changes, | ||
| metadataFilters: { | ||
| ...(changes.metadataFilters || []).reduce((collection, filter) => ({ | ||
| ...collection, | ||
| [filter['@type']]: filter | ||
| }), {}) | ||
| } | ||
| }) : changes), | ||
| } |
Oops, something went wrong.