Skip to content

Commit 34d3f91

Browse files
authored
Merge pull request #1341 from bbc/upstream/tidying
chore: some minor changes
2 parents b66de77 + 83c11bf commit 34d3f91

File tree

5 files changed

+63
-116
lines changed

5 files changed

+63
-116
lines changed

meteor/__mocks__/meteor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ export namespace MeteorMock {
195195
// but it'll do for now:
196196
return callAsync(methodName, ...args)
197197
}
198-
export function absoluteUrl(path?: string): string {
199-
return path + '' // todo
200-
}
201198
export function setTimeout(fcn: () => void | Promise<void>, time: number): number {
202199
return $.setTimeout(() => {
203200
Promise.resolve()

meteor/server/migration/X_X_X.ts

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -199,43 +199,6 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
199199
},
200200
},
201201

202-
{
203-
id: `add studio settings allowHold & allowPieceDirectPlay`,
204-
canBeRunAutomatically: true,
205-
validate: async () => {
206-
const studios = await Studios.findFetchAsync({
207-
$or: [
208-
{ 'settings.allowHold': { $exists: false } },
209-
{ 'settings.allowPieceDirectPlay': { $exists: false } },
210-
],
211-
})
212-
213-
if (studios.length > 0) {
214-
return 'studios must have settings.allowHold and settings.allowPieceDirectPlay defined'
215-
}
216-
217-
return false
218-
},
219-
migrate: async () => {
220-
const studios = await Studios.findFetchAsync({
221-
$or: [
222-
{ 'settings.allowHold': { $exists: false } },
223-
{ 'settings.allowPieceDirectPlay': { $exists: false } },
224-
],
225-
})
226-
227-
for (const studio of studios) {
228-
// Populate the settings to be backwards compatible
229-
await Studios.updateAsync(studio._id, {
230-
$set: {
231-
'settings.allowHold': true,
232-
'settings.allowPieceDirectPlay': true,
233-
},
234-
})
235-
}
236-
},
237-
},
238-
239202
{
240203
id: 'TriggeredActions.remove old systemwide',
241204
canBeRunAutomatically: true,
@@ -353,6 +316,66 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
353316
},
354317
},
355318

319+
{
320+
id: 'Ensure CoreSystem.settingsWithOverrides is valid',
321+
dependOnResultFrom: `convert CoreSystem.settingsWithOverrides`,
322+
canBeRunAutomatically: true,
323+
validate: async () => {
324+
const systems = await CoreSystem.findFetchAsync({
325+
$or: [
326+
{
327+
'settingsWithOverrides.defaults': { $exists: false },
328+
},
329+
{
330+
'settingsWithOverrides.overrides': { $exists: false },
331+
},
332+
],
333+
})
334+
335+
if (systems.length > 0) {
336+
return 'settings must be converted to an ObjectWithOverrides'
337+
}
338+
339+
return false
340+
},
341+
migrate: async () => {
342+
const systems = await CoreSystem.findFetchAsync({
343+
$or: [
344+
{
345+
'settingsWithOverrides.defaults': { $exists: false },
346+
},
347+
{
348+
'settingsWithOverrides.overrides': { $exists: false },
349+
},
350+
],
351+
})
352+
353+
for (const system of systems) {
354+
const newSettings = wrapDefaultObject<ICoreSystemSettings>({
355+
cron: {
356+
casparCGRestart: {
357+
enabled: false,
358+
},
359+
storeRundownSnapshots: {
360+
enabled: false,
361+
},
362+
},
363+
support: { message: '' },
364+
evaluationsMessage: { enabled: false, heading: '', message: '' },
365+
})
366+
367+
await CoreSystem.updateAsync(system._id, {
368+
$set: {
369+
settingsWithOverrides: {
370+
...newSettings,
371+
...system.settingsWithOverrides,
372+
},
373+
},
374+
})
375+
}
376+
},
377+
},
378+
356379
{
357380
id: `studios create peripheralDeviceSettings.deviceSettings`,
358381
canBeRunAutomatically: true,

packages/webui/src/client/lib/uncaughtErrorHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function uncaughtErrorHandler(errorObj: any, context: string) {
4747
stringContent += stringifyError(errorObj)
4848
}
4949

50+
// Ignore any react deprecation warnings, as they add a lot of noise
51+
if (stringContent.includes('will be removed in the next major release')) return
52+
5053
const caughtErrorStack = new Error('')
5154
if (caughtErrorStack.stack) {
5255
stringContent += `\nCaught stack: ${caughtErrorStack.stack}`

packages/webui/src/meteor/meteor.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -234,78 +234,6 @@ Meteor.Error.prototype.clone = function () {
234234
return new Meteor.Error(self.error, self.reason, self.details)
235235
}
236236

237-
/**
238-
* @summary Generate an absolute URL pointing to the application. The server reads from the `ROOT_URL` environment variable to determine where it is running. This is taken care of automatically for apps deployed to Galaxy, but must be provided when using `meteor build`.
239-
* @locus Anywhere
240-
* @param {String} [path] A path to append to the root URL. Do not include a leading "`/`".
241-
* @param {Object} [options]
242-
* @param {Boolean} options.secure Create an HTTPS URL.
243-
* @param {Boolean} options.replaceLocalhost Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name.
244-
* @param {String} options.rootUrl Override the default ROOT_URL from the server environment. For example: "`http://foo.example.com`"
245-
*/
246-
Meteor.absoluteUrl = function (path, options) {
247-
// path is optional
248-
if (!options && typeof path === 'object') {
249-
options = path
250-
path = undefined
251-
}
252-
// merge options with defaults
253-
options = Object.assign({}, Meteor.absoluteUrl.defaultOptions, options || {})
254-
255-
var url = options.rootUrl
256-
if (!url) throw new Error('Must pass options.rootUrl or set ROOT_URL in the server environment')
257-
258-
if (!/^http[s]?:\/\//i.test(url))
259-
// url starts with 'http://' or 'https://'
260-
url = 'http://' + url // we will later fix to https if options.secure is set
261-
262-
if (!url.endsWith('/')) {
263-
url += '/'
264-
}
265-
266-
if (path) {
267-
// join url and path with a / separator
268-
while (path.startsWith('/')) {
269-
path = path.slice(1)
270-
}
271-
url += path
272-
}
273-
274-
// turn http to https if secure option is set, and we're not talking
275-
// to localhost.
276-
if (
277-
options.secure &&
278-
/^http:/.test(url) && // url starts with 'http:'
279-
!/http:\/\/localhost[:\/]/.test(url) && // doesn't match localhost
280-
!/http:\/\/127\.0\.0\.1[:\/]/.test(url)
281-
)
282-
// or 127.0.0.1
283-
url = url.replace(/^http:/, 'https:')
284-
285-
if (options.replaceLocalhost) url = url.replace(/^http:\/\/localhost([:\/].*)/, 'http://127.0.0.1$1')
286-
287-
return url
288-
}
289-
290-
// allow later packages to override default options
291-
var defaultOptions = (Meteor.absoluteUrl.defaultOptions = {})
292-
293-
// available only in a browser environment
294-
var location = typeof window === 'object' && window.location
295-
296-
if (typeof window.__meteor_runtime_config__ === 'object' && window.__meteor_runtime_config__.ROOT_URL) {
297-
defaultOptions.rootUrl = window.__meteor_runtime_config__.ROOT_URL
298-
} else if (location && location.protocol && location.host) {
299-
defaultOptions.rootUrl = location.protocol + '//' + location.host
300-
}
301-
302-
// Make absolute URLs use HTTPS by default if the current window.location
303-
// uses HTTPS. Since this is just a default, it can be overridden by
304-
// passing { secure: false } if necessary.
305-
if (location && location.protocol === 'https:') {
306-
defaultOptions.secure = true
307-
}
308-
309237
Meteor._relativeToSiteRootUrl = function (link) {
310238
if (typeof window.__meteor_runtime_config__ === 'object' && link.substr(0, 1) === '/')
311239
link = (window.__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '') + link

packages/webui/src/meteor/socket-stream-client/urls.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ function translateUrl(url, newSchemeBase, subPath) {
1212
newSchemeBase = 'http';
1313
}
1414

15-
if (subPath !== "sockjs" && url.startsWith("/")) {
16-
url = Meteor.absoluteUrl(url.substr(1));
17-
}
18-
1915
var ddpUrlMatch = url.match(/^ddp(i?)\+sockjs:\/\//);
2016
var httpUrlMatch = url.match(/^http(s?):\/\//);
2117
var newScheme;

0 commit comments

Comments
 (0)