-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🕹 Manage root users #146
Merged
Merged
🕹 Manage root users #146
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35621c4
feat: manage root users
MontaGhanmy e833ed9
feat: updated root users ui
MontaGhanmy c9886aa
feat: backend ref
MontaGhanmy e19d4e4
merge: resolve conflicts
MontaGhanmy 984bf4b
fix: merge marker
MontaGhanmy 4e81538
fix: lint/prettier
MontaGhanmy f5f767b
feat: access level control inversion
MontaGhanmy afb63e0
feat: conflict resolution
MontaGhanmy 04fc805
ref: types and error management
MontaGhanmy d8c2520
feat: updating access admin check
MontaGhanmy 07d08f1
feat: updated check access for new users
MontaGhanmy 548d8ba
feat: updated tests
MontaGhanmy 0a9aeaa
fix: e2e tests
MontaGhanmy 9990c91
ref: manage user list
MontaGhanmy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tdrive/frontend/src/app/views/client/body/drive/modals/manage-users/common.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Select from '@atoms/input/input-select'; | ||
import { DriveFileAccessLevel } from '@features/drive/types'; | ||
import Languages from 'features/global/services/languages-service'; | ||
|
||
export const AccessLevel = ({ | ||
disabled, | ||
level, | ||
onChange, | ||
canRemove, | ||
hiddenLevels, | ||
className, | ||
}: { | ||
disabled?: boolean; | ||
level: DriveFileAccessLevel | null; | ||
onChange: (level: DriveFileAccessLevel & 'remove') => void; | ||
canRemove?: boolean; | ||
className?: string; | ||
hiddenLevels?: string[]; | ||
}) => { | ||
return ( | ||
<Select | ||
disabled={disabled} | ||
className={ | ||
className + | ||
' w-auto ' + | ||
(level === 'none' ? '!text-rose-500 !bg-rose-100 dark-bg-rose-800' : '') | ||
} | ||
value={level || 'none'} | ||
onChange={e => onChange(e.target.value as DriveFileAccessLevel & 'remove')} | ||
> | ||
{!hiddenLevels?.includes('manage') && <option value={'manage'}>{Languages.t('common.access-level_full_acess')}</option>} | ||
{!hiddenLevels?.includes('write') && <option value={'write'}>{Languages.t('common.access-level_write')}</option>} | ||
{!hiddenLevels?.includes('read') && <option value={'read'}>{Languages.t('common.access-level_read')}</option>} | ||
{!hiddenLevels?.includes('none') && <option value={'none'}>{Languages.t('common.access-level_no_access')}</option>} | ||
{canRemove && <option value={'remove'}>Remove</option>} | ||
</Select> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
tdrive/frontend/src/app/views/client/body/drive/modals/manage-users/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Modal, ModalContent } from '@atoms/modal'; | ||
import { useDriveItem } from '@features/drive/hooks/use-drive-item'; | ||
import { useEffect } from 'react'; | ||
import { atom, useRecoilState } from 'recoil'; | ||
import { InternalAccessManager } from './internal-access'; | ||
import { PublicLinkManager } from './public-link-access'; | ||
import Languages from 'features/global/services/languages-service'; | ||
|
||
|
||
export type AccessModalType = { | ||
open: boolean; | ||
id: string; | ||
}; | ||
|
||
export const AccessModalAtom = atom<AccessModalType>({ | ||
key: 'AccessModalAtom', | ||
default: { | ||
open: false, | ||
id: '', | ||
}, | ||
}); | ||
|
||
export const AccessModal = () => { | ||
const [state, setState] = useRecoilState(AccessModalAtom); | ||
|
||
return ( | ||
<Modal open={state.open} onClose={() => setState({ ...state, open: false })}> | ||
{!!state.id && <AccessModalContent id={state.id} />} | ||
</Modal> | ||
); | ||
}; | ||
|
||
const AccessModalContent = ({ id }: { id: string }) => { | ||
const { item, access, refresh } = useDriveItem(id); | ||
|
||
useEffect(() => { | ||
refresh(id); | ||
}, []); | ||
|
||
console.log(item?.access_info?.public?.level, 'item'); | ||
|
||
return ( | ||
<ModalContent title={Languages.t('components.item_context_menu.manage_access_to') + " " + item?.name}> | ||
<PublicLinkManager id={id} disabled={access !== 'manage'} /> | ||
<InternalAccessManager id={id} disabled={access !== 'manage'} /> | ||
</ModalContent> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
1
mean?(Magic constant spotted).
I recommend to extract this as a global variable and give it a name.