mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
* refactor(sidebar): migrate sidebar to react [EE-2907] fixes [EE-2907] feat(sidebar): show label for help fix(sidebar): apply changes from ddExtension fix(sidebar): resolve conflicts style(ts): add explanation for ddExtension fix(sidebar): use enum for status refactor(sidebar): rename to EdgeComputeSidebar refactor(sidebar): removed the need of `ident` prop style(sidebar): add ref for mobile breakpoint refactor(app): document testing props refactor(sidebar): use single sidebar item refactor(sidebar): use section for nav refactor(sidebar): rename sidebarlink to link refactor(sidebar): memoize menu paths fix(kubectl-shell): infinite loop on hooks dependencies refactor(sidebar): use authorized element feat(k8s/shell): track open shell refactor(k8s/shell): remove memoization refactor(settings): move settings queries to queries fix(sidebar): close sidebar on mobile refactor(settings): use mutation helpers refactor(sidebar): remove memo refactor(sidebar): rename sidebar item for storybook refactor(sidebar): move to react gprefactor(sidebar): remove dependence on EndProvider feat(environments): rename settings type feat(kube): move kubeconfig button fix(sidebar): open submenus fix(sidebar): open on expand fix(sibebar): show kube shell correctly * fix(sidebar): import from react component * chore(tests): fix missing prop
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { DefaultRequestBody, PathParams, rest } from 'msw';
|
|
|
|
import {
|
|
Edition,
|
|
LicenseInfo,
|
|
LicenseType,
|
|
} from '@/portainer/license-management/types';
|
|
import { EnvironmentGroup } from '@/portainer/environment-groups/types';
|
|
import { Tag } from '@/portainer/tags/types';
|
|
import { StatusResponse } from '@/portainer/services/api/status.service';
|
|
import { createMockTeams } from '@/react-tools/test-mocks';
|
|
import { PublicSettingsResponse } from '@/portainer/settings/types';
|
|
|
|
import { azureHandlers } from './setup-handlers/azure';
|
|
import { dockerHandlers } from './setup-handlers/docker';
|
|
import { userHandlers } from './setup-handlers/users';
|
|
|
|
const tags: Tag[] = [
|
|
{ ID: 1, Name: 'tag1' },
|
|
{ ID: 2, Name: 'tag2' },
|
|
];
|
|
|
|
const licenseInfo: LicenseInfo = {
|
|
nodes: 1000,
|
|
type: LicenseType.Subscription,
|
|
company: 'company',
|
|
createdAt: 0,
|
|
email: 'email@company.com',
|
|
expiresAt: Number.MAX_SAFE_INTEGER,
|
|
productEdition: Edition.EE,
|
|
valid: true,
|
|
};
|
|
|
|
export const handlers = [
|
|
rest.get('/api/teams', async (req, res, ctx) =>
|
|
res(ctx.json(createMockTeams(10)))
|
|
),
|
|
|
|
...azureHandlers,
|
|
...dockerHandlers,
|
|
...userHandlers,
|
|
rest.get('/api/licenses/info', (req, res, ctx) => res(ctx.json(licenseInfo))),
|
|
rest.get('/api/status/nodes', (req, res, ctx) => res(ctx.json({ nodes: 3 }))),
|
|
rest.get('/api/backup/s3/status', (req, res, ctx) =>
|
|
res(ctx.json({ Failed: false }))
|
|
),
|
|
rest.get('/api/endpoint_groups', (req, res, ctx) => res(ctx.json([]))),
|
|
rest.get('/api/endpoint_groups/:groupId', (req, res, ctx) => {
|
|
if (req.params.groupId instanceof Array) {
|
|
throw new Error('should be string');
|
|
}
|
|
const id = parseInt(req.params.groupId, 10);
|
|
const group: Partial<EnvironmentGroup> = {
|
|
Id: id,
|
|
Name: `group${id}`,
|
|
};
|
|
return res(ctx.json(group));
|
|
}),
|
|
rest.get('/api/tags', (req, res, ctx) => res(ctx.json(tags))),
|
|
rest.post<{ name: string }>('/api/tags', (req, res, ctx) => {
|
|
const tagName = req.body.name;
|
|
const tag = { ID: tags.length + 1, Name: tagName };
|
|
tags.push(tag);
|
|
return res(ctx.json(tag));
|
|
}),
|
|
rest.get<DefaultRequestBody, PathParams, Partial<PublicSettingsResponse>>(
|
|
'/api/settings/public',
|
|
(req, res, ctx) => res(ctx.json({}))
|
|
),
|
|
rest.get<DefaultRequestBody, PathParams, Partial<StatusResponse>>(
|
|
'/api/status',
|
|
(req, res, ctx) => res(ctx.json({}))
|
|
),
|
|
];
|