Skip to content

Commit

Permalink
fix: the description of the role uses data from the API (#4439)
Browse files Browse the repository at this point in the history
Signed-off-by: donniean <[email protected]>
  • Loading branch information
donniean authored Jan 16, 2025
1 parent 946efc3 commit 6822c58
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/shared/src/stores/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import { get, isEmpty } from 'lodash';

import { useUrl } from '../hooks';
import { getOriginData, parser, getRoleBaseInfo, request } from '../utils';
import type { PathParams, FormattedRole, OriginalRole, RoleKind } from '../types';
import { getOriginData, parser, getBaseInfo, request } from '../utils';
import type { PathParams, FormattedRole, OriginalRole } from '../types';
import baseStore from './store';

function mapper(item: OriginalRole, kind: RoleKind): FormattedRole {
function mapper(item: OriginalRole): FormattedRole {
return {
...getRoleBaseInfo<OriginalRole>(item, kind),
...getBaseInfo<OriginalRole>(item),
labels: get(item, 'metadata.labels', {}) as FormattedRole['labels'],
namespace: get(item, 'metadata.namespace'),
annotations: get(item, 'metadata.annotations', {}) as FormattedRole['annotations'],
Expand All @@ -27,6 +27,7 @@ function mapper(item: OriginalRole, kind: RoleKind): FormattedRole {
}

const store = (module = 'roles') => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { getPath } = useUrl({ module });

const apiVersion = 'kapis/iam.kubesphere.io/v1beta1';
Expand Down Expand Up @@ -78,12 +79,12 @@ const store = (module = 'roles') => {
}`,
},
});
return res?.items?.map((item: OriginalRole) => mapper(item, `${tempModule}roles`));
return res?.items?.map((item: OriginalRole) => mapper(item));
};

const BaseStore = baseStore<FormattedRole>({
module,
mapper: (item: OriginalRole) => mapper(item, module),
mapper: (item: OriginalRole) => mapper(item),
getResourceUrlFn,
getListUrlFn: getResourceUrlFn,
});
Expand Down

0 comments on commit 6822c58

Please sign in to comment.