Skip to content

Commit

Permalink
initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Dec 13, 2023
1 parent a5a1850 commit 27f5d42
Show file tree
Hide file tree
Showing 6 changed files with 649 additions and 153 deletions.
85 changes: 50 additions & 35 deletions app/javascript/components/recordings/RecordingRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function RecordingRow({
const currentUser = useAuth();
const redirectRecordingUrl = useRedirectRecordingUrl();
const copyRecordingUrl = useCopyRecordingUrl();
const allowedVisibilities = JSON.parse(currentUser.permissions?.AccessToVisibilities)

const localizedTime = localizeDateTimeString(recording?.recorded_at, currentUser?.language);
const formats = recording.formats.sort(
Expand Down Expand Up @@ -106,41 +107,55 @@ export default function RecordingRow({
defaultValue={recording.visibility}
dropUp={dropUp}
>
<Dropdown.Item
key="Public/Protected"
value="Public/Protected"
onClick={() => visibilityAPI.mutate({ visibility: 'Public/Protected', id: recording.record_id })}
>
{t('recording.public_protected')}
</Dropdown.Item>
<Dropdown.Item
key="Public"
value="Public"
onClick={() => visibilityAPI.mutate({ visibility: 'Public', id: recording.record_id })}
>
{t('recording.public')}
</Dropdown.Item>
<Dropdown.Item
key="Protected"
value="Protected"
onClick={() => visibilityAPI.mutate({ visibility: 'Protected', id: recording.record_id })}
>
{t('recording.protected')}
</Dropdown.Item>
<Dropdown.Item
key="Published"
value="Published"
onClick={() => visibilityAPI.mutate({ visibility: 'Published', id: recording.record_id })}
>
{t('recording.published')}
</Dropdown.Item>
<Dropdown.Item
key="Unpublished"
value="Unpublished"
onClick={() => visibilityAPI.mutate({ visibility: 'Unpublished', id: recording.record_id })}
>
{t('recording.unpublished')}
</Dropdown.Item>
{ (allowedVisibilities.includes('Public/Protected') || recording.visibility == 'Public/Protected') && (
<Dropdown.Item
key="Public/Protected"
value="Public/Protected"
onClick={() => visibilityAPI.mutate({ visibility: 'Public/Protected', id: recording.record_id })}
>
{t('recording.public_protected')}
</Dropdown.Item>
)}

{ (allowedVisibilities.includes('Public') || recording.visibility == 'Public') && (
<Dropdown.Item
key="Public"
value="Public"
onClick={() => visibilityAPI.mutate({ visibility: 'Public', id: recording.record_id })}
>
{t('recording.public')}
</Dropdown.Item>
)}

{ (allowedVisibilities.includes('Protected') || recording.visibility == 'Protected') && (
<Dropdown.Item
key="Protected"
value="Protected"
onClick={() => visibilityAPI.mutate({ visibility: 'Protected', id: recording.record_id })}
>
{t('recording.protected')}
</Dropdown.Item>
)}

{ (allowedVisibilities.includes('Published') || recording.visibility == 'Published') && (
<Dropdown.Item
key="Published"
value="Published"
onClick={() => visibilityAPI.mutate({ visibility: 'Published', id: recording.record_id })}
>
{t('recording.published')}
</Dropdown.Item>
)}

{ (allowedVisibilities.includes('Unpublished') || recording.visibility == 'Unpublished') && (
<Dropdown.Item
key="Unpublished"
value="Unpublished"
onClick={() => visibilityAPI.mutate({ visibility: 'Unpublished', id: recording.record_id })}
>
{t('recording.unpublished')}
</Dropdown.Item>
)}
</SimpleSelect>
</td>
<td className="border-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ChevronDownIcon } from '@heroicons/react/20/solid';

export default function SimpleSelect({ defaultValue, dropUp, children }) {
// Get the currently selected option and set the dropdown toggle to that value
console.log(children)
const defaultString = children?.filter((item) => item.props.value === defaultValue)[0];

return (
Expand Down
15 changes: 15 additions & 0 deletions db/data/20231210154647_add_visibility_to_role_permissions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class AddVisibilityToRolePermissions < ActiveRecord::Migration[7.1]
def up
visibility_permission = Permission.create!(name: 'AccessToVisibilities')

Role.all.each do |role|
RolePermission.create!(role:, permission: visibility_permission, value: Recording::VISIBILITIES.values)
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
2 changes: 1 addition & 1 deletion db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20231117151542)
DataMigrate::Data.define(version: 20231210154647)
16 changes: 16 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 27f5d42

Please sign in to comment.