Skip to content

Commit

Permalink
fix(KONFLUX-5721): change workspace to namespace for release and do not
Browse files Browse the repository at this point in the history
append suffix for creating/editing release
  • Loading branch information
testcara committed Jan 9, 2025
1 parent 7c5807c commit 7a06d7b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ReleasePlanForm: React.FC<Props> = ({
/>
<ApplicationDropdown
name="application"
helpText="The application you want to release to the environments in your target workspace."
helpText="The application you want to release to the environments in your target namespace."
required
/>
<RunReleasePipelineSection />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const GitOptions: React.FC<{ required?: boolean }> = ({ required = false }) => {
export const RunReleasePipelineSection: React.FC = () => {
const [{ value: pipelineLocation }] =
useField<ReleasePipelineLocation>('releasePipelineLocation');
const { workspace } = useWorkspaceInfo();
// The namespace here is 'username-tenant'.
const { namespace } = useWorkspaceInfo();

return (
<>
Expand All @@ -58,9 +59,9 @@ export const RunReleasePipelineSection: React.FC = () => {
options={[
{
value: ReleasePipelineLocation.current,
label: `In this workspace: ${workspace}`,
label: `In this namespace: ${namespace}`,
},
{ value: ReleasePipelineLocation.target, label: 'In a target workspace' },
{ value: ReleasePipelineLocation.target, label: 'In a target namespace' },
]}
required
/>
Expand Down Expand Up @@ -110,12 +111,12 @@ export const RunReleasePipelineSection: React.FC = () => {
<>
<InputField
name="target"
label="Target workspace"
helperText="Type the workspace name that you would like the selected application to be released to"
label="Target namespace"
helperText="Type the namespace name(username-tenant) that you would like the selected application to be released to."
labelIcon={
<HelpPopover
headerContent="Target workspace"
bodyContent="Your application will be released to the environments in this workspace."
headerContent="Target namespace"
bodyContent="Your application will be released to the environments in this namespace."
/>
}
required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('ReleasePlanForm', () => {
expect(result.getByRole('heading', { name: 'Create release plan' })).toBeVisible();
expect(result.getByRole('button', { name: 'Create' })).toBeVisible();
expect(result.getByRole('button', { name: 'Create' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In this workspace: test-ws' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In a target workspace' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In this namespace: test-ns' })).toBeVisible();
expect(result.getByRole('radio', { name: 'In a target namespace' })).toBeVisible();
expect(result.getByRole('checkbox', { name: 'Auto release' })).toBeVisible();
expect(result.getByRole('checkbox', { name: 'Standing attribution' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Release plan name' })).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('RunReleasePipelineSection', () => {
expect(
result.getByRole('region', { name: 'Git options for the release pipeline' }),
).toBeVisible();
expect(result.getByRole('textbox', { name: 'Target workspace' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Target namespace' })).toBeVisible();
expect(result.getByRole('textbox', { name: 'Data' })).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('createReleasePlan', () => {
k8sUpdateMock.mockImplementation((obj) => obj.resource);
});

it('should use active workspace for current release pipeline location', async () => {
it('should use active namespace for current release pipeline location', async () => {
const result = await createReleasePlan(
{
name: 'test-plan',
Expand All @@ -32,8 +32,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result).toEqual(
expect.objectContaining({
Expand All @@ -43,7 +43,7 @@ describe('createReleasePlan', () => {
'release.appstudio.openshift.io/standing-attribution': 'false',
},
name: 'test-plan',
namespace: 'test-ns',
namespace: 'test-ns-tenant',
},
spec: {
application: 'test-app',
Expand All @@ -64,7 +64,7 @@ describe('createReleasePlan', () => {
],
resolver: 'git',
},
target: 'test-ws-tenant',
target: 'test-ns-tenant',
},
}),
);
Expand All @@ -75,7 +75,7 @@ describe('createReleasePlan', () => {
{
name: 'test-plan',
application: 'test-app',
target: 'target-ws',
target: 'target-ws-tenant',
releasePipelineLocation: ReleasePipelineLocation.target,
labels: [],
params: [],
Expand All @@ -85,8 +85,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result).toEqual(
expect.objectContaining({
Expand Down Expand Up @@ -131,8 +131,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result.metadata.labels).toEqual({
'release.appstudio.openshift.io/auto-release': 'true',
Expand All @@ -154,8 +154,8 @@ describe('createReleasePlan', () => {
path: '/',
},
},
'test-ns',
'test-ws',
'test-ns-tenant',
'test-ws-tenant',
);
expect(result.metadata.labels).toEqual({
'release.appstudio.openshift.io/auto-release': 'true',
Expand All @@ -182,7 +182,7 @@ describe('editReleasePlan', () => {
path: '/',
},
},
'my-ws',
'my-ws-tenant',
);

expect(result.spec.target).toBe('my-ws-tenant');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export enum ReleasePipelineLocation {
target,
}

const WORKSPACE_SUFFIX = 'tenant';

export type ReleasePlanFormValues = {
name: string;
application: string;
Expand Down Expand Up @@ -88,7 +86,7 @@ export const createReleasePlan = async (
autoRelease,
standingAttribution,
} = values;
const targetWs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const targetNs = releasePipelineLocation === ReleasePipelineLocation.current ? namespace : target;
const labels = labelPairs
.filter((l) => !!l.key)
.reduce((acc, o) => ({ ...acc, [o.key]: o.value }), {} as Record<string, string>);
Expand All @@ -110,7 +108,7 @@ export const createReleasePlan = async (
application,
...(data ? { data } : {}),
serviceAccount,
target: `${targetWs}-${WORKSPACE_SUFFIX}`,
target: `${targetNs}`,
pipelineRef: {
resolver: ResolverType.GIT,
params: [
Expand Down Expand Up @@ -152,7 +150,7 @@ export const editReleasePlan = async (
autoRelease,
standingAttribution,
} = values;
const targetWs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const targetNs = releasePipelineLocation === ReleasePipelineLocation.current ? workspace : target;
const labels = labelPairs
.filter((l) => !!l.key)
.reduce((acc, o) => ({ ...acc, [o.key]: o.value }), {} as Record<string, string>);
Expand All @@ -175,7 +173,7 @@ export const editReleasePlan = async (
application,
...(data ? { data } : {}),
serviceAccount,
target: `${targetWs}-${WORKSPACE_SUFFIX}`,
target: `${targetNs}`,
pipelineRef: {
resolver: ResolverType.GIT,
params: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ReleasePlanListHeader = () => {
props: { className: releasesPlanTableColumnClasses.application },
},
{
title: 'Target Workspace',
title: 'Target Namespace',
props: { className: releasesPlanTableColumnClasses.target },
},
{
Expand Down

0 comments on commit 7a06d7b

Please sign in to comment.