Skip to content

Commit

Permalink
add flag to toggle diff page
Browse files Browse the repository at this point in the history
  • Loading branch information
WangQianliang committed Oct 21, 2019
1 parent e6938bc commit ae1c6b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/code/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const code = (kibana: any) =>
return {
codeUiEnabled: config.get('xpack.code.ui.enabled'),
codeIntegrationsEnabled: config.get('xpack.code.integrations.enabled'),
codeDiffPageEnabled: config.get('xpack.code.diffPage.enabled'),
};
},
hacks: ['plugins/code/hacks/toggle_app_link_in_nav'],
Expand All @@ -61,6 +62,9 @@ export const code = (kibana: any) =>
integrations: Joi.object({
enabled: Joi.boolean().default(false),
}).default(),
diffPage: Joi.object({
enabled: Joi.boolean().default(false),
}).default(),
enabled: Joi.boolean().default(true),
})
.default()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion x-pack/legacy/plugins/code/public/components/commits/commit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import {
EuiCopy,
EuiTitle,
} from '@elastic/eui';
import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { CommitInfo } from '../../../model/commit';
import { RepositoryUtils } from '../../../common/repository_utils';
import { parseCommitMessage } from '../../../common/commit_utils';
import { PathTypes } from '../../common/types';

const COMMIT_ID_LENGTH = 8;

Expand Down Expand Up @@ -53,8 +55,17 @@ const revisionLinkLabel = i18n.translate('xpack.code.commits.revisionLinkAriaLab
defaultMessage: 'View the project at this commit',
});

const getRevisionPath = (repoUri: string, commitId: string) => {
const diffPageEnabled = chrome.getInjected('codeDiffPageEnabled');
if (diffPageEnabled) {
return `#/${repoUri}/commit/${commitId}`;
} else {
return `#/${repoUri}/${PathTypes.tree}/${commitId}`;
}
};

const CommitActions = ({ commitId, repoUri }: ActionProps) => {
const revisionPath = `#/${repoUri}/commit/${commitId}`;
const revisionPath = getRevisionPath(repoUri, commitId);

return (
<div className="commit__actions">
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/code/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const createCodeConfigSchema = () => {
enabled: schema.boolean({ defaultValue: true }),
}),
enabled: schema.boolean({ defaultValue: true }),
diffPage: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
integrations: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
queueIndex: schema.string({ defaultValue: '.code_internal-worker-queue' }),
// 1 hour by default.
queueTimeoutMs: schema.number({
Expand Down

0 comments on commit ae1c6b4

Please sign in to comment.