Skip to content
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

Cosmos infra #212

Merged
merged 3 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,832 changes: 1,988 additions & 1,844 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"dependencies": {
"@bbc/aes31-adl-composer": "^1.1.0",
"@bbc/digital-paper-edit-storybook": "^1.21.0",
"@bbc/digital-paper-edit-storybook": "^1.22.0",
"@bbc/fcpx-xml-composer": "^1.0.0",
"@bbc/react-transcript-editor": "^1.4.0",
"@datapunt/matomo-tracker-react": "^0.3.1",
Expand Down Expand Up @@ -70,7 +70,7 @@
"deploy:all": "rimraf build && npm run build && firebase deploy",
"deploy:ghpages": "rimraf build && cross-env REACT_APP_NODE_ENV=demo npm run build && gh-pages -d build",
"deploy:dev:hosting": "rimraf build && npm run build && firebase deploy -P dev --only hosting:digital-paper-edit-dev",
"deploy:prod:hosting": "rimraf build && npm run build && firebase deploy -P prod --only hosting:digital-paper-edit",
"deploy:prod:hosting": "rimraf build && npm run build && firebase deploy -P prod --only hosting:digital-paper-edit-prod",
"publish:prep": "npm run build && cp package.json ./build/package.json && cp README.md ./build/README.md && rimraf ./build/db",
"publish:public": "npm run publish:prep && npm publish build --access public"
},
Expand Down
16 changes: 14 additions & 2 deletions src/Components/Admin/TranscriptsView/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ const Row = ({
return <Badge variant={ variant }>{status}</Badge>;
};

let mediaRef = '';
let mediaType = '';

try {
mediaRef = media.ref;
mediaType = media.type;
} catch (err) {
console.error(
`Transcript ID: ${ transcriptId } for Project ${ projectId } should be removed:`,
err.message);
}

return (
<tr key={ transcriptId }>
<td>{getStatusBadge(status)}</td>
Expand All @@ -56,8 +68,8 @@ const Row = ({
<td>{dhmsRuntime}</td>
<td>{ToDhmsCompact(duration)}</td>
<td>{size}</td>
<td>{media.ref}</td>
<td>{media.type}</td>
<td>{mediaRef}</td>
<td>{mediaType}</td>
</tr>
);
};
Expand Down
15 changes: 13 additions & 2 deletions src/Components/Admin/TranscriptsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ const TranscriptsView = props => {
const getDataForRows = async (title, tr, user) => {
const Uploads = new Collection(props.firebase, `users/${ user }/uploads`);
const upload = await Uploads.getItem(tr.id);
let duration = 0;
let size = 0;

try {
duration = upload.duration;
size = upload.size;
} catch (err) {
console.error(
`Transcript ID: ${ tr.id } for User ${ user } should be removed:`,
err.message);
}

return {
transcriptId: tr.id,
Expand All @@ -48,8 +59,8 @@ const TranscriptsView = props => {
status: tr.status,
created: tr.created,
updated: tr.updated,
duration: upload.duration,
size:upload.size,
duration: duration,
size: size,
};
};

Expand Down
18 changes: 15 additions & 3 deletions src/Components/Analytics/AnalyticsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@ import React, { useEffect, useState } from 'react';
import { MatomoProvider, createInstance } from '@datapunt/matomo-tracker-react';
import { useMatomo } from '@datapunt/matomo-tracker-react';
import PropTypes from 'prop-types';
import isProduction from '../../Util/is-production';

const instance = createInstance({
const prodConfig = {
urlBase: process.env.REACT_APP_MATOMO_BASE,
siteId: process.env.REACT_APP_MATOMO_SITEID,
trackerUrl: process.env.REACT_APP_MATOMO_TRACKER, // optional, default value: `${urlBase}matomo.php`
srcUrl: process.env.REACT_APP_MATOMO_SRC, // optional, default value: `${urlBase}matomo.js`
});
srcUrl: process.env.REACT_APP_MATOMO_SRC // optional, default value: `${urlBase}matomo.js`
};

const devConfig = {
urlBase: process.env.REACT_APP_TEST_MATOMO_BASE,
siteId: process.env.REACT_APP_TEST_MATOMO_SITEID,
trackerUrl: process.env.REACT_APP_TEST_MATOMO_TRACKER, // optional, default value: `${urlBase}matomo.php`
srcUrl: process.env.REACT_APP_TEST_MATOMO_SRC, // optional, default value: `${urlBase}matomo.js`
};

const config = isProduction() ? prodConfig : devConfig;

const instance = createInstance(config);

const AnalyticsProvider = props => (
<MatomoProvider value={ instance }>
Expand Down
31 changes: 23 additions & 8 deletions src/Components/Firebase/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ import app from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import 'firebase/storage';
import isProduction from '../../Util/is-production';

const config = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID
};
let config;
if (isProduction()) {
config = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID
};
} else {
config = {
apiKey: process.env.REACT_APP_TEST_API_KEY,
authDomain: process.env.REACT_APP_TEST_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_TEST_DATABASE_URL,
projectId: process.env.REACT_APP_TEST_PROJECT_ID,
storageBucket: process.env.REACT_APP_TEST_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_TEST_MESSAGING_SENDER_ID
};
}

console.log('config: ', config);
class Firebase {
constructor() {
app.initializeApp(config);
Expand Down
14 changes: 14 additions & 0 deletions src/Util/is-production/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import url from 'url';

const isProduction = () => {
const parsedUrl = url.parse(window.location.href, true);

if ((parsedUrl.host) === 'digital-paper-edit.tools.bbc.co.uk') {
return true;
}

return false;

};

export default isProduction;
4 changes: 3 additions & 1 deletion src/serviceWorker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This optional code is used to register a service worker.
// register() is not called by default.

import isProduction from './Util/is-production';

// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
Expand All @@ -21,7 +23,7 @@ const isLocalhost = Boolean(
);

export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
if (isProduction() && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
Expand Down