@perses-dev/plugin-system 0.42.0 → 0.43.0-rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +7 -9
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +217 -147
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/cjs/validation/index.js +1 -0
- package/dist/cjs/validation/role.js +4 -4
- package/dist/cjs/validation/rolebinding.js +7 -7
- package/dist/cjs/validation/secret.js +176 -0
- package/dist/cjs/validation/variable.js +23 -4
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +7 -9
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +218 -148
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +8 -21
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +1 -0
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/role.d.ts +24 -24
- package/dist/validation/role.js +1 -1
- package/dist/validation/role.js.map +1 -1
- package/dist/validation/rolebinding.js +1 -1
- package/dist/validation/rolebinding.js.map +1 -1
- package/dist/validation/secret.d.ts +964 -0
- package/dist/validation/secret.d.ts.map +1 -0
- package/dist/validation/secret.js +157 -0
- package/dist/validation/secret.js.map +1 -0
- package/dist/validation/variable.d.ts +82 -5
- package/dist/validation/variable.d.ts.map +1 -1
- package/dist/validation/variable.js +21 -2
- package/dist/validation/variable.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { DispatchWithoutAction, useCallback, useMemo, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Button,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { useImmer } from 'use-immer';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { variableEditValidationSchema, VariableEditValidationType } from '../../../validation';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\nimport { VariableEditorState, getVariableDefinitionFromState, getInitialState } from './variable-editor-form-model';\n\nfunction FallbackPreview() {\n return <div>Error previewing values</div>;\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm(props: VariableEditorFormProps) {\n const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialVariableDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [previewKey, setPreviewKey] = useState(0);\n const [action, setAction] = useState(initialAction);\n\n const refreshPreview = () => {\n setPreviewKey((prev) => prev + 1);\n };\n\n /** We use the `previewKey` that we increment to know when to explicitly update the\n * spec that will be used for preview. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n */\n const previewSpec = useMemo(() => {\n return getVariableDefinitionFromState(state) as ListVariableDefinition;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [previewKey]);\n\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<VariableEditValidationType>({\n resolver: zodResolver(variableEditValidationSchema),\n mode: 'onBlur',\n defaultValues: state,\n });\n\n const processForm: SubmitHandler<VariableEditValidationType> = () => {\n onSave(getVariableDefinitionFromState(state));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [state, initialState, setDiscardDialogOpened, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!form.formState.isValid}\n onClick={form.handleSubmit(processForm)}\n >\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update',\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.title = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.description = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.kind = event.target.value as VariableEditorState['kind'];\n });\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {state.kind === 'TextVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Box>\n <VariablePreview values={[state.textVariableFields.value]} />\n </Box>\n <TextField\n label=\"Value\"\n value={state.textVariableFields.value}\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n onChange={(v) => {\n setState((draft) => {\n draft.textVariableFields.value = v.target.value;\n });\n }}\n />\n <FormControlLabel\n control={\n <Switch\n checked={state.textVariableFields.constant ?? false}\n readOnly={action === 'read'}\n onChange={(e) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n setState((draft) => {\n draft.textVariableFields.constant = e.target.checked;\n });\n }}\n />\n }\n label=\"Constant\"\n />\n </Stack>\n </>\n )}\n\n {state.kind === 'ListVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {state.listVariableFields.plugin.kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** */}\n <PluginEditor\n width=\"100%\"\n pluginType=\"Variable\"\n pluginKindLabel=\"Source\"\n value={state.listVariableFields.plugin}\n isReadonly={action === 'read'}\n onChange={(val) => {\n setState((draft) => {\n draft.listVariableFields.plugin = val;\n });\n }}\n />\n </Stack>\n\n <Stack>\n <TextField\n label=\"Capturing Regexp Filter\"\n value={state.listVariableFields.capturingRegexp ?? ''}\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n onChange={(e) => {\n setState((draft) => {\n if (e.target.value) {\n // TODO: do a better fix, if empty string => it should skip the filter\n draft.listVariableFields.capturingRegexp = e.target.value;\n } else {\n draft.listVariableFields.capturingRegexp = undefined;\n }\n });\n }}\n helperText=\"Optional, if you want to filter on captured result.\"\n />\n </Stack>\n\n <Stack>\n <TextField\n select\n label=\"Sort\"\n value={state.listVariableFields.sort ?? ''}\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n setState((draft) => {\n draft.listVariableFields.sort = e.target.value;\n });\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <FormControlLabel\n control={\n <Switch\n checked={state.listVariableFields.allowMultiple}\n readOnly={action === 'read'}\n onChange={(e) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n setState((draft) => {\n draft.listVariableFields.allowMultiple = e.target.checked;\n });\n }}\n />\n }\n label=\"Allow Multiple Values\"\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <FormControlLabel\n control={\n <Switch\n checked={state.listVariableFields.allowAll}\n readOnly={action === 'read'}\n onChange={(e) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n setState((draft) => {\n draft.listVariableFields.allowAll = e.target.checked;\n });\n }}\n />\n }\n label=\"Allow All option\"\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {state.listVariableFields.allowAll && (\n <TextField\n label=\"Custom All Value\"\n value={state.listVariableFields.customAllValue}\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n onChange={(e) => {\n setState((draft) => {\n if (e.target.value) {\n draft.listVariableFields.customAllValue = e.target.value;\n } else {\n draft.listVariableFields.customAllValue = undefined;\n }\n });\n }}\n helperText=\"When All is selected, this value will be used\"\n />\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["React","useCallback","useMemo","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Button","Stack","ClickAwayListener","Divider","useImmer","DiscardChangesConfirmationDialog","ErrorBoundary","Controller","FormProvider","useForm","zodResolver","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","variableEditValidationSchema","VariableListPreview","VariablePreview","getVariableDefinitionFromState","getInitialState","FallbackPreview","div","VariableEditorForm","props","initialVariableDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","state","setState","isDiscardDialogOpened","setDiscardDialogOpened","previewKey","setPreviewKey","action","setAction","refreshPreview","prev","previewSpec","titleAction","submitText","form","resolver","mode","defaultValues","processForm","handleCancel","JSON","stringify","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","type","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","name","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","undefined","InputProps","readOnly","error","helperText","message","onChange","event","draft","target","value","title","description","select","kind","map","v","py","values","textVariableFields","control","checked","constant","e","listVariableFields","plugin","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginType","pluginKindLabel","val","capturingRegexp","sort","allowMultiple","allowAll","customAllValue","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAAgCC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SACEC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,iBAAiB,EACjBC,OAAO,QACF,gBAAgB;AACvB,SAASC,QAAQ,QAAQ,YAAY;AAErC,SAASC,gCAAgC,EAAEC,aAAa,QAAQ,yBAAyB;AACzF,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,aAAa,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,cAA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
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { DispatchWithoutAction, useCallback, useMemo, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Button,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useImmer } from 'use-immer';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { variableEditorValidationSchema, VariableEditorValidationType } from '../../../validation';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\nimport { getVariableDefinitionFromState, getInitialState, VariableEditorState } from './variable-editor-form-model';\n\nfunction FallbackPreview() {\n return <div>Error previewing values</div>;\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm(props: VariableEditorFormProps) {\n const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialVariableDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [previewKey, setPreviewKey] = useState(0);\n const [action, setAction] = useState(initialAction);\n\n const refreshPreview = () => {\n setPreviewKey((prev) => prev + 1);\n };\n\n /** We use the `previewKey` that we increment to know when to explicitly update the\n * spec that will be used for preview. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n */\n const previewSpec = useMemo(() => {\n return getVariableDefinitionFromState(state) as ListVariableDefinition;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [previewKey]);\n\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<VariableEditorValidationType>({\n resolver: zodResolver(variableEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: initialState,\n });\n\n const processForm: SubmitHandler<VariableEditorValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(\n getVariableDefinitionFromState({\n ...state,\n title: state.title === '' ? undefined : state.title,\n description: state.description === '' ? undefined : state.description,\n })\n );\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [initialState, state, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!form.formState.isValid}\n onClick={form.handleSubmit(processForm)}\n >\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.name}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.title ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.title = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.description ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.description = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.kind}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.kind = event.target.value as VariableEditorState['kind'];\n });\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {state.kind === 'TextVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Box>\n <VariablePreview values={[state.textVariableFields.value]} />\n </Box>\n <Controller\n name=\"textVariableFields.value\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.textVariableFields.value}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.value = event.target.value;\n });\n }}\n />\n )}\n />\n <Controller\n name=\"textVariableFields.constant\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Constant\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.textVariableFields.constant}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.constant = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n )}\n\n {state.kind === 'ListVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {state.listVariableFields.plugin.kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** */}\n <Controller\n name=\"listVariableFields.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginType=\"Variable\"\n pluginKindLabel=\"Source\"\n isReadonly={action === 'read'}\n value={state.listVariableFields.plugin}\n onChange={(val) => {\n field.onChange(val);\n setState((draft) => {\n draft.listVariableFields.plugin = val;\n });\n }}\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.capturingRegexp\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Capturing Regexp Filter\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n value={state.listVariableFields.capturingRegexp ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n // TODO: do a better fix, if empty string => it should skip the filter\n draft.listVariableFields.capturingRegexp = event.target.value;\n } else {\n draft.listVariableFields.capturingRegexp = undefined;\n }\n });\n }}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'Optional, if you want to filter on captured result.'\n }\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.sort\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Sort\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.listVariableFields.sort ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.sort = event.target.value;\n });\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n )}\n />\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <Controller\n name=\"listVariableFields.allowMultiple\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow Multiple Values\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowMultiple}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowMultiple = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <Controller\n name=\"listVariableFields.allowAllValue\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow All option\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowAllValue}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowAllValue = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {state.listVariableFields.allowAllValue && (\n <Controller\n name=\"listVariableFields.customAllValue\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Custom All Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'When All is selected, this value will be used'\n }\n value={state.listVariableFields.customAllValue ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n draft.listVariableFields.customAllValue = event.target.value;\n } else {\n draft.listVariableFields.customAllValue = undefined;\n }\n });\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["React","useCallback","useMemo","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Button","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorBoundary","Controller","FormProvider","useForm","zodResolver","useImmer","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","variableEditorValidationSchema","VariableListPreview","VariablePreview","getVariableDefinitionFromState","getInitialState","FallbackPreview","div","VariableEditorForm","props","initialVariableDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","state","setState","isDiscardDialogOpened","setDiscardDialogOpened","previewKey","setPreviewKey","action","setAction","refreshPreview","prev","previewSpec","titleAction","submitText","form","resolver","mode","defaultValues","processForm","title","undefined","description","handleCancel","JSON","stringify","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","type","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","name","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","value","onChange","event","draft","target","select","kind","map","v","py","values","textVariableFields","control","checked","constant","listVariableFields","plugin","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginType","pluginKindLabel","val","capturingRegexp","sort","allowMultiple","allowAllValue","customAllValue","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAAgCC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SACEC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,iBAAiB,EACjBC,OAAO,QACF,gBAAgB;AAEvB,SAASC,gCAAgC,EAAEC,aAAa,QAAQ,yBAAyB;AACzF,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,aAAa,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,8BAA8B,QAAsC,sBAAsB;AACnG,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,oBAAoB;AACzE,SAASC,8BAA8B,EAAEC,eAAe,QAA6B,+BAA+B;AAEpH,SAASC;IACP,qBAAO,KAACC;kBAAI;;AACd;AAYA,OAAO,SAASC,mBAAmBC,KAA8B;IAC/D,MAAM,EAAEC,0BAAyB,EAAEC,cAAa,EAAEC,QAAO,EAAEC,WAAU,EAAEC,OAAM,EAAEC,QAAO,EAAEC,SAAQ,EAAE,GAA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AClDoE,UAAU,CAACC;4DACTd,MAAMa,SAASC;4DACfpE,SAAS,CAACqE;gEACR,IAAID,MAAME,OAAOJ,OAAO;oEACtBG,MAAMY,mBAAmBgB,iBAAiB7B,MAAME,OAAOJ;gEACzD,OAAO;oEACLG,MAAMY,mBAAmBgB,iBAAiB/E;gEAC5C;4DACF;wDACF;;;;;;;;;;;;0BAUlB,KAAC/C;gBACCgD,aAAY;gBACZ+E,QAAQjG;gBACRkG,UAAU;oBACRjG,uBAAuB;gBACzB;gBACAkG,kBAAkB;oBAChBlG,uBAAuB;oBACvBN;gBACF;;;;AAIR"}
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import { VariableDefinition } from '@perses-dev/core';
|
|
2
|
-
export declare
|
|
1
|
+
import { ListVariableSpec, TextVariableSpec, UnknownSpec, VariableDefinition } from '@perses-dev/core';
|
|
2
|
+
export declare type VariableEditorState = {
|
|
3
3
|
name: string;
|
|
4
|
-
title
|
|
5
|
-
kind:
|
|
6
|
-
description
|
|
7
|
-
listVariableFields:
|
|
8
|
-
|
|
9
|
-
allowAll: boolean;
|
|
10
|
-
customAllValue: string | undefined;
|
|
11
|
-
capturingRegexp: string | undefined;
|
|
12
|
-
sort: string | undefined;
|
|
13
|
-
plugin: {
|
|
14
|
-
kind: string;
|
|
15
|
-
spec: {};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
textVariableFields: {
|
|
19
|
-
value: string;
|
|
20
|
-
constant: boolean;
|
|
21
|
-
};
|
|
4
|
+
title?: string;
|
|
5
|
+
kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';
|
|
6
|
+
description?: string;
|
|
7
|
+
listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'>;
|
|
8
|
+
textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;
|
|
22
9
|
};
|
|
23
|
-
export declare
|
|
10
|
+
export declare function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState;
|
|
24
11
|
export declare function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition;
|
|
25
12
|
//# sourceMappingURL=variable-editor-form-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,oBAAY,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,iBAAiB,CAAC;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5E,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAChE,CAAC;AAEF,wBAAgB,eAAe,CAAC,yBAAyB,EAAE,kBAAkB,GAAG,mBAAmB,CAkClG;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mBAAmB,GAAG,kBAAkB,CAgC7F"}
|
|
@@ -19,7 +19,7 @@ export function getInitialState(initialVariableDefinition) {
|
|
|
19
19
|
};
|
|
20
20
|
const listVariableFields = {
|
|
21
21
|
allowMultiple: false,
|
|
22
|
-
|
|
22
|
+
allowAllValue: false,
|
|
23
23
|
customAllValue: undefined,
|
|
24
24
|
capturingRegexp: undefined,
|
|
25
25
|
sort: undefined,
|
|
@@ -32,7 +32,7 @@ export function getInitialState(initialVariableDefinition) {
|
|
|
32
32
|
var _initialVariableDefinition_spec_allowMultiple;
|
|
33
33
|
listVariableFields.allowMultiple = (_initialVariableDefinition_spec_allowMultiple = initialVariableDefinition.spec.allowMultiple) !== null && _initialVariableDefinition_spec_allowMultiple !== void 0 ? _initialVariableDefinition_spec_allowMultiple : false;
|
|
34
34
|
var _initialVariableDefinition_spec_allowAllValue;
|
|
35
|
-
listVariableFields.
|
|
35
|
+
listVariableFields.allowAllValue = (_initialVariableDefinition_spec_allowAllValue = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue !== void 0 ? _initialVariableDefinition_spec_allowAllValue : false;
|
|
36
36
|
listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;
|
|
37
37
|
listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;
|
|
38
38
|
listVariableFields.sort = initialVariableDefinition.spec.sort;
|
|
@@ -71,7 +71,7 @@ export function getVariableDefinitionFromState(state) {
|
|
|
71
71
|
name,
|
|
72
72
|
display,
|
|
73
73
|
allowMultiple: state.listVariableFields.allowMultiple,
|
|
74
|
-
allowAllValue: state.listVariableFields.
|
|
74
|
+
allowAllValue: state.listVariableFields.allowAllValue,
|
|
75
75
|
customAllValue: state.listVariableFields.customAllValue,
|
|
76
76
|
capturingRegexp: state.listVariableFields.capturingRegexp,
|
|
77
77
|
sort: state.listVariableFields.sort,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n ListVariableSpec,\n TextVariableDefinition,\n TextVariableSpec,\n UnknownSpec,\n VariableDefinition,\n} from '@perses-dev/core';\n\nexport type VariableEditorState = {\n name: string;\n title?: string;\n kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';\n description?: string;\n listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'>;\n textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;\n};\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState {\n const textVariableFields: Omit<TextVariableSpec, 'name' | 'display'> = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'> = {\n allowMultiple: false,\n allowAllValue: false,\n customAllValue: undefined,\n capturingRegexp: undefined,\n sort: undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAllValue,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAllValue","customAllValue","undefined","capturingRegexp","sort","plugin","kind","name","title","display","description","getVariableDefinitionFromState","state","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAmBjC,OAAO,SAASA,gBAAgBC,yBAA6C;QA4BlEA,yCAEMA;QA5BN,uCACG;IAFZ,MAAMC,qBAAiE;QACrEC,OAAO,CAAA,wCAAA,AAACF,0BAAqDG,KAAKD,mBAA3D,mDAAA,wCAAoE;QAC3EE,UAAU,CAAA,2CAAA,AAACJ,0BAAqDG,KAAKC,sBAA3D,sDAAA,2CAAuE;IACnF;IAEA,MAAMC,qBAA8E;QAClFC,eAAe;QACfC,eAAe;QACfC,gBAAgBC;QAChBC,iBAAiBD;QACjBE,MAAMF;QACNG,QA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AAMd,mBAAmBE;gBACxCC,gBAAgBW,MAAMd,mBAAmBG;gBACzCE,iBAAiBS,MAAMd,mBAAmBK;gBAC1CC,MAAMQ,MAAMd,mBAAmBM;gBAC/BC,QAAQO,MAAMd,mBAAmBO;YACnC;QACF;IACF;IACA,MAAM,IAAIQ,MAAM,CAAC,uBAAuB,EAAEP,KAAK,CAAC;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './resource';\nexport * from './variable';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,aAAa"}
|
|
1
|
+
{"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './resource';\nexport * from './secret';\nexport * from './variable';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,aAAa"}
|
|
@@ -17,20 +17,20 @@ export declare const roleValidationSchema: z.ZodObject<{
|
|
|
17
17
|
scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
|
|
18
18
|
}, "strip", z.ZodTypeAny, {
|
|
19
19
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
20
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
20
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
21
21
|
}, {
|
|
22
22
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
23
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
23
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
24
24
|
}>, "many">;
|
|
25
25
|
}, "strip", z.ZodTypeAny, {
|
|
26
26
|
permissions: {
|
|
27
27
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
28
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
28
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
29
29
|
}[];
|
|
30
30
|
}, {
|
|
31
31
|
permissions: {
|
|
32
32
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
33
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
33
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
34
34
|
}[];
|
|
35
35
|
}>;
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -42,7 +42,7 @@ export declare const roleValidationSchema: z.ZodObject<{
|
|
|
42
42
|
spec: {
|
|
43
43
|
permissions: {
|
|
44
44
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
45
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
45
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
46
46
|
}[];
|
|
47
47
|
};
|
|
48
48
|
}, {
|
|
@@ -54,7 +54,7 @@ export declare const roleValidationSchema: z.ZodObject<{
|
|
|
54
54
|
spec: {
|
|
55
55
|
permissions: {
|
|
56
56
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
57
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
57
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
58
58
|
}[];
|
|
59
59
|
};
|
|
60
60
|
}>;
|
|
@@ -73,20 +73,20 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
|
|
|
73
73
|
scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
|
|
74
74
|
}, "strip", z.ZodTypeAny, {
|
|
75
75
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
76
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
76
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
77
77
|
}, {
|
|
78
78
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
79
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
79
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
80
80
|
}>, "many">;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
82
82
|
permissions: {
|
|
83
83
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
84
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
84
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
85
85
|
}[];
|
|
86
86
|
}, {
|
|
87
87
|
permissions: {
|
|
88
88
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
89
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
89
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
90
90
|
}[];
|
|
91
91
|
}>;
|
|
92
92
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -97,7 +97,7 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
|
|
|
97
97
|
spec: {
|
|
98
98
|
permissions: {
|
|
99
99
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
100
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
100
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
101
101
|
}[];
|
|
102
102
|
};
|
|
103
103
|
}, {
|
|
@@ -108,7 +108,7 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
|
|
|
108
108
|
spec: {
|
|
109
109
|
permissions: {
|
|
110
110
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
111
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
111
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
112
112
|
}[];
|
|
113
113
|
};
|
|
114
114
|
}>;
|
|
@@ -130,20 +130,20 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
130
130
|
scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
|
|
131
131
|
}, "strip", z.ZodTypeAny, {
|
|
132
132
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
133
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
133
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
134
134
|
}, {
|
|
135
135
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
136
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
136
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
137
137
|
}>, "many">;
|
|
138
138
|
}, "strip", z.ZodTypeAny, {
|
|
139
139
|
permissions: {
|
|
140
140
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
141
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
141
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
142
142
|
}[];
|
|
143
143
|
}, {
|
|
144
144
|
permissions: {
|
|
145
145
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
146
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
146
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
147
147
|
}[];
|
|
148
148
|
}>;
|
|
149
149
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -155,7 +155,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
155
155
|
spec: {
|
|
156
156
|
permissions: {
|
|
157
157
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
158
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
158
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
159
159
|
}[];
|
|
160
160
|
};
|
|
161
161
|
}, {
|
|
@@ -167,7 +167,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
167
167
|
spec: {
|
|
168
168
|
permissions: {
|
|
169
169
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
170
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
170
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
171
171
|
}[];
|
|
172
172
|
};
|
|
173
173
|
}>, z.ZodObject<{
|
|
@@ -185,20 +185,20 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
185
185
|
scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
187
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
188
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
188
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
189
189
|
}, {
|
|
190
190
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
191
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
191
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
192
192
|
}>, "many">;
|
|
193
193
|
}, "strip", z.ZodTypeAny, {
|
|
194
194
|
permissions: {
|
|
195
195
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
196
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
196
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
197
197
|
}[];
|
|
198
198
|
}, {
|
|
199
199
|
permissions: {
|
|
200
200
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
201
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
201
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
202
202
|
}[];
|
|
203
203
|
}>;
|
|
204
204
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -209,7 +209,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
209
209
|
spec: {
|
|
210
210
|
permissions: {
|
|
211
211
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
212
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
212
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
213
213
|
}[];
|
|
214
214
|
};
|
|
215
215
|
}, {
|
|
@@ -220,7 +220,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
|
|
|
220
220
|
spec: {
|
|
221
221
|
permissions: {
|
|
222
222
|
actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
|
|
223
|
-
scopes: ["*" | "Datasource" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "
|
|
223
|
+
scopes: ["*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Datasource" | "Secret" | "GlobalSecret" | "Variable" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
|
|
224
224
|
}[];
|
|
225
225
|
};
|
|
226
226
|
}>]>;
|
package/dist/validation/role.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { z } from 'zod';
|
|
14
|
-
import { resourceIdValidationSchema } from '
|
|
14
|
+
import { resourceIdValidationSchema } from './resource';
|
|
15
15
|
const permissionValidationSchema = z.object({
|
|
16
16
|
// TODO: use SCOPE & ACTIONS constants
|
|
17
17
|
actions: z.array(z.enum([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/role.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { resourceIdValidationSchema } from '
|
|
1
|
+
{"version":3,"sources":["../../src/validation/role.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { resourceIdValidationSchema } from './resource';\n\nconst permissionValidationSchema = z.object({\n // TODO: use SCOPE & ACTIONS constants\n actions: z.array(z.enum(['*', 'create', 'read', 'update', 'delete'])).nonempty('Must contains at least 1 action'),\n scopes: z\n .array(\n z.enum([\n '*',\n 'Dashboard',\n 'Datasource',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n ])\n )\n .nonempty('Must contains at least 1 scope'), // TODO: limit project role\n});\n\nexport const roleValidationSchema = z.object({\n kind: z.literal('Role'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n project: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const globalRoleValidationSchema = z.object({\n kind: z.literal('GlobalRole'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const rolesEditorValidationSchema = z.discriminatedUnion('kind', [\n roleValidationSchema,\n globalRoleValidationSchema,\n]);\n\nexport type RolesEditorValidationType = z.infer<typeof rolesEditorValidationSchema>;\n"],"names":["z","resourceIdValidationSchema","permissionValidationSchema","object","actions","array","enum","nonempty","scopes","roleValidationSchema","kind","literal","metadata","name","project","spec","permissions","globalRoleValidationSchema","rolesEditorValidationSchema","discriminatedUnion"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,0BAA0B,QAAQ,aAAa;AAExD,MAAMC,6BAA6BF,EAAEG,OAAO;IAC1C,sCAAsC;IACtCC,SAASJ,EAAEK,MAAML,EAAEM,KAAK;QAAC;QAAK;QAAU;QAAQ;QAAU;KAAS,GAAGC,SAAS;IAC/EC,QAAQR,EACLK,MACCL,EAAEM,KAAK;QACL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD,GAEFC,SAAS;AACd;AAEA,OAAO,MAAME,uBAAuBT,EAAEG,OAAO;IAC3CO,MAAMV,EAAEW,QAAQ;IAChBC,UAAUZ,EAAEG,OAAO;QACjBU,MAAMZ;QACNa,SAASb;IACX;IACAc,MAAMf,EAAEG,OAAO;QACba,aAAahB,EAAEK,MAAMH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMe,6BAA6BjB,EAAEG,OAAO;IACjDO,MAAMV,EAAEW,QAAQ;IAChBC,UAAUZ,EAAEG,OAAO;QACjBU,MAAMZ;IACR;IACAc,MAAMf,EAAEG,OAAO;QACba,aAAahB,EAAEK,MAAMH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMgB,8BAA8BlB,EAAEmB,mBAAmB,QAAQ;IACtEV;IACAQ;CACD,EAAE"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { z } from 'zod';
|
|
14
|
-
import { resourceIdValidationSchema } from '
|
|
14
|
+
import { resourceIdValidationSchema } from './resource';
|
|
15
15
|
const subjectValidationSchema = z.object({
|
|
16
16
|
kind: z.enum([
|
|
17
17
|
'User'
|