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

feat: AI insights tab #813

Merged
merged 11 commits into from
Aug 3, 2023
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
28 changes: 2 additions & 26 deletions src/AppRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ import {Content} from 'antd/lib/layout/layout';

import FingerprintJS from '@fingerprintjs/fingerprintjs';

import {IconLabel, Tag} from '@atoms';

import {ConfigContext, DashboardContext, MainContext} from '@contexts';
import {ModalHandler, ModalOutletProvider} from '@contexts/ModalContext';

import {useAxiosInterceptors} from '@hooks/useAxiosInterceptors';
import {useLastCallback} from '@hooks/useLastCallback';

import {AiInsightsTab} from '@molecules';

import {Sider} from '@organisms';

import {ErrorBoundary} from '@pages';

import {BasePermissionsResolver, PermissionsProvider} from '@permissions/base';

import PluginScope from '@plugins/PluginScope';
import createAiInsightsPlugin from '@plugins/definitions/ai-insights';
import {Plugin} from '@plugins/types';

import {useAppDispatch} from '@redux/hooks';
Expand Down Expand Up @@ -111,27 +107,7 @@ const AppRoot: React.FC = () => {
[navigate, location]
);

const plugins: Plugin[] = useMemo(
() => [
{
name: 'ai-insights',
setup: (scope: PluginScope) => {
scope.appendSlot(
'testExecutionTabs',
{
key: 'ai-insights-tab',
label: <IconLabel title="AI Insights" icon={<Tag title="NEW" type="info" />} />,
children: <AiInsightsTab />,
},
{
order: 4,
}
);
},
},
],
[]
);
const plugins: Plugin[] = useMemo(() => [createAiInsightsPlugin()], []);

return composeProviders()
.append(ConfigContext.Provider, {value: config})
Expand Down
3 changes: 3 additions & 0 deletions src/assets/images/lockedIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/components/molecules/AiInsightsTab/AiInsightsTab.styled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from 'styled-components';

import Colors from '@styles/Colors';

export const AiInsightContainer = styled.div`
width: 100%;
border: 1px solid ${Colors.indigo400};
border-radius: 4px;
background-color: ${Colors.slate900};
`;

export const AiInsightContent = styled.div`
padding: 40px 12px;
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
`;
36 changes: 30 additions & 6 deletions src/components/molecules/AiInsightsTab/AiInsightsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
import {ReactComponent as LockedIcon} from '@assets/lockedIcon.svg';

import {Button, Text} from '@custom-antd';

import {Execution} from '@models/execution';

import {usePluginState} from '@plugins/pluginHooks';
import Colors from '@styles/Colors';

import {externalLinks} from '@utils/externalLinks';

import {AiInsightContainer, AiInsightContent} from './AiInsightsTab.styled';

interface AiInsightsTabProps {
execution: Execution;
test: any;
}

const AiInsightsTab = () => {
const [{execution}] = usePluginState<AiInsightsTabProps>('testExecutionTabs');
return (
<div>
This is a cloud only feature. Please log in to cloud in order to use this feature for id
{execution.id}
</div>
<AiInsightContainer>
<AiInsightContent>
<LockedIcon />
<Text className="big bold"> This feature is available only in Testkube Cloud.</Text>
<Text color={Colors.slate400}>
Start using Testkube Cloud to get AI insights for your test executions, as well as other exclusive features.
<a href={externalLinks.testkubeCloud} target="_blank">
{' '}
Learn more
</a>
</Text>
<Button
type="primary"
onClick={() => {
window.open(externalLinks.testkubeCloud, '_blank');
}}
>
Go to Testkube Cloud
</Button>
</AiInsightContent>
</AiInsightContainer>
);
};

Expand Down
30 changes: 30 additions & 0 deletions src/plugins/definitions/ai-insights.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {IconLabel, Tag} from '@atoms';

import {AiInsightsTab} from '@molecules';

import {Plugin, TestExecutionTabsInterface} from '@plugins/types';

const createAiInsightsPlugin = (): Plugin => ({
name: 'ai-insights',
setup: scope => {
scope.appendSlot(
'testExecutionTabs',
{
key: 'ai-insights-tab',
label: <IconLabel title="AI Insights" icon={<Tag title="NEW" type="info" />} />,
children: <AiInsightsTab />,
},
{
order: 4,
visible: () => {
return (
scope.getState<TestExecutionTabsInterface>('testExecutionTabs')?.execution?.executionResult?.status ===
'failed'
);
},
}
);
},
});

export default createAiInsightsPlugin;
1 change: 1 addition & 0 deletions src/utils/externalLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum externalLinks {
sourcesApi = 'https://docs.testkube.io/openapi/#tag/test-sources',
sourcesDocumentation = 'https://docs.testkube.io/articles/creating-tests/#test-source',
testSources = 'https://docs.testkube.io/articles/test-sources',
testkubeCloud = 'https://cloud.testkube.io',
rangoo94 marked this conversation as resolved.
Show resolved Hide resolved
OSStoCloudMigration = 'https://cloud.testkube.io/system-init?cloudMigrate=true',
apiEndpoint = 'https://docs.testkube.io/articles/testkube-dashboard-api-endpoint',
createTestSuite = 'https://docs.testkube.io/articles/creating-test-suites',
Expand Down
Loading