@equinor/amplify-component-lib 9.8.4 → 9.9.0
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/atoms/hooks/useFaqsInApplication.js +1 -1
- package/dist/molecules/Select/Select.js +1 -1
- package/dist/molecules/Select/Select.types.d.ts +4 -1
- package/dist/organisms/ToggleGroup/ToggleGroup.js +6 -2
- package/dist/organisms/ToggleGroup/ToggleGroup.types.d.ts +1 -0
- package/dist/organisms/ToggleGroup/ToggleGroupOption.js +1 -1
- package/dist/organisms/TopBar/Account/Account.d.ts +3 -19
- package/dist/organisms/TopBar/Account/Account.js +1 -1
- package/dist/organisms/TopBar/Account/ImpersonateMenu/CreateOrEditUser/CreateOrEditUser.js +1 -1
- package/dist/organisms/TopBar/Account/ImpersonateMenu/UserImpersonation.js +2 -2
- package/dist/organisms/TopBar/Account/ImpersonateMenu/hooks/useAllAppRoles.d.ts +1 -1
- package/dist/organisms/TopBar/Account/ImpersonateMenu/hooks/useAllAppRoles.js +1 -1
- package/dist/organisms/TopBar/Account/ImpersonateMenu/hooks/useMappedRoles.d.ts +4 -0
- package/dist/organisms/TopBar/Account/ImpersonateMenu/hooks/useMappedRoles.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FaqService as e}from"@equinor/subsurface-app-management";import{useQuery as r}from"@tanstack/react-query";import{environment as t}from"../utils/auth_environment.js";function
|
|
1
|
+
import{FaqService as e}from"@equinor/subsurface-app-management";import{useQuery as r}from"@tanstack/react-query";import{environment as t}from"../utils/auth_environment.js";function a(){return r({queryKey:["GET_FAQ_IN_APP"],queryFn:async()=>(await e.getCategoriesWithFaqsFromApplicationName(t.getAppName(import.meta.env.VITE_NAME))).toSorted(((e,r)=>(e.orderBy??0)-(r.orderBy??0))),staleTime:3e5})}export{a as useFaqsInApplication};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useRef as o,useMemo as n}from"react";import{Label as l,CircularProgress as r,Icon as a}from"@equinor/eds-core-react";import{arrow_drop_up as i,arrow_drop_down as s,clear as c}from"@equinor/eds-icons";import{tokens as d}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/index.js";import{useSelect as m}from"../../atoms/hooks/useSelect.js";import{getVariantIcon as h}from"../../atoms/utils/forms.js";import{GroupedSelectMenu as u}from"./GroupedSelectMenu.js";import{ListSelectMenu as p}from"./ListSelectMenu.js";import{ValueText as g,ComboBoxChip as f,Wrapper as b,Container as v,Section as x,PlaceholderText as S,ClearButton as y,HelperWrapper as C,StyledMenu as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useRef as o,useMemo as n}from"react";import{Label as l,CircularProgress as r,Icon as a}from"@equinor/eds-core-react";import{arrow_drop_up as i,arrow_drop_down as s,clear as c}from"@equinor/eds-icons";import{tokens as d}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/index.js";import{useSelect as m}from"../../atoms/hooks/useSelect.js";import{getVariantIcon as h}from"../../atoms/utils/forms.js";import{GroupedSelectMenu as u}from"./GroupedSelectMenu.js";import{ListSelectMenu as p}from"./ListSelectMenu.js";import{ValueText as g,ComboBoxChip as f,Wrapper as b,Container as v,Section as x,PlaceholderText as S,ClearButton as y,HelperWrapper as C,StyledMenu as w}from"./Select.styles.js";import{useOutsideClick as I}from"../../node_modules/@equinor/eds-utils/dist/esm/hooks/useOutsideClick.js";const{colors:O}=d,k=d=>{const{clearable:k=!0,loading:A=!1,disabled:T=!1,lightBackground:$=!1,underlineHighlight:j=!1,sortValues:D=!0,placeholder:R="Select...",label:V,helperText:B,showHelperIcon:F=!0,meta:K,id:_=`amplify-combobox-${V}`,variant:q,inDialog:z=!1,onSearchFilter:H,"data-testid":M}=d,{handleOnAddItem:W,handleOnClear:E,handleOnItemKeyDown:G,handleOnItemSelect:L,handleOnSearchChange:N,handleOnSearchKeyDown:J,handleToggleOpen:P,itemRefs:Q,search:U,selectedValues:X,handleOnClose:Y,handleOnOpen:Z,handleOnRemoveItem:ee,open:te,searchRef:oe,tryingToRemoveItem:ne}=m({...d,clearable:k,loading:A,disabled:T,lightBackground:$,underlineHighlight:j,sortValues:D,placeholder:R}),le=o(null),re=o(null),ae=n((()=>!!V||!!K),[V,K]),ie=n((()=>!!B),[B]),se=n((()=>{if(F)return h(q)}),[F,q]);I(re.current,(e=>{z&&te&&e.target&&le.current&&re.current&&!le.current.contains(e.target)&&!re.current?.contains(e.target)&&Y()}));const ce=n((()=>{if("value"in d&&d.value)return e(g,{children:d.value.label});if("showSelectedAsText"in d&&d.showSelectedAsText){const t=d.items?d.items.length:d.groups.flatMap((e=>e.items)).length,o="function"==typeof d.showSelectedAsText?d.showSelectedAsText({selectedAmount:X.length,totalAmount:t}):`${X.length}/${t} Selected`;return e(g,{children:o})}return X.map((t=>"customValueComponent"in d&&d.customValueComponent?e(d.customValueComponent,{item:t,onDelete:()=>ee(t),tryingToRemove:void 0!==ne&&ne.value===t.value},t.value):e(f,{"data-testid":"amplify-combobox-chip",className:"amplify-combo-box-chip",onDelete:()=>ee(t),$tryingToRemove:ne?.value===t.value,$lightBackground:$,children:t.label},t.value)))}),[X,ne,$,d,ee]);return t("div",{children:[ae&&e(l,{label:V,meta:K,htmlFor:_}),t(b,{children:[t(v,{"data-testid":M||"combobox-container",ref:le,onClick:Z,"aria-expanded":te,$variant:q,$lightBackground:$,children:[t(x,{children:[""===U&&0===X.length&&e(S,{children:R}),(""===U&&"value"in d||"values"in d&&X.length>0&&(!d.showSelectedAsText||d.showSelectedAsText&&""===U))&&ce,e("input",{id:_,disabled:T||A,ref:oe,type:"search",role:"combobox",value:U,autoComplete:"off",onChange:N,onKeyDownCapture:J})]}),A?e(r,{size:16}):e(a,{onClick:P,data:te?i:s,color:O.interactive.primary__resting.rgba}),k&&X.length>0&&!A&&e(y,{id:"clear",variant:"ghost_icon",onClick:E,"data-testid":"clearBtn",children:e(a,{data:c,size:18})})]}),ie&&t(C,{$variant:q,children:[se&&e(a,{data:se,size:16}),e(l,{label:B,htmlFor:_})]})]}),te&&e(w,{ref:re,open:!0,id:"combobox-menu",anchorEl:le.current,onClose:Y,placement:"bottom",style:{width:`${le.current?.clientWidth}px`,maxWidth:`${le.current?.clientWidth}px`},children:"groups"in d&&d.groups?e(u,{...d,search:U,itemRefs:Q,onItemSelect:L,onItemKeyDown:G,onSearchFilter:H}):e(p,{...d,search:U,itemRefs:Q,onAddItem:d.onAddItem?W:void 0,onItemSelect:L,onItemKeyDown:G,onSearchFilter:H})})]})};export{k as Select};
|
|
@@ -17,7 +17,10 @@ interface MultiSelectBase<T extends SelectOptionRequired> {
|
|
|
17
17
|
syncParentChildSelection?: boolean;
|
|
18
18
|
}
|
|
19
19
|
type MultiSelectWithSelectedAsText<T extends SelectOptionRequired> = {
|
|
20
|
-
showSelectedAsText: boolean
|
|
20
|
+
showSelectedAsText: boolean | (({ selectedAmount, totalAmount, }: {
|
|
21
|
+
selectedAmount: number;
|
|
22
|
+
totalAmount: number;
|
|
23
|
+
}) => string);
|
|
21
24
|
} & MultiSelectBase<T>;
|
|
22
25
|
type MultiSelectWithCustomValueComponent<T extends SelectOptionRequired> = {
|
|
23
26
|
showSelectedAsText?: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{forwardRef as o,Children as t}from"react";import{ToggleGroupOption as e}from"./ToggleGroupOption.js";import"../../molecules/RichTextEditor/custom-extensions/AmplifyKit.js";import"../../molecules/RichTextEditor/RichTextEditor.types.js";import"../../_virtual/lodash.js";import"../TopBar/Notifications/NotificationProvider.js";import"../../providers/AuthProvider/AuthProvider.js";import"../../providers/ReleaseNotesProvider.js";import"../../providers/SideBarProvider.js";import"../../providers/SnackbarProvider/SnackbarProvider.js";import"../../providers/StepperProvider.js";import"../../providers/TableOfContentsProvider.js";import"../../providers/ThemeProvider/ThemeProvider.js";import"react-router-dom";import"@tanstack/react-query";import"@equinor/subsurface-app-management";import"../../atoms/utils/auth_environment.js";import{shape as i}from"../../atoms/style/index.js";import"../../atoms/enums/Errors.js";import"../../atoms/enums/Environment.js";import"../../atoms/enums/Theme.js";import"../../atoms/enums/SpacingsMode.js";import"html2canvas";import"proj4";import"@equinor/eds-icons";import s,{css as a}from"styled-components";import{colors as m}from"../../atoms/style/colors.js";const
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{forwardRef as o,Children as t}from"react";import{ToggleGroupOption as e}from"./ToggleGroupOption.js";import"../../molecules/RichTextEditor/custom-extensions/AmplifyKit.js";import"../../molecules/RichTextEditor/RichTextEditor.types.js";import"../../_virtual/lodash.js";import"../TopBar/Notifications/NotificationProvider.js";import"../../providers/AuthProvider/AuthProvider.js";import"../../providers/ReleaseNotesProvider.js";import"../../providers/SideBarProvider.js";import"../../providers/SnackbarProvider/SnackbarProvider.js";import"../../providers/StepperProvider.js";import"../../providers/TableOfContentsProvider.js";import"../../providers/ThemeProvider/ThemeProvider.js";import"react-router-dom";import"@tanstack/react-query";import"@equinor/subsurface-app-management";import"../../atoms/utils/auth_environment.js";import{shape as i}from"../../atoms/style/index.js";import"../../atoms/enums/Errors.js";import"../../atoms/enums/Environment.js";import"../../atoms/enums/Theme.js";import"../../atoms/enums/SpacingsMode.js";import"html2canvas";import"proj4";import"@equinor/eds-icons";import s,{css as a}from"styled-components";import{colors as m}from"../../atoms/style/colors.js";const n=s.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
${({$variant:r})=>"filled"===r?a`
|
|
4
4
|
border-radius: ${i.button.borderRadius};
|
|
@@ -22,4 +22,8 @@ import{jsx as r}from"react/jsx-runtime";import{forwardRef as o,Children as t}fro
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
`:void 0}
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
${({$matchParentHeight:r})=>r?a`
|
|
27
|
+
height: 100%;
|
|
28
|
+
`:""}
|
|
29
|
+
`,p=o((({variant:o="filled",matchParentHeight:i=!1,children:s},a)=>r(n,{ref:a,$variant:o,$matchParentHeight:i,children:t.map(s,(r=>{if(r.type!=e)throw"Expected child to be ToggleGroupOption!";return r}))})));p.displayName="ToggleGroup";export{p as ToggleGroup};
|
|
@@ -4,7 +4,7 @@ import{jsxs as r,jsx as e}from"react/jsx-runtime";import{forwardRef as a}from"re
|
|
|
4
4
|
padding: calc(${s.medium_small} / 2); // 6px in comfortable
|
|
5
5
|
> span {
|
|
6
6
|
color: ${c.text.static_icons__tertiary.rgba};
|
|
7
|
-
padding: ${s.
|
|
7
|
+
padding: ${s.x_small} calc(${s.medium_small} / 2);
|
|
8
8
|
}
|
|
9
9
|
> svg {
|
|
10
10
|
fill: ${c.text.static_icons__tertiary.rgba};
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import { FC,
|
|
2
|
-
import { AccountInfo } from '@azure/msal-common';
|
|
1
|
+
import { FC, ReactElement, ReactNode, RefObject } from 'react';
|
|
3
2
|
export interface AccountProps {
|
|
4
|
-
|
|
5
|
-
* @deprecated logout - Not needed anymore
|
|
6
|
-
*/
|
|
7
|
-
logout?: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated account - Not needed anymore
|
|
10
|
-
*/
|
|
11
|
-
account?: AccountInfo | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated photo - Not needed anymore
|
|
14
|
-
*/
|
|
15
|
-
photo?: string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated roles - Not needed anymore
|
|
18
|
-
*/
|
|
19
|
-
roles?: string[] | undefined;
|
|
20
|
-
renderCustomButton?: (buttonRef: MutableRefObject<HTMLButtonElement | null>, handleToggle: () => void) => ReactElement;
|
|
3
|
+
renderCustomButton?: (buttonRef: RefObject<HTMLButtonElement | null>, handleToggle: () => void) => ReactElement;
|
|
21
4
|
hideRoleChips?: boolean;
|
|
5
|
+
useDisplayNameForRole?: boolean;
|
|
22
6
|
children?: ReactNode;
|
|
23
7
|
}
|
|
24
8
|
export declare const Account: FC<AccountProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as o,Fragment as r,jsx as e}from"react/jsx-runtime";import{useState as t,useRef as i,useCallback as
|
|
1
|
+
import{jsxs as o,Fragment as r,jsx as e}from"react/jsx-runtime";import{useState as t,useRef as i,useCallback as s,useEffect as m,useMemo as n}from"react";import{Typography as p,Button as a,Icon as u}from"@equinor/eds-core-react";import{log_out as c}from"@equinor/eds-icons";import{TopBarMenu as l}from"../TopBarMenu.js";import{useActiveImpersonationUser as d}from"./ImpersonateMenu/hooks/useActiveImpersonationUser.js";import{useCanImpersonate as h}from"./ImpersonateMenu/hooks/useCanImpersonate.js";import{useMappedRoles as v}from"./ImpersonateMenu/hooks/useMappedRoles.js";import{useStopImpersonation as j}from"./ImpersonateMenu/hooks/useStopImpersonation.js";import{ImpersonateMenu as f}from"./ImpersonateMenu/ImpersonateMenu.js";import{Container as I,TextContent as N,RolesContainer as A,RoleChip as E,ButtonWrapper as C}from"./Account.styles.js";import{AccountAvatar as T}from"./AccountAvatar.js";import{AccountButton as M}from"./AccountButton.js";import{ActiveUserImpersonationButton as P}from"./ActiveUserImpersonationButton.js";import{ImpersonateButton as k}from"./ImpersonateButton.js";import"../../../molecules/RichTextEditor/custom-extensions/AmplifyKit.js";import"../../../molecules/RichTextEditor/RichTextEditor.types.js";import"../../../_virtual/lodash.js";import"../Notifications/NotificationProvider.js";import{useAuth as R}from"../../../providers/AuthProvider/AuthProvider.js";import"../../../providers/ReleaseNotesProvider.js";import"../../../providers/SideBarProvider.js";import"../../../providers/SnackbarProvider/SnackbarProvider.js";import"../../../providers/StepperProvider.js";import"../../../providers/TableOfContentsProvider.js";import"../../../providers/ThemeProvider/ThemeProvider.js";import"react-router-dom";import"@tanstack/react-query";import"@equinor/subsurface-app-management";import{environment as g}from"../../../atoms/utils/auth_environment.js";import"../../../atoms/style/colors.js";import"../../../atoms/enums/Errors.js";import{EnvironmentType as _}from"../../../atoms/enums/Environment.js";import"../../../atoms/enums/Theme.js";import"../../../atoms/enums/SpacingsMode.js";import"html2canvas";import"proj4";import{impersonateUserDtoToFullName as y}from"./ImpersonateMenu/Impersonate.utils.js";const B=({renderCustomButton:B,hideRoleChips:x=!1,useDisplayNameForRole:S=!1,children:b})=>{const q=g.getEnvironmentName(import.meta.env.VITE_ENVIRONMENT_NAME),O=g.getApiClientId(import.meta.env.VITE_API_CLIENT_ID),U=g.getAppName(import.meta.env.VITE_NAME),{account:V,roles:D,logout:L}=R(),[F,K]=t(!1),[w,z]=t(!1),G=i(null),{data:H=!0}=h(),{data:J}=d(),{mutate:Q}=j(),W=v(J?J.roles:D??[],S),X=J?y(J):V?.name,Y=J?J.uniqueName:V?.username,Z=()=>K(!1),$=s((()=>{K((o=>!o)),z(!1)}),[]),oo=()=>{z(!0),K(!1)};m((()=>{J&&null!=J.appName&&J.appName.toUpperCase()!=U.toUpperCase()&&Q()}),[J,U,Q]);const ro=n((()=>B?B(G,$):null),[B,$]);return o(r,{children:[ro||e(M,{ref:G,onClick:$}),o(l,{open:F,title:"Account",onClose:Z,anchorEl:G.current,children:[o(I,{children:[J&&e(P,{onClick:oo}),e(T,{}),o(N,{children:[e(p,{variant:"h6",children:X}),e(p,{children:Y})]}),W&&!x&&e(A,{children:W.map((o=>e(E,{children:o.label},o.value)))}),b,H&&q!==_.PRODUCTION&&O&&e(k,{onOpenImpersonateMenu:oo,onClose:Z})]}),e(C,{children:o(a,{variant:"ghost",onClick:L,children:[e(u,{data:c}),"Log out"]})})]}),e(f,{open:w,onClose:()=>z(!1),anchorEl:G.current})]})};B.displayName="TopBar.Account";export{B as Account};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useRef as t,useState as l,useEffect as s,useMemo as r}from"react";import{Button as i,Icon as a,Typography as m,DotProgress as n}from"@equinor/eds-core-react";import{arrow_back as c}from"@equinor/eds-icons";import{useCreateImpersonation as p}from"../hooks/useCreateImpersonation.js";import{useEditImpersonation as u}from"../hooks/useEditImpersonation.js";import{Header as d}from"../Impersonate.styles.js";import{Container as j,Section as h}from"./CreateOrEditUser.styles.js";import{environment as v}from"../../../../../atoms/utils/auth_environment.js";import"../../../../../molecules/AnimatedCheckmark/AnimatedCheckmark.styles.js";import"../../../../../molecules/ApplicationIcon/ApplicationIcon.js";import"../../../../../molecules/Badge/Badge.styles.js";import"../../../../../molecules/Banner/Banner.styles.js";import"../../../../../molecules/Button/Button.js";import"../../../../../molecules/Chip/Chip.js";import"../../../../../molecules/ContentMenu/ContentMenu.styles.js";import"../../../../../molecules/DatePicker/DatePicker.js";import"../../../../../molecules/Dialog/Dialog.js";import"../../../../../molecules/EquinorLogo/EquinorLogo.js";import"../../../../../molecules/FileProgress/CompactFileProgress.styles.js";import"../../../../../atoms/style/colors.js";import"html2canvas";import"proj4";import"../../../../../molecules/RichTextEditor/RichTextEditor.types.js";import"../../../../../molecules/FileProgress/RegularFileProgress.styles.js";import"../../../../../molecules/FileUploadArea/FileUploadArea.js";import"../../../../../molecules/FullPageSpinner/FullPageSpinner.js";import"../../../../../molecules/InfoElement/InfoElement.js";import"../../../../../molecules/OptionalTooltip/OptionalTooltip.js";import"../../../../../molecules/ProfileAvatar/ProfileAvatar.js";import"@tiptap/react";import"../../../../../molecules/RichTextEditor/custom-extensions/AmplifyKit.js";import"../../../../../molecules/RichTextEditor/RichTextEditor.styles.js";import"../../../../../molecules/RichTextEditor/MenuBar/MenuBar.js";import"@tanstack/react-query";import"../../../../../molecules/Tabs/Tabs.js";import"../../../../../molecules/RichTextEditor/MenuBar/MenuBar.styles.js";import"../../../../../molecules/RichTextEditor/MenuBar/MenuButton.js";import"../../../../../molecules/Search/Search.js";import"react-router-dom";import"../../../../../molecules/Sieve/Sieve.styles.js";import"../../../../../_virtual/lodash.js";import"../../../../../molecules/SingleFilterMenu/SingleFilterMenu.js";import"../../../../../molecules/Skeleton/SkeletonBase/SkeletonBase.js";import"../../../../../molecules/Skeleton/Skeleton.styles.js";import"../../../../../molecules/Stepper/Stepper.js";import"../../../../../molecules/OptionDrawer/OptionDrawer.js";import{ComboBox as g}from"../../../../../molecules/Select/ComboBox/ComboBox.js";import"../../../../../molecules/Select/Select.styles.js";import"../../../../../molecules/ListItem/ListItem.js";import"../../../../../molecules/SelectionControls/Checkbox/Checkbox.js";import"../../../../../molecules/SelectionControls/Radio/Radio.js";import"../../../../../molecules/SelectionControls/Switch/Switch.js";import"../../../../../molecules/Waves/Waves.styles.js";import"framer-motion";import{TextField as C}from"../../../../../molecules/TextField/TextField.js";import{useAllAppRoles as S}from"../hooks/useAllAppRoles.js";const f=({editingUser:f,onBack:y})=>{const k=t(!1),[A,E]=l([]),[x,B]=l(""),[N,T]=l(""),[b,F]=l(""),{data:R,isLoading:P}=S();s((()=>{f&&R&&!k.current&&(k.current=!0,E(f.roles.map((e=>{const o=R.find((o=>o.value===e));return o?{value:e,label:o.displayName}:{value:e,label:e}}))),B(f.firstName),T(f.lastName),F(f.email??""))}),[R,f,k]);const M=r((()=>R?.map((e=>({value:e.value,label:e.displayName})))??[]),[R]),{mutateAsync:I,isPending:q}=p(),{mutateAsync:w,isPending:L}=u(),D=q||L,O=r((()=>""===x||""===N||0===A.length),[x,N,A.length]);return e(j,{children:[e(d,{children:[o(i,{variant:"ghost_icon",onClick:y,children:o(a,{data:c})}),o(m,{variant:"h6",children:f?"Edit user":"Create new user"})]}),e(h,{children:[o(C,{id:"first-name",label:"First name",placeholder:"Add first name...",value:x,onChange:e=>{B(e.target.value)}}),o(C,{id:"last-name",label:"Last name",placeholder:"Add last name...",value:N,onChange:e=>{T(e.target.value)}}),o(C,{id:"email",label:"E-mail",placeholder:"Add e-mail...",meta:"Optional",value:b,onChange:e=>{F(e.target.value)}})]}),e(h,{children:[o(m,{variant:"label",group:"navigation",children:"Roles"}),P&&o(n,{color:"primary"}),o(g,{placeholder:"Select roles...",values:A,onSelect:e=>{E(e)},items:M})]}),e(h,{children:[o(i,{variant:"outlined",onClick:y,children:"Cancel"}),o(i,D?{children:o(n,{})}:{onClick:async()=>{f?(await w({id:f.id,firstName:x,lastName:N,email:""!==b?b:void 0,roles:A.map((e=>e.value)).sort(),uniqueName:f.uniqueName,appName:f.appName,activeUsers:[]}),y()):(await I({firstName:x,lastName:N,email:""!==b?b:void 0,roles:A.map((e=>e.value)).sort(),uniqueName:`${x}.${N}`.toLowerCase(),appName:v.getAppName(import.meta.env.VITE_NAME),activeUsers:[]}),y())},disabled:O,children:f?"Save":"Create"})]})]})};export{f as CreateOrEditUser};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{useState as i,useRef as o}from"react";import{Icon as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{useState as i,useRef as o}from"react";import{Icon as l,Typography as n,Button as a,Menu as s}from"@equinor/eds-core-react";import{account_circle as c,check as d,more_horizontal as m,edit as g,delete_to_trash as p}from"@equinor/eds-icons";import{useMappedRoles as h}from"./hooks/useMappedRoles.js";import{Container as u,RoleChipContainer as f,RoleChip as b}from"./UserImpersonation.styles.js";import{colors as _}from"../../../../atoms/style/colors.js";import{ListItem as v}from"../../../../molecules/ListItem/ListItem.js";import{OptionalTooltip as C}from"../../../../molecules/OptionalTooltip/OptionalTooltip.js";import{impersonateUserDtoToFullName as j}from"./Impersonate.utils.js";import k from"styled-components";const $=k(v)`
|
|
2
2
|
svg {
|
|
3
3
|
fill: ${_.interactive.danger__resting.rgba};
|
|
4
4
|
}
|
|
@@ -13,4 +13,4 @@ import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{useState
|
|
|
13
13
|
&:hover:not(:disabled) {
|
|
14
14
|
background: ${_.interactive.danger__highlight.rgba};
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
`,y=({firstName:k,lastName:y,uniqueName:N,roles:x,activeUsers:I,selected:q,onClick:E,onEdit:D,onDelete:L})=>{const[O,T]=i(!1),U=o(null),w=j({firstName:k,lastName:y}),M=h(x),R=()=>T(!1);return e(t,{children:[e(u,{$selected:q,onClick:e=>{e.target!==U.current&&E(N)},"data-testid":"impersonation-user",children:[r(l,{color:_.text.static_icons__tertiary.rgba,data:c}),r(n,{"data-testid":"name",children:w}),e(f,{$selected:q,children:[r(b,{"data-testid":"role",children:M[0].label}),M.length>1&&r(C,{title:M.slice(1).join(", "),children:r(b,{"data-testid":"additional-roles",children:"+"+(M.length-1)})})]}),q&&r(l,{data:d,color:_.interactive.primary__resting.rgba}),r(a,{variant:"ghost_icon",ref:U,onClick:()=>T((e=>!e)),children:r(l,{data:m})})]}),O&&e(s,{open:!0,anchorEl:U.current,placement:"right-start",onClose:R,children:[r(v,{label:"Edit user",onClick:()=>{D(N),R()},leadingContent:g}),r(C,{title:I.length>0?"Cannot delete user with active sessions":void 0,children:r($,{label:"Delete user",onClick:()=>{L(N),R()},disabled:I.length>0,leadingContent:p})})]})]})};export{y as UserImpersonation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useAllAppRoles(): import("@tanstack/react-query").UseQueryResult<import("@equinor/subsurface-app-management/dist/api/models/GraphAppRole").GraphAppRole[], Error>;
|
|
1
|
+
export declare function useAllAppRoles(enabled?: boolean): import("@tanstack/react-query").UseQueryResult<import("@equinor/subsurface-app-management/dist/api/models/GraphAppRole").GraphAppRole[], Error>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AmplifyApplicationService as
|
|
1
|
+
import{AmplifyApplicationService as e}from"@equinor/subsurface-app-management";import{useQuery as t}from"@tanstack/react-query";import{AVAILABLE_ROLES as r}from"../Impersonate.constants.js";import{environment as m}from"../../../../../atoms/utils/auth_environment.js";function n(n=!0){return t({queryKey:[r],queryFn:()=>e.getAllAppRoles(m.getApiClientId(import.meta.env.VITE_API_CLIENT_ID)),enabled:n,staleTime:1/0,gcTime:1/0})}export{n as useAllAppRoles};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as e}from"react";import{useAllAppRoles as a}from"./useAllAppRoles.js";function l(l,t=!0){const{data:o=[]}=a(t);return e((()=>l.toSorted().map((e=>{const a=o.find((a=>a.value===e));return a?{value:a.value,label:a.displayName}:{value:e,label:e}}))),[o,l])}export{l as useMappedRoles};
|