Skip to content

Commit

Permalink
Allow disabling file upload via site config (#1464)
Browse files Browse the repository at this point in the history
* This PR splits one single feature from #1229 by @Binrix, which is too
large
* Adds a new configuration option `disableFileUploadControl`
* Addresses part of #1211

---------

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro committed Jun 4, 2023
1 parent 4ea4742 commit 6ed89d7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
22 changes: 14 additions & 8 deletions packages/jaeger-ui/src/components/SearchTracePage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class SearchTracePageImpl extends Component {
embedded,
errors,
isHomepage,
disableFileUploadControl,
loadingServices,
loadingTraces,
maxTraceDuration,
Expand All @@ -107,13 +108,15 @@ export class SearchTracePageImpl extends Component {
<TabPane tab="Search" key="searchForm">
{!loadingServices && services ? <SearchForm services={services} /> : <LoadingIndicator />}
</TabPane>
<TabPane tab="Upload" key="fileLoader">
<FileLoader
loadJsonTraces={fileList => {
loadJsonTraces(fileList);
}}
/>
</TabPane>
{!disableFileUploadControl && (
<TabPane tab="Upload" key="fileLoader">
<FileLoader
loadJsonTraces={fileList => {
loadJsonTraces(fileList);
}}
/>
</TabPane>
)}
</Tabs>
</div>
</Col>
Expand Down Expand Up @@ -173,6 +176,7 @@ SearchTracePageImpl.propTypes = {
}),
maxTraceDuration: PropTypes.number,
loadingServices: PropTypes.bool,
disableFileUploadControl: PropTypes.bool,
loadingTraces: PropTypes.bool,
urlQueryParams: PropTypes.shape({
service: PropTypes.string,
Expand Down Expand Up @@ -246,9 +250,10 @@ const stateServicesXformer = memoizeOne(stateServices => {

// export to test
export function mapStateToProps(state) {
const { embedded, router, services: stServices, traceDiff } = state;
const { embedded, router, services: stServices, traceDiff, config } = state;
const query = getUrlState(router.location.search);
const isHomepage = !Object.keys(query).length;
const { disableFileUploadControl } = config;
const {
query: queryOfResults,
traces,
Expand All @@ -274,6 +279,7 @@ export function mapStateToProps(state) {
embedded,
isHomepage,
loadingServices,
disableFileUploadControl,
loadingTraces,
services,
traceResults,
Expand Down
19 changes: 17 additions & 2 deletions packages/jaeger-ui/src/components/SearchTracePage/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { shallow, mount } from 'enzyme';
import store from 'store';

import { SearchTracePageImpl as SearchTracePage, mapStateToProps } from './index';
import FileLoader from './FileLoader';
import SearchForm from './SearchForm';
import LoadingIndicator from '../common/LoadingIndicator';
import { fetchedState } from '../../constants';
Expand Down Expand Up @@ -64,6 +65,7 @@ describe('<SearchTracePage>', () => {
isHomepage: false,
loadingServices: false,
loadingTraces: false,
disableFileUploadControl: false,
maxTraceDuration: 100,
numberOfTraceResults: traceResults.length,
services: null,
Expand Down Expand Up @@ -153,15 +155,24 @@ describe('<SearchTracePage>', () => {
expect(wrapper.find('.js-test-logo').length).toBe(1);
});

it('hide SearchForm if is embed', () => {
it('hides SearchForm if is embed', () => {
wrapper.setProps({ embed: true });
expect(wrapper.find(SearchForm).length).toBe(0);
});

it('hide logo if is embed', () => {
it('hides logo if is embed', () => {
wrapper.setProps({ embed: true });
expect(wrapper.find('.js-test-logo').length).toBe(0);
});

it('shows Upload tab by default', () => {
expect(wrapper.find(FileLoader).length).toBe(1);
});

it('hides Upload tab if it is disabled via config', () => {
wrapper.setProps({ disableFileUploadControl: true });
expect(wrapper.find(FileLoader).length).toBe(0);
});
});

describe('mapStateToProps()', () => {
Expand Down Expand Up @@ -190,6 +201,9 @@ describe('mapStateToProps()', () => {
cohort: [trace.traceID],
},
services: stateServices,
config: {
disableFileUploadControl: false,
},
};

const {
Expand All @@ -210,6 +224,7 @@ describe('mapStateToProps()', () => {
expect(diffCohort[0].data.traceID).toBe(trace.traceID);

expect(rest).toEqual({
disableFileUploadControl: false,
embedded: undefined,
queryOfResults: undefined,
isHomepage: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/constants/default-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const defaultConfig: Config = {
},
docsLink: 'https://www.jaegertracing.io/docs/latest/spm/',
},

disableFileUploadControl: false,
traceGraph: {
layoutManagerMemory: undefined,
},
Expand Down
3 changes: 3 additions & 0 deletions packages/jaeger-ui/src/types/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export type Config = {
// traceGraph controls the trace graph under trace page
traceGraph?: TraceGraphConfig;

// Disables the file upload control.
disableFileUploadControl: boolean;

// The following features are experimental / undocumented.

deepDependencies?: {
Expand Down

0 comments on commit 6ed89d7

Please sign in to comment.