Skip to content

Commit

Permalink
fix: Fixed RBAC issue and updated upload YAML function (#4295)
Browse files Browse the repository at this point in the history
* fix: Fixed RBAC issue and updated upload YAML function

Signed-off-by: Hrishav <hrishav.kumar@harness.io>

* chore: Updated more permissions

Signed-off-by: Hrishav <hrishav.kumar@harness.io>

---------

Signed-off-by: Hrishav <hrishav.kumar@harness.io>
  • Loading branch information
hrishavjha committed Nov 15, 2023
1 parent 3349d1d commit fd2a996
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 25 deletions.
Expand Up @@ -352,7 +352,7 @@ export const DownloadExperimentButton = ({
}}
variation={ButtonVariation.ICON}
icon={'import'}
permission={PermissionGroup.EDITOR}
permission={PermissionGroup.VIEWER}
/>
</div>
);
Expand Down
15 changes: 8 additions & 7 deletions chaoscenter/web/src/strings/strings.en.yaml
Expand Up @@ -211,15 +211,10 @@ criteria: Criteria
criteriaForData: Criteria for data
cron: Cron
cronDisabled: Cron Schedule is disabled
cronHalted: This cron experiment as been halted successfully.
cronResumed: This cron experiment has re-scheduled successfully.
disableCron: Disable Cron
disableCronDesc: This will disable the cron schedule for this experiment.
enableCron: Enable Cron
enableCronDesc: This will enable the cron schedule for this experiment.
nonCron: Non-Cron
cronExpression: Cron Expression
cronExpressionRequired: Cron Expression required
cronHalted: This cron experiment as been halted successfully.
cronResumed: This cron experiment has re-scheduled successfully.
cronSelectOption: Cron (Recurring run)
cronText: >-
The experiment will run periodically according to the cron provided below. You
Expand Down Expand Up @@ -269,6 +264,8 @@ details: Details
detailsAndProperties: Details & Properties
disable: Disable
disableChaosInfrastructure: Disable Chaos Infrastructure
disableCron: Disable Cron
disableCronDesc: This will disable the cron schedule for this experiment.
disableUser: Disable User
disableUserDescription: Are you sure you want to disable this user?
discard: Discard
Expand Down Expand Up @@ -318,6 +315,8 @@ enableChaosInfrastructure: Enable chaos infrastructure to run your first chaos e
enableChaosInfrastructureDesc: >-
In order to run Chaos Experiments, you need to enable chaos infrastructure in
the Environments
enableCron: Enable Cron
enableCronDesc: This will enable the cron schedule for this experiment.
enableImageRegistryChanges: Enable Image Registry Changes
enableSSLCheck: Enable SSL/TLS check
enableUser: Enable User
Expand Down Expand Up @@ -350,6 +349,7 @@ environments: Environments
error: Error
errorApplyChanges: Error in Applying the Changes. Please enter correct input values.
errorFetchName: Error in fetching the name.
errorInYamlDescription: There are some errors in the file, please check YAML file for errors.
evaluationTimeout: Evaluation timeout
executedBy: Executed by
executedOn: Executed on
Expand Down Expand Up @@ -698,6 +698,7 @@ nodeSelectorPlaceholderForValue: Enter the value
nodeSelectorText: >-
Node Selector is a selector which will result in all pods of the experiment to
be scheduled on the selected node.
nonCron: Non-Cron
nonCronSelectOption: Non-Cron (Single run)
nonCronText: >-
The experiment will run once after you click on Run. If you want to run it
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/web/src/strings/types.ts
Expand Up @@ -298,6 +298,7 @@ export interface StringsMap {
'error': unknown
'errorApplyChanges': unknown
'errorFetchName': unknown
'errorInYamlDescription': unknown
'evaluationTimeout': unknown
'executedBy': unknown
'executedOn': unknown
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/web/src/views/ChaosProbes/AddProbeModal.tsx
Expand Up @@ -87,7 +87,7 @@ export const AddProbeModal = ({ refetchProbes }: RefetchProbes): React.ReactElem
<ParentComponentErrorWrapper>
<RbacButton
variation={ButtonVariation.PRIMARY}
permission={PermissionGroup.EDITOR || PermissionGroup.OWNER}
permission={PermissionGroup.EDITOR}
text={getString(`newProbe`)}
icon="plus"
onClick={() => {
Expand Down
Expand Up @@ -27,17 +27,20 @@ export default function UploadYAML({ onClose }: UploadYAMLProps): React.ReactEle
const { showError } = useToaster();

const onUpload = (response: string): void => {
experimentHandler?.getExperiment(experimentKey).then(experiment => {
const processedManifest = experimentHandler.preProcessExperimentManifest({
manifest: parse(response) as ExperimentManifest,
experimentName: experiment?.name ?? 'chaos-experiment',
chaosInfrastructureID: experiment?.chaosInfrastructure?.id,
chaosInfrastructureNamespace: experiment?.chaosInfrastructure?.namespace,
imageRegistry: experiment?.imageRegistry
});
experimentHandler?.updateExperimentManifest(experimentKey, processedManifest);
onClose(processedManifest, true);
});
experimentHandler
?.getExperiment(experimentKey)
.then(experiment => {
const processedManifest = experimentHandler.preProcessExperimentManifest({
manifest: parse(response) as ExperimentManifest,
experimentName: experiment?.name ?? 'chaos-experiment',
chaosInfrastructureID: experiment?.chaosInfrastructure?.id,
chaosInfrastructureNamespace: experiment?.chaosInfrastructure?.namespace,
imageRegistry: experiment?.imageRegistry
});
experimentHandler?.updateExperimentManifest(experimentKey, processedManifest);
onClose(processedManifest, true);
})
.catch(() => showError('errorInYamlDescription'));
};

const onUploadError = (err: string): void => {
Expand Down
Expand Up @@ -47,7 +47,7 @@ export default function NoProbes({ loading }: NoProbesProps): React.ReactElement
<Layout.Horizontal spacing={'medium'}>
<ParentComponentErrorWrapper>
<RbacButton
permission={PermissionGroup.EDITOR || PermissionGroup.OWNER}
permission={PermissionGroup.EDITOR}
variation={ButtonVariation.PRIMARY}
text={getString('addProbe')}
icon="plus"
Expand Down
Expand Up @@ -70,7 +70,7 @@ export const MenuCell = ({
}}
permission={PermissionGroup.EDITOR}
/>
{/* */}
{/* <!-- clone experiment button --> */}
<RbacMenuItem
icon={'copy-alt'}
text={getString('cloneExperiment')}
Expand All @@ -91,7 +91,7 @@ export const MenuCell = ({
pathname: paths.toExperimentRunHistory({ experimentID: data.experimentID })
});
}}
permission={PermissionGroup.EDITOR}
permission={PermissionGroup.VIEWER}
/>
{/* <!-- download manifest button --> */}
<RbacMenuItem
Expand All @@ -100,7 +100,7 @@ export const MenuCell = ({
onClick={() => {
downloadYamlAsFile(yamlStringify(parse(data.experimentManifest)), `${data.experimentName}.yml`);
}}
permission={PermissionGroup.EDITOR}
permission={PermissionGroup.VIEWER}
/>
<MenuDivider />
{/* <!-- delete experiment button --> */}
Expand Down
Expand Up @@ -69,7 +69,7 @@ export default function ProjectMembersView(): React.ReactElement {
icon="plus"
iconProps={{ size: 10 }}
text={getString('newMember')}
permission={PermissionGroup.EDITOR}
permission={PermissionGroup.OWNER}
onClick={() => {
open();
}}
Expand Down

0 comments on commit fd2a996

Please sign in to comment.