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

fix: Fix multiple issues #298

Merged
merged 1 commit into from
Jul 11, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM epamedp/headlamp:0.22.20
FROM epamedp/headlamp:0.22.21

COPY --chown=100:101 assets/ /headlamp/frontend
COPY --chown=100:101 dist/main.js /headlamp/plugins/edp/main.js
Expand Down
5 changes: 5 additions & 0 deletions src/k8s/JiraServer/mocks/jira-server.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ export const JiraServerMock = {
available: true,
status: 'finished',
},
spec: {
apiUrl: 'https://test-jira.com',
credentialName: 'ci-jira',
rootUrl: 'https://test-jira.com',
},
};
1 change: 1 addition & 0 deletions src/pages/edp-cdpipeline-list/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const permissionChecks = {
CD_PIPELINE: 'cdPipeline',
CODEBASE: 'codebase',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ export const PermissionsContext = React.createContext<PermissionsContextProvider
update: false,
delete: false,
},
codebase: {
create: false,
},
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { EDPCDPipelineKubeObject } from '../../../../k8s/EDPCDPipeline';
import { EDPCDPipelineKubeObjectConfig } from '../../../../k8s/EDPCDPipeline/config';
import { EDPCodebaseKubeObject } from '../../../../k8s/EDPCodebase';
import { EDPCodebaseKubeObjectConfig } from '../../../../k8s/EDPCodebase/config';
import { ValueOf } from '../../../../types/global';
import { PermissionList } from '../../../../types/permissions';
import { getDefaultNamespace } from '../../../../utils/getDefaultNamespace';
Expand All @@ -16,6 +18,15 @@ const CDPipelineInstance = new EDPCDPipelineKubeObject({
},
});

const CodebaseInstance = new EDPCodebaseKubeObject({
apiVersion: `${EDPCodebaseKubeObjectConfig.group}/${EDPCodebaseKubeObjectConfig.version}`,
kind: EDPCodebaseKubeObjectConfig.kind,
// @ts-ignore
metadata: {
namespace: getDefaultNamespace(),
},
});

export const PermissionsContextProvider: React.FC = ({ children }) => {
const [permissions, setPermissions] = React.useState<
PermissionList<ValueOf<typeof permissionChecks>>
Expand All @@ -25,19 +36,27 @@ export const PermissionsContextProvider: React.FC = ({ children }) => {
update: false,
delete: false,
},
codebase: {
create: false,
},
});

React.useEffect(() => {
(async () => {
const createCheck = await CDPipelineInstance.getAuthorization('create');
const updateCheck = await CDPipelineInstance.getAuthorization('update');
const deleteCheck = await CDPipelineInstance.getAuthorization('delete');
const cdPipelineCreateCheck = await CDPipelineInstance.getAuthorization('create');
const cdPipelineUpdateCheck = await CDPipelineInstance.getAuthorization('update');
const cdPipelineDeleteCheck = await CDPipelineInstance.getAuthorization('delete');

const codebaseCreateCheck = await CodebaseInstance.getAuthorization('create');

setPermissions({
cdPipeline: {
create: createCheck?.status?.allowed || false,
update: updateCheck?.status?.allowed || false,
delete: deleteCheck?.status?.allowed || false,
create: cdPipelineCreateCheck?.status?.allowed || false,
update: cdPipelineUpdateCheck?.status?.allowed || false,
delete: cdPipelineDeleteCheck?.status?.allowed || false,
},
codebase: {
create: codebaseCreateCheck?.status?.allowed || false,
},
});
})();
Expand All @@ -50,6 +69,9 @@ export const PermissionsContextProvider: React.FC = ({ children }) => {
update: permissions.cdPipeline.update,
delete: permissions.cdPipeline.delete,
},
codebase: {
create: permissions.codebase.create,
},
}),
[permissions]
);
Expand Down
19 changes: 12 additions & 7 deletions src/pages/edp-cdpipeline-list/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const PageView = () => {

const { filterFunction } = useFilterContext();

const { cdPipeline: CDPipelinePermissions } = usePermissionsContext();
const { cdPipeline: CDPipelinePermissions, codebase: codebasePermissions } =
usePermissionsContext();

return (
<PageWrapper>
Expand Down Expand Up @@ -118,12 +119,16 @@ export const PageView = () => {
error={error}
filterFunction={filterFunction}
blockerComponent={
!gitOpsCodebaseQuery.data && (
<EmptyList
customText={'No GitOps repository configured.'}
linkText={'Click here to add a repository.'}
handleClick={() => history.push(gitOpsConfigurationPageRoute)}
/>
codebasePermissions.create ? (
!gitOpsCodebaseQuery.data && (
<EmptyList
customText={'No GitOps repository configured.'}
linkText={'Click here to add a repository.'}
handleClick={() => history.push(gitOpsConfigurationPageRoute)}
/>
)
) : (
<EmptyList customText="You do not have permission to create GitOps repository." />
)
}
/>
Expand Down
63 changes: 41 additions & 22 deletions src/pages/edp-component-list/components/ComponentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,46 @@ export const ComponentList = ({ noGitServers }: ComponentListProps) => {
permissions: codebasePermissions,
});

const renderEmptyListComponent = React.useCallback(() => {
const componentsAreLoaded = items !== null;

if (!codebasePermissions.create) {
return <EmptyList customText="You do not have permission to create components." />;
}

if (componentsAreLoaded && noGitServers) {
return (
<EmptyList
customText={'No Git Servers Connected.'}
linkText={'Click here to add a Git Server.'}
handleClick={() => history.push(gitServersConfigurationPageRoute)}
/>
);
}

return (
<EmptyList
customText={"Let's kickstart the application onboarding!"}
linkText={'Click here to add a new application and integrate with the platform.'}
handleClick={() => {
setDialog({
modalName: CREATE_EDIT_CODEBASE_DIALOG_NAME,
forwardedProps: {
mode: FORM_MODES.CREATE,
},
});
}}
/>
);
}, [
codebasePermissions.create,
gitServersConfigurationPageRoute,
history,
items,
noGitServers,
setDialog,
]);

return (
<>
<Resources />
Expand All @@ -107,28 +147,7 @@ export const ComponentList = ({ noGitServers }: ComponentListProps) => {
selected={selected}
isSelected={(row) => selected.indexOf(row.metadata.name) !== -1}
canBeSelected={(row) => row.spec.type !== CODEBASE_TYPES.SYSTEM}
emptyListComponent={
items !== null && noGitServers ? (
<EmptyList
customText={'No Git Servers Connected.'}
linkText={'Click here to add a Git Server.'}
handleClick={() => history.push(gitServersConfigurationPageRoute)}
/>
) : (
<EmptyList
customText={"Let's kickstart the application onboarding!"}
linkText={'Click here to add a new application and integrate with the platform.'}
handleClick={() => {
setDialog({
modalName: CREATE_EDIT_CODEBASE_DIALOG_NAME,
forwardedProps: {
mode: FORM_MODES.CREATE,
},
});
}}
/>
)
}
emptyListComponent={renderEmptyListComponent()}
/>
{deleteDialogOpen && (
<ComponentMultiDeletion
Expand Down
32 changes: 10 additions & 22 deletions src/pages/edp-configuration/pages/edp-jira-integration/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import { ICONS } from '../../../../icons/iconify-icons-mapping';
import { JiraServerKubeObject } from '../../../../k8s/JiraServer';
import { SecretKubeObject } from '../../../../k8s/Secret';
import { SECRET_LABEL_SECRET_TYPE } from '../../../../k8s/Secret/labels';
import { FORM_MODES } from '../../../../types/forms';
import { getForbiddenError } from '../../../../utils/getForbiddenError';
import { rem } from '../../../../utils/styling/rem';
import { ManageJira } from '../../../../widgets/ManageJira';
import { ManageJiraServer } from '../../../../widgets/ManageJiraServer';
import { ConfigurationPageContent } from '../../components/ConfigurationPageContent';
import { JIRA_INTEGRATION_PAGE_DESCRIPTION } from './constants';

Expand All @@ -32,7 +31,6 @@ export const PageView = () => {

const jiraServer = jiraServers?.[0]?.jsonData;
const jiraServerSecret = jiraServerSecrets?.[0]?.jsonData;
const mode = !!jiraServerSecret ? FORM_MODES.EDIT : FORM_MODES.CREATE;
const ownerReference = jiraServerSecret?.metadata?.ownerReferences?.[0]?.kind;
const error = jiraServersError || jiraServerSecretsError;
const isLoading = (jiraServers === null || jiraServerSecrets === null) && !error;
Expand Down Expand Up @@ -110,36 +108,26 @@ export const PageView = () => {
</Typography>
</AccordionSummary>
<AccordionDetails>
<ManageJira
formData={{
jiraServer,
jiraServerSecret,
ownerReference,
isReadOnly: !!ownerReference,
mode,
handleClosePanel: handleCloseCreateDialog,
}}
<ManageJiraServer
secret={jiraServerSecret}
jiraServer={jiraServer}
ownerReference={ownerReference}
/>
</AccordionDetails>
</Accordion>
</LoadingWrapper>
);
}, [error, jiraServerSecret, isLoading, jiraServer, mode]);
}, [error, jiraServerSecret, isLoading, jiraServer]);

return (
<ConfigurationPageContent
creationForm={{
label: 'Add Integration',
component: (
<ManageJira
formData={{
jiraServer,
jiraServerSecret,
ownerReference,
isReadOnly: !!ownerReference,
mode,
handleClosePanel: handleCloseCreateDialog,
}}
<ManageJiraServer
secret={jiraServerSecret}
jiraServer={jiraServer}
ownerReference={ownerReference}
/>
),
isOpen: isCreateDialogOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ export const PipelineRunDetails = ({ pipelineRunTasks, taskRunListByNameMap }) =
return (
<StyledAccordionChildBtn
color="inherit"
onClick={() =>
onClick={() => {
setActiveTab({
type: 'step',
name: taskRunStepName,
})
}
});
setActiveAccordion(taskRunName);
}}
isActive={isActive}
>
<Stack direction="row" alignItems="center" spacing={2}>
Expand Down
Loading
Loading