forked from jaegertracing/jaeger-ui
-
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.
Add build & versions info to about menu (jaegertracing#606)
* Added jaeger ui version to about menu Signed-off-by: Alan Pinkert <alan.pinkert@gmail.com> * Added Jaeger version info from config Signed-off-by: Alan Pinkert <alan.pinkert@gmail.com> * Removed extra 'v' from Jaeger version Signed-off-by: Alan Pinkert <alan.pinkert@gmail.com> * Changed to use short git commit hash Signed-off-by: Alan Pinkert <alan.pinkert@gmail.com> * Added test for missing coverage Signed-off-by: Alan Pinkert <alan.pinkert@gmail.com> Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
- Loading branch information
Showing
7 changed files
with
174 additions
and
10 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
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,19 @@ | ||
// Copyright (c) 2020 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
export default Object.freeze({ | ||
gitCommit: '', | ||
gitVersion: '', | ||
buildDate: '', | ||
}); |
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,77 @@ | ||
// Copyright (c) 2020 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* eslint-disable no-console, import/first */ | ||
|
||
import getVersion from './get-version'; | ||
import defaultVersion from '../../constants/default-version'; | ||
|
||
describe('getVersion()', () => { | ||
const warnFn = jest.fn(); | ||
let oldWarn; | ||
|
||
beforeAll(() => { | ||
oldWarn = console.warn; | ||
console.warn = warnFn; | ||
}); | ||
|
||
beforeEach(() => { | ||
warnFn.mockClear(); | ||
}); | ||
|
||
afterAll(() => { | ||
console.warn = oldWarn; | ||
}); | ||
|
||
describe('`window.getVersion` is not a function', () => { | ||
beforeAll(() => { | ||
window.getVersion = undefined; | ||
}); | ||
|
||
it('warns once', () => { | ||
getVersion(); | ||
expect(warnFn.mock.calls.length).toBe(1); | ||
getVersion(); | ||
expect(warnFn.mock.calls.length).toBe(1); | ||
}); | ||
|
||
it('returns the default version information', () => { | ||
expect(getVersion()).toEqual(defaultVersion); | ||
}); | ||
}); | ||
|
||
describe('`window.getVersion` is a function', () => { | ||
let embedded; | ||
let getJaegerVersion; | ||
|
||
beforeEach(() => { | ||
embedded = {}; | ||
getJaegerVersion = jest.fn(() => embedded); | ||
window.getJaegerVersion = getJaegerVersion; | ||
}); | ||
|
||
it('returns the default version information when the embedded version information is `null`', () => { | ||
embedded = null; | ||
expect(getVersion()).toEqual(defaultVersion); | ||
}); | ||
|
||
it('returns the embedded version information when it is not `null`', () => { | ||
embedded = { | ||
a: '1', | ||
b: '2', | ||
}; | ||
expect(getVersion()).toEqual(embedded); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
// Copyright (c) 2020 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import defaultVersion from '../../constants/default-version'; | ||
|
||
let haveWarnedFactoryFn = false; | ||
|
||
export default function getVersion() { | ||
const getJaegerVersion = window.getJaegerVersion; | ||
if (typeof getJaegerVersion !== 'function') { | ||
if (!haveWarnedFactoryFn) { | ||
// eslint-disable-next-line no-console | ||
console.warn('Embedded version information not available'); | ||
haveWarnedFactoryFn = true; | ||
} | ||
return { ...defaultVersion }; | ||
} | ||
const embedded = getJaegerVersion(); | ||
if (!embedded) { | ||
return { ...defaultVersion }; | ||
} | ||
|
||
return { ...embedded }; | ||
} |
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