Skip to content

Commit eb9d6ea

Browse files
committed
re-organize some stuff
1 parent b45a4da commit eb9d6ea

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

packages/kserve/src/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const deployKServeDeployment = async (
6666
const createTokenAuth =
6767
(inferenceServiceData.tokenAuth && inferenceServiceData.tokenAuth.length > 0) ?? false;
6868

69-
if (initialWizardData?.canCreateRoleBindings !== false) {
69+
if (wizardData.canCreateRoleBindings) {
7070
await setUpTokenAuth(
7171
inferenceServiceData,
7272
inferenceServiceData.k8sName,

packages/llmd-serving/src/deployments/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export const deployLLMdDeployment = async (
219219
(wizardData.tokenAuthentication.data && wizardData.tokenAuthentication.data.length > 0) ??
220220
false;
221221

222-
if (initialWizardData?.canCreateRoleBindings !== false) {
222+
if (wizardData.canCreateRoleBindings) {
223223
await setUpTokenAuth(
224224
wizardData.tokenAuthentication.data,
225225
wizardData.k8sNameDesc.data.k8sName.value,

packages/model-serving/src/__tests__/mockUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ export const mockDeploymentWizardState = (
229229
setData: jest.fn(),
230230
isVisible: true,
231231
},
232+
canCreateRoleBindings: true,
232233
},
233-
canCreateRoleBindings: true,
234234
loaded: {
235235
modelSourceLoaded: true,
236236
modelDeploymentLoaded: true,

packages/model-serving/src/components/deploymentWizard/ModelDeploymentWizard.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ import {
88
isGeneratedSecretName,
99
} from '@odh-dashboard/internal/api/k8s/secrets';
1010
import { SupportedArea, useIsAreaAvailable } from '@odh-dashboard/internal/concepts/areas';
11-
import { useAccessReview } from '@odh-dashboard/internal/api/index';
1211
import { Deployment } from 'extension-points';
1312
import { deployModel } from './utils';
1413
import { ExternalDataLoader, type ExternalDataMap } from './ExternalDataLoader';
1514
import { useModelDeploymentWizard } from './useDeploymentWizard';
1615
import { useModelDeploymentWizardValidation } from './useDeploymentWizardValidation';
1716
import { ModelSourceStepContent } from './steps/ModelSourceStep';
18-
import { AdvancedSettingsStepContent, accessReviewResource } from './steps/AdvancedOptionsStep';
17+
import { AdvancedSettingsStepContent } from './steps/AdvancedOptionsStep';
1918
import { ModelDeploymentStepContent } from './steps/ModelDeploymentStep';
2019
import { ReviewStepContent } from './steps/ReviewStep';
2120
import { useDeployMethod } from './useDeployMethod';
@@ -60,15 +59,6 @@ const ModelDeploymentWizard: React.FC<ModelDeploymentWizardProps> = ({
6059

6160
const wizardState = useModelDeploymentWizard(existingData, project?.metadata.name, externalData);
6261
const currentProjectName = wizardState.state.project.projectName ?? undefined;
63-
64-
// Check if user has permission to create rolebindings (admins can, contributors cannot)
65-
const [canCreateRoleBindings] = useAccessReview({
66-
...accessReviewResource,
67-
namespace: currentProjectName,
68-
});
69-
70-
// Update wizard state with the current permission value
71-
wizardState.canCreateRoleBindings = canCreateRoleBindings;
7262
const validation = useModelDeploymentWizardValidation(wizardState.state, wizardState.fields);
7363

7464
const { deployMethod, deployMethodLoaded } = useDeployMethod(wizardState.state);
@@ -300,7 +290,7 @@ const ModelDeploymentWizard: React.FC<ModelDeploymentWizardProps> = ({
300290
<AdvancedSettingsStepContent
301291
wizardState={wizardState}
302292
externalData={externalData}
303-
allowCreate={canCreateRoleBindings}
293+
allowCreate={wizardState.state.canCreateRoleBindings}
304294
/>
305295
) : (
306296
<Spinner data-testid="spinner" />

packages/model-serving/src/components/deploymentWizard/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export type WizardFormData = {
142142
modelServer: ReturnType<typeof useModelServerSelectField>;
143143
createConnectionData: ReturnType<typeof useCreateConnectionData>;
144144
deploymentStrategy: ReturnType<typeof useDeploymentStrategyField>;
145+
canCreateRoleBindings: boolean;
145146
} & Record<string, unknown>;
146147
};
147148

packages/model-serving/src/components/deploymentWizard/useDeploymentWizard.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
extractK8sNameDescriptionFieldData,
66
LimitNameResourceType,
77
} from '@odh-dashboard/internal/concepts/k8s/K8sNameDescriptionField/utils';
8+
import { useAccessReview } from '@odh-dashboard/internal/api/index';
9+
import { accessReviewResource } from './steps/AdvancedOptionsStep';
810
import { useModelFormatField } from './fields/ModelFormatField';
911
import { useModelTypeField } from './fields/ModelTypeSelectField';
1012
import { useModelLocationData } from './fields/ModelLocationInputFields';
@@ -23,7 +25,6 @@ import { useDeploymentWizardReducer, type WizardFormAction } from './useDeployme
2325
import type { ExternalDataMap } from './ExternalDataLoader';
2426

2527
export type UseModelDeploymentWizardState = WizardFormData & {
26-
canCreateRoleBindings: boolean;
2728
loaded: {
2829
modelSourceLoaded: boolean;
2930
modelDeploymentLoaded: boolean;
@@ -47,6 +48,12 @@ export const useModelDeploymentWizard = (
4748
// Step 1: Model Source
4849
const modelType = useModelTypeField(initialData?.modelTypeField);
4950
const project = useProjectSection(initialProjectName);
51+
52+
const [canCreateRoleBindings] = useAccessReview({
53+
...accessReviewResource,
54+
namespace: project.projectName ?? undefined,
55+
});
56+
5057
const modelLocationData = useModelLocationData(
5158
project.projectName,
5259
initialData?.modelLocationData,
@@ -140,6 +147,7 @@ export const useModelDeploymentWizard = (
140147
modelAvailability,
141148
modelServer,
142149
deploymentStrategy,
150+
canCreateRoleBindings,
143151
}),
144152
[
145153
project,
@@ -157,6 +165,7 @@ export const useModelDeploymentWizard = (
157165
modelAvailability,
158166
modelServer,
159167
deploymentStrategy,
168+
canCreateRoleBindings,
160169
],
161170
);
162171

@@ -172,7 +181,6 @@ export const useModelDeploymentWizard = (
172181
state,
173182
dispatch,
174183
fields,
175-
canCreateRoleBindings: true, // Default value, will be updated by the component
176184
loaded: {
177185
modelSourceLoaded,
178186
modelDeploymentLoaded,

packages/model-serving/src/components/deploymentWizard/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const getTokenAuthenticationFromDeployment = (
7979
};
8080

8181
export const deployModel = async (
82-
wizardState: WizardFormData & { canCreateRoleBindings: boolean },
82+
wizardState: WizardFormData,
8383
secretName: string,
8484
exitWizard: () => void,
8585
deployMethod?: (
@@ -126,7 +126,7 @@ export const deployModel = async (
126126
true,
127127
undefined,
128128
undefined,
129-
{ ...initialWizardData, canCreateRoleBindings: wizardState.canCreateRoleBindings },
129+
initialWizardData,
130130
applyFieldData,
131131
),
132132
]
@@ -160,7 +160,7 @@ export const deployModel = async (
160160
false,
161161
actualSecretName,
162162
overwrite,
163-
{ ...initialWizardData, canCreateRoleBindings: wizardState.canCreateRoleBindings },
163+
initialWizardData,
164164
applyFieldData,
165165
);
166166

0 commit comments

Comments
 (0)