Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Next sso #775

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ declare module 'vue' {
AGrid: typeof import('@arco-design/web-vue')['Grid'];
AGridItem: typeof import('@arco-design/web-vue')['GridItem'];
AInput: typeof import('@arco-design/web-vue')['Input'];
AInputGroup: typeof import('@arco-design/web-vue')['InputGroup'];
AInputNumber: typeof import('@arco-design/web-vue')['InputNumber'];
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'];
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch'];
Expand Down
34 changes: 19 additions & 15 deletions src/views/application-management/environments/config/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ServiceRowData } from '@/views/application-management/services/config/interface';
import { ConnectorRowData } from '@/views/operation-hub/connectors/config/interface';
import { DataListItem } from '@/types/global';
import { DataListItem, AxiosRequestPayload } from '@/types/global';

export interface EnvironmentRow extends DataListItem {
id: string;
Expand All @@ -19,18 +19,22 @@ export interface EnvironmentRow extends DataListItem {
connectorIDs: string[];
}

export interface EnvironFormData {
draft?: boolean;
preview?: boolean;
projectID?: string;
id?: string;
name: string;
type: string;
description: string;
connectorIDs: string[];
connectors: any[];
edges?: any[];
labels?: Record<string, any>;
resources?: any[];
variables?: any[];
export interface EnvironFormData extends AxiosRequestPayload {
metadata: {
name: string;
namespace: string;
labels: object;
};
spec: {
type: string;
description: string;
draft?: boolean;
preview?: boolean;
connectorIDs: string[];
connectors: any[];
edges?: any[];
labels?: Record<string, any>;
resources?: any[];
variables?: any[];
};
}
88 changes: 52 additions & 36 deletions src/views/application-management/environments/pages/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
>
<a-form-item
:label="$t('operation.environments.table.name')"
field="name"
field="metadata.name"
:validate-trigger="['change', 'input']"
:hide-label="true"
:rules="[
Expand All @@ -56,7 +56,7 @@
]"
>
<seal-input
v-model.trim="formData.name"
v-model.trim="formData.metadata.name"
:view-status="pageAction === PageAction.VIEW"
:disabled="!!name && !isCloneAction"
:label="$t('operation.environments.table.name')"
Expand All @@ -70,7 +70,7 @@
:label="$t('applications.environment.type')"
:hide-label="true"
hide-asterisk
field="type"
field="spec.type"
:rules="[
{
required: true,
Expand All @@ -79,7 +79,7 @@
]"
>
<seal-select
v-model="formData.type"
v-model="formData.spec.type"
:view-status="pageAction === PageAction.VIEW"
:label="$t('applications.environment.type')"
:required="true"
Expand All @@ -92,12 +92,12 @@
</a-form-item>
<a-form-item
:label="$t('operation.environments.table.description')"
field="description"
field="spec.description"
:hide-label="true"
validate-trigger="change"
>
<seal-textarea
v-model="formData.description"
v-model="formData.spec.description"
:view-status="pageAction === PageAction.VIEW"
:label="$t('operation.environments.table.description')"
:style="{ width: `${InputWidth.LARGE}px` }"
Expand All @@ -110,7 +110,7 @@
<a-form-item
:label="$t(`applications.projects.form.label`)"
:hide-label="true"
field="labels"
field="metadata.labels"
validate-trigger="change"
:rules="[
{
Expand Down Expand Up @@ -138,7 +138,7 @@
:style="{ width: `${InputWidth.LARGE}px` }"
>
<keyValueLabels
v-model:value="formData.labels"
v-model:value="formData.metadata.labels"
v-model:labelList="labelsData.list"
:validate-trigger="validateTrigger"
:labels="labelsData.labels"
Expand Down Expand Up @@ -286,7 +286,6 @@
validateInputLength,
InputWidth,
EnvironmentTypeMap,
EnvironmentTypeList,
EnvironmentTypeOrder,
SaveActions,
HintKeyMaps
Expand Down Expand Up @@ -325,7 +324,10 @@
createEnvironment,
cloneEnvironment,
updateEnvironment,
queryItemEnvironments
queryItemEnvironments,
apiVersion,
ResourceKinds,
GlobalNamespace
} from '../api';

const {
Expand All @@ -343,7 +345,7 @@
const tabBarStore = useTabBarStore();
const { router, route, t } = useCallCommon();
const { pageAction, handleEdit } = usePageAction();
const name = route.query.name as string;
const envName = route.query.name as string;
const isCloneAction = route.params.clone as string; // only in clone
const environmentName = route.params.environmentName as string;
const projectName = route.params.projectName as string;
Expand Down Expand Up @@ -374,10 +376,23 @@
const projectVariables = ref<any[]>([]);

const formData = ref<EnvironFormData>({
projectID: route.params.projectId as string,
name: '',
type: '',
description: '',
apiVersion,
kind: ResourceKinds.Environment,
metadata: {
namespace: projectName,
name: '',
labels: {}
},
spec: {
type: '',
description: '',
connectorIDs: [],
connectors: [],
variables: [],
edges: [],
labels: {},
resources: []
},
connectorIDs: [],
connectors: [],
variables: [],
Expand All @@ -401,15 +416,16 @@
[HintKeyMaps.var]: [...projectVariables.value, ...variables]
};
});
// const EnvironmentTypeList = computed(() => {
// return _.map(userStore.applicableEnvironmentTypes, (item) => {
// return {
// label: t(EnvironmentTypeMap[item] || ''),
// value: item,
// order: EnvironmentTypeOrder[item]
// };
// }).sort((a, b) => a.order - b.order);
// });
const EnvironmentTypeList = computed(() => {
// userStore.applicableEnvironmentTypes
return _.map(_.keys(EnvironmentTypeMap), (item) => {
return {
label: t(EnvironmentTypeMap[item] || ''),
value: item,
order: EnvironmentTypeOrder[item]
};
}).sort((a, b) => a.order - b.order);
});
const selectableConnectors = computed(() => {
return _.filter(connectorList.value, (item) => {
return item.applicableEnvironmentType === formData.value.type;
Expand All @@ -420,10 +436,10 @@
if (isCloneAction) {
return t('applications.environment.clone');
}
if (!name) {
if (!envName) {
return t('operation.environments.create');
}
if (name && pageAction.value === PageAction.EDIT) {
if (envName && pageAction.value === PageAction.EDIT) {
return t('operation.environments.edit');
}
return t('operation.environments.view');
Expand All @@ -439,8 +455,8 @@
if (route.name === PROJECT.EnvDetail) {
pageAction.value = userStore.hasProjectResourceActions({
resource: Resources.Environments,
environmentID: name,
projectID: route.params.projectId,
environmentID: envName,
projectID: route.params.projectName,
actions: ['POST']
})
? PageAction.EDIT
Expand All @@ -453,8 +469,8 @@
}
const hasPermission = userStore.hasProjectResourceActions({
resource: Resources.Environments,
environmentID: name,
projectID: route.params.projectId,
environmentID: envName,
projectID: route.params.projectName,
actions: ['POST']
});
return pageAction.value === PageAction.VIEW && hasPermission;
Expand Down Expand Up @@ -504,10 +520,10 @@
};
const getItemEnvironmentInfo = async () => {
copyFormData = cloneDeep(formData.value);
if (!name) return;
if (!envName) return;
try {
const { data } = await queryItemEnvironments({
environmentName: name,
environmentName: envName,
namespace: projectName
});
formData.value = data;
Expand All @@ -525,7 +541,7 @@
copyFormData = cloneDeep(formData.value);
} catch (error) {
formData.value = {
projectID: route.params.projectId as string,
projectID: route.params.projectName as string,
name: '',
type: '',
description: '',
Expand Down Expand Up @@ -596,11 +612,11 @@
if (isCloneAction) {
handleCloneEnvironment(data);
}
if (name && !isCloneAction) {
if (envName && !isCloneAction) {
await updateEnvironment(data);
} else if (isCloneAction) {
await cloneEnvironment(data, environmentName);
} else if (!name && !environmentName) {
} else if (!envName && !environmentName) {
await createEnvironment({
data,
namespace: projectName
Expand Down Expand Up @@ -720,7 +736,7 @@
}
};
const setLabels = () => {
labelsData.value.labels = _.cloneDeep(formData.value.labels);
labelsData.value.labels = _.cloneDeep(formData.value.metadata.labels);
};
const init = async () => {
setBreadCrumbList();
Expand Down
3 changes: 2 additions & 1 deletion src/views/config/resource-kinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default {
Settings: 'Settings',
Project: 'Project',
Variable: 'Variable',
Connector: 'Connector'
Connector: 'Connector',
Environment: 'Environment'
};

export const apiVersion = 'walrus.seal.io/v1';
Expand Down
2 changes: 1 addition & 1 deletion src/views/operation-hub/catalogs/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function refreshCatalog(data: {
name: string;
item: object;
}) {
const url = `/${NAMESPACES}/${data.namespace}/${CatalogAPI}/${data.name}`;
const url = `/${NAMESPACES}/${data.namespace}/${CatalogAPI}/${data.name}/status`;
return axios.put(`${url}`, data.item);
}

Expand Down
21 changes: 7 additions & 14 deletions src/views/operation-hub/catalogs/components/catalog-basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
spec: {
...props.formData.spec,
vcsSource: {
...props.formData.spec.vcsSource,
token: ''
...props.formData.spec.vcsSource
}
}
});
Expand Down Expand Up @@ -161,14 +160,8 @@
show-word-limit
></seal-textarea>
</a-form-item>
<GroupTitle
style={{ marginBottom: 0 }}
title="Storage"
bordered={false}
flexStart
></GroupTitle>

<a-form-item
label={t('operation.templates.form.StorageType')}
field="spec.vcsSource.platform"
hide-asterisk
hide-label={true}
Expand All @@ -188,7 +181,7 @@
}
});
}}
label={t('operation.templates.form.StorageType')}
label={t('common.table.type')}
required={true}
style={{ width: `${InputWidth.LARGE}px` }}
v-slots={{
Expand Down Expand Up @@ -247,7 +240,7 @@
style={{ width: `${InputWidth.LARGE}px` }}
></seal-input>
</a-form-item>
<a-form-item
{/* <a-form-item
label={t('operation.templates.form.authentication')}
field="spec.vcsSource.secretRef"
hide-asterisk
Expand All @@ -264,8 +257,8 @@
style={{ width: `${InputWidth.LARGE}px` }}
options={AuthenticationOptions}
></seal-select>
</a-form-item>
{authentication.value === 'bearer' && (
</a-form-item> */}
{/* {authentication.value === 'bearer' && (
<a-form-item
label="Token"
field="spec.vcsSource.token"
Expand Down Expand Up @@ -293,7 +286,7 @@
style={{ width: `${InputWidth.LARGE}px` }}
></seal-input>
</a-form-item>
)}
)} */}
</>
);
}
Expand Down
6 changes: 2 additions & 4 deletions src/views/operation-hub/catalogs/components/catalog-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@
description: '',
vcsSource: {
platform: 'Github',
url: '',
token: ''
url: ''
},
filtering: {
excludeFilter: '',
Expand Down Expand Up @@ -157,8 +156,7 @@
description: '',
vcsSource: {
platform: 'Github',
url: '',
token: ''
url: ''
},
filtering: {
excludeFilter: '',
Expand Down
Loading
Loading