-
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
18 changed files
with
346 additions
and
35 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 |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import React from 'react'; | ||
| import { format } from 'date-fns'; | ||
|
|
||
| export default function FormattedDate ({ date }) { | ||
| const formatted = React.useMemo(() => format(new Date(date), 'MMM Lo, Y'), [date]); | ||
| export default function FormattedDate ({ date, time = false }) { | ||
| const formatted = React.useMemo(() => format(new Date(date), `MMM Lo, Y${time ? ' HH:mm:ss' : ''}`), [date, time]); | ||
|
|
||
| return (<>{ formatted }</>); | ||
| } |
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
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,33 @@ | ||
| import React from 'react'; | ||
| import { Switch, Route, useRouteMatch } from 'react-router-dom'; | ||
| import { MetadataOptions } from './component/MetadataOptions'; | ||
| import { MetadataDetail } from './component/MetadataDetail'; | ||
| import { MetadataHistory } from './component/MetadataHistory'; | ||
| import { MetadataEditor } from './editor/MetadataEditor'; | ||
| import { MetadataSelector } from './hoc/MetadataSelector'; | ||
| import MetadataSchema from './hoc/MetadataSchema'; | ||
|
|
||
| export function Metadata () { | ||
|
|
||
| let { path } = useRouteMatch(); | ||
|
|
||
| return ( | ||
| <MetadataSelector> | ||
| <MetadataSchema> | ||
| <Switch> | ||
| <Route path={`${path}/configuration/options`} render={ () => | ||
| <MetadataDetail> | ||
| <MetadataOptions></MetadataOptions> | ||
| </MetadataDetail> | ||
| } /> | ||
| <Route path={`${path}/configuration/history`} render={ () => | ||
| <MetadataDetail> | ||
| <MetadataHistory></MetadataHistory> | ||
| </MetadataDetail> | ||
| } /> | ||
| <Route path={`${path}/edit`} component={ MetadataEditor } /> | ||
| </Switch> | ||
| </MetadataSchema> | ||
| </MetadataSelector> | ||
| ); | ||
| } |
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 React from 'react'; | ||
|
|
||
| export function MetadataConfiguration () { | ||
| return ( | ||
| <></> | ||
| ); | ||
| } |
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,33 @@ | ||
| import React from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| import { MetadataObjectContext } from '../hoc/MetadataSelector'; | ||
|
|
||
| export function MetadataDetail ({ children }) { | ||
|
|
||
| const metadata = React.useContext(MetadataObjectContext); | ||
|
|
||
| return ( | ||
| <div className="container-fluid p-3"> | ||
| <section className="section" tabIndex="0"> | ||
| <div className="section-body px-4 pb-4 border border-info"> | ||
| <nav aria-label="breadcrumb"> | ||
| <ol className="breadcrumb breadcrumb-bar"> | ||
| <li className="breadcrumb-item"> | ||
| <Link to="/dashboard"><Translate value="action.dashboard">Dashboard</Translate></Link> | ||
| </li> | ||
| <li className="breadcrumb-item active" aria-current="page"> | ||
| <span className="display-6"> | ||
| { metadata.serviceProviderName || metadata.name } | ||
| </span> | ||
| </li> | ||
| </ol> | ||
| </nav> | ||
| { children } | ||
| </div> | ||
| </section> | ||
| </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,35 @@ | ||
| import React from 'react'; | ||
| import FormattedDate from '../../core/components/FormattedDate'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| export function MetadataHeader ({ model, current = true, enabled = true }) { | ||
| return ( | ||
| <div className="card enabled-status"> | ||
| <div className="card-body"> | ||
| <div className="d-flex justify-content-between"> | ||
| <h5 className="card-title version-title"> | ||
| <Translate value="label.saved">Saved</Translate>: | ||
| <span className="save-date"> | ||
| <FormattedDate date={model.modifiedDate} time={true} /> | ||
| </span> | ||
| <br /> | ||
| <Translate value="label.by">By</Translate>: | ||
| <span className="author">{model.createdBy }</span> | ||
| </h5> | ||
|
|
||
| </div> | ||
|
|
||
| <p className="card-text"> | ||
| <span className={`badge badge-${enabled ? 'primary' : 'danger' }`}> | ||
| <Translate value={`value.${enabled ? 'enabled' : 'disabled'}`}>Enabled</Translate> | ||
| </span> | ||
| | ||
| <span className={`badge badge-${current ? 'primary' : 'warning'}`}> | ||
| <Translate value={`value.${current ? 'current' : 'not-current'}`}>Current</Translate> | ||
| </span> | ||
| </p> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| export function MetadataHistory () { | ||
| return ( | ||
| <> | ||
| <h2 className="mb-4"> | ||
| <Translate value={`label.version-history`}>version history</Translate> | ||
| </h2> | ||
| </> | ||
| ); | ||
| } |
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,56 @@ | ||
| import { faArrowDown, faHistory } from '@fortawesome/free-solid-svg-icons'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import React from 'react'; | ||
| import { Link, useParams } from 'react-router-dom'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| import { MetadataObjectContext } from '../hoc/MetadataSelector'; | ||
| import { MetadataHeader } from './MetadataHeader'; | ||
|
|
||
| export function MetadataOptions () { | ||
|
|
||
| const metadata = React.useContext(MetadataObjectContext); | ||
|
|
||
| const { type, id } = useParams(); | ||
|
|
||
| return ( | ||
| <> | ||
| <h2 className="mb-4"> | ||
| <Translate value={`label.${type}-configuration`}>[{type}] configuration</Translate> | ||
| </h2> | ||
| <div className="container"> | ||
| <MetadataHeader | ||
| current={true} | ||
| enabled={type === 'source' ? metadata.enabled : metadata.serviceEnabled} | ||
| model={metadata} /> | ||
| <div className="px-3 my-3 d-flex justify-content-between" id="navigation"> | ||
| <div> | ||
| <Link className="btn btn-link" to={`/metadata/${type}/${id}/configuration/history`}> | ||
| <FontAwesomeIcon icon={ faHistory } /> | ||
| <Translate value="action.version-history">Version History</Translate> | ||
| </Link> | ||
| {type === 'provider' && | ||
| <button className="btn btn-link" onClick={"onScrollTo('filters')"}> | ||
| <FontAwesomeIcon icon={faArrowDown} /> | ||
| <Translate value="label.filters">Filters</Translate> | ||
| </button> | ||
| } | ||
| </div> | ||
| {/*<div *ngIf="hasXml$ | async"> | ||
| <div className="btn-group" role="group" aria-label="Options selected"> | ||
| <a className="btn" routerLink="../options" routerLinkActive="btn-primary" aria-pressed="true"> | ||
| <span className="sr-only"><Translate value="action.toggle-view">Toggle view:</Translate></span> | ||
| Options | ||
| </a> | ||
| <a className="btn" routerLink="../xml" routerLinkActive="btn-primary"> | ||
| <span className="sr-only"><Translate value="action.toggle-view">Toggle view:</Translate></span> | ||
| XML | ||
| </a> | ||
| </div> | ||
| </div>*/} | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| import { MetadataObjectContext, MetadataTypeContext } from '../hoc/MetadataSelector'; | ||
|
|
||
| export function MetadataEditor () { | ||
|
|
||
| const metadata = React.useContext(MetadataObjectContext); | ||
| const type = React.useContext(MetadataTypeContext); | ||
|
|
||
| return ( | ||
| <section className="section" aria-label={`Edit metadata ${type} - ${metadata.serviceProviderName || metadata.name }`} tabIndex="0"> | ||
| <div className="section-header bg-info p-2 text-white"> | ||
| <div className="row justify-content-between"> | ||
| <div className="col-md-12"> | ||
| <span className="display-6"> | ||
| <i className="fa fa-fw fa-gears"></i> | ||
| Edit metadata { type } - {metadata.serviceProviderName || metadata.name} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
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,36 @@ | ||
| import React from 'react'; | ||
| import { useParams } from 'react-router'; | ||
| import { useMetadataSchema, getSchemaPath } from '../hooks/api'; | ||
|
|
||
| export const MetadataSchemaContext = React.createContext(); | ||
|
|
||
|
|
||
| export function MetadataSchema({ children }) { | ||
|
|
||
| let { type } = useParams(); | ||
|
|
||
| const { get, response } = useMetadataSchema(); | ||
|
|
||
| const [schema, setSchema] = React.useState([]); | ||
|
|
||
| async function loadSchema(t) { | ||
| const source = await get(`/${getSchemaPath(t)}`) | ||
| if (response.ok) { | ||
| setSchema(source); | ||
| } | ||
| } | ||
|
|
||
| React.useEffect(() => { loadSchema(type) }, [type]); | ||
|
|
||
| return ( | ||
| <> | ||
| {type && | ||
| <MetadataSchemaContext.Provider value={type}> | ||
| {children} | ||
| </MetadataSchemaContext.Provider> | ||
| } | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default MetadataSchema; |
Oops, something went wrong.