This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IR-48 Created a Tailwind AutoComplete component and updated Radio Com…
…ponent (#10254) * Add Autocomplete component * Update Autocomplete dropdown positioning * Update Autocomplete dropdown width * Refactor AutoComplete component to include onChange prop * Update Autocomplete options structure * Add useRef hook to track option selection in AutoComplete component * Refactor Radio component to include a description * Refactor AutoComplete component to remove unused code * Fix Autocomplete dropdown visibility issue * Fix project permission type bug * Fix project permission type in patch * IR-2538 Updated project-permission service to include createdBy column (#10346) * Add createdBy column to project-permission service * Update migration name --------- Co-authored-by: Hanzla Mateen <[email protected]> * Cleaned autocomplete * feat: Refactor project-permission.hooks.ts to use explicit type casting * Updated tests * feat: Add 'type' parameter to createPermission function in ProjectService --------- Co-authored-by: Hanzla Mateen <[email protected]>
- Loading branch information
1 parent
63c9434
commit 9b96653
Showing
9 changed files
with
198 additions
and
49 deletions.
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
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
74 changes: 74 additions & 0 deletions
74
...server-core/src/projects/project-permission/migrations/20240607053537_createdBy-column.ts
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,74 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import { projectPermissionPath } from '@etherealengine/common/src/schemas/projects/project-permission.schema' | ||
import type { Knex } from 'knex' | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
export async function up(knex: Knex): Promise<void> { | ||
await knex.raw('SET FOREIGN_KEY_CHECKS=0') | ||
|
||
await addCreatedByColumn(knex, projectPermissionPath) | ||
|
||
await knex.raw('SET FOREIGN_KEY_CHECKS=1') | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
export async function down(knex: Knex): Promise<void> { | ||
await knex.raw('SET FOREIGN_KEY_CHECKS=0') | ||
|
||
await dropCreatedByColumn(knex, projectPermissionPath) | ||
|
||
await knex.raw('SET FOREIGN_KEY_CHECKS=1') | ||
} | ||
|
||
export async function addCreatedByColumn(knex: Knex, tableName: string) { | ||
const createdByColumnExists = await knex.schema.hasColumn(tableName, 'createdBy') | ||
|
||
if (createdByColumnExists === false) { | ||
await knex.schema.alterTable(tableName, async (table) => { | ||
//@ts-ignore | ||
table.uuid('createdBy', 36).collate('utf8mb4_bin').nullable().index() | ||
table.foreign('createdBy').references('id').inTable('user').onDelete('CASCADE').onUpdate('CASCADE') | ||
}) | ||
} | ||
} | ||
|
||
export async function dropCreatedByColumn(knex: Knex, tableName: string) { | ||
const createdByColumnExists = await knex.schema.hasColumn(tableName, 'createdBy') | ||
|
||
if (createdByColumnExists === true) { | ||
await knex.schema.alterTable(tableName, async (table) => { | ||
table.dropForeign('createdBy') | ||
table.dropColumn('createdBy') | ||
}) | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
packages/ui/src/primitives/tailwind/Autocomplete/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,63 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import React from 'react' | ||
import Input from '../Input' | ||
|
||
export type AutoCompleteOptionsType = { label: string; value: any } | ||
|
||
export interface AutoCompleteProps { | ||
value: string | ||
options: AutoCompleteOptionsType[] | ||
className?: string | ||
placeholder?: string | ||
onSelect: (value: any) => void | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void | ||
} | ||
|
||
const AutoComplete = ({ options, onSelect, placeholder, className, value, onChange }: AutoCompleteProps) => { | ||
return ( | ||
<div className={`relative ${className}`}> | ||
<Input value={value} placeholder={placeholder} className="w-full" onChange={onChange} /> | ||
{options.length > 0 && ( | ||
<div className="fixed left-10 right-0 z-[60] mt-2 w-1/2 rounded border border-theme-primary bg-theme-surface-main"> | ||
<ul className="max-h-40 overflow-auto [&>li]:px-4 [&>li]:py-2"> | ||
{options.map((option, index) => ( | ||
<li | ||
key={index} | ||
className="cursor-pointer px-4 py-2 text-theme-secondary" | ||
onClick={() => onSelect(option.value)} | ||
> | ||
{option.label} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default AutoComplete |
Oops, something went wrong.